aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/cgi
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageialinux-online.org>2015-10-10 09:16:26 +0200
committerPapoteur <papoteur@mageialinux-online.org>2015-10-10 09:16:26 +0200
commit142d404aa8cffc9f4785e5347f26036463dedcd4 (patch)
treec58f4d5c692c945eb10180baadb123d2c3762ad3 /MgaRepo/cgi
parent3e3e90e699192df60eeafb2ec7a9e087aff97195 (diff)
downloadmgarepo-142d404aa8cffc9f4785e5347f26036463dedcd4.tar
mgarepo-142d404aa8cffc9f4785e5347f26036463dedcd4.tar.gz
mgarepo-142d404aa8cffc9f4785e5347f26036463dedcd4.tar.bz2
mgarepo-142d404aa8cffc9f4785e5347f26036463dedcd4.tar.xz
mgarepo-142d404aa8cffc9f4785e5347f26036463dedcd4.zip
Apply 2to3-3.4
Diffstat (limited to 'MgaRepo/cgi')
-rw-r--r--MgaRepo/cgi/soapserver.py18
-rw-r--r--MgaRepo/cgi/submit.py23
-rw-r--r--MgaRepo/cgi/xmlrpcserver.py32
3 files changed, 36 insertions, 37 deletions
diff --git a/MgaRepo/cgi/soapserver.py b/MgaRepo/cgi/soapserver.py
index a203940..2fdbe0b 100644
--- a/MgaRepo/cgi/soapserver.py
+++ b/MgaRepo/cgi/soapserver.py
@@ -18,28 +18,28 @@ class SoapIface:
username = os.environ.get("REMOTE_USER")
packager = config.get("users", username)
if not packager:
- raise CgiError, "your email was not found"
+ raise CgiError("your email was not found")
elif not packagerev:
- raise CgiError, "no revision provided"
+ raise CgiError("no revision provided")
elif not targetname:
- raise CgiError, "no target provided"
+ raise CgiError("no target provided")
else:
targetname = targetname.lower()
for target in get_targets():
if target.name.lower() == targetname:
break
else:
- raise CgiError, "target not found"
+ raise CgiError("target not found")
try:
tmp = int(packagerev)
except ValueError:
- raise CgiError, "invalid revision provided"
+ raise CgiError("invalid revision provided")
for allowed in target.allowed:
if packageurl.startswith(allowed):
break
else:
- raise CgiError, "%s is not allowed for this target" \
- % packageurl
+ raise CgiError("%s is not allowed for this target" \
+ % packageurl)
get_srpm(packageurl,
revision=packagerev,
targetdirs=target.target,
@@ -73,10 +73,10 @@ Content-type: text/html
def show(msg="", error=0):
if error:
msg = '<font color="red">%s</font>' % msg
- print TEMPLATE % {"message":msg}
+ print(TEMPLATE % {"message":msg})
def main():
- if not os.environ.has_key('REQUEST_METHOD'):
+ if 'REQUEST_METHOD' not in os.environ:
sys.stderr.write("error: this program is meant to be used as a cgi\n")
sys.exit(1)
if not NINZ:
diff --git a/MgaRepo/cgi/submit.py b/MgaRepo/cgi/submit.py
index cba5977..e06ae07 100644
--- a/MgaRepo/cgi/submit.py
+++ b/MgaRepo/cgi/submit.py
@@ -55,7 +55,7 @@ def get_targetoptions():
def show(msg="", error=0):
if error:
msg = '<font color="red">%s</font>' % msg
- print TEMPLATE % {"message":msg, "targetoptions":get_targetoptions()}
+ print(TEMPLATE % {"message":msg, "targetoptions":get_targetoptions()})
def submit_packages(packager):
form = cgi.FieldStorage()
@@ -64,25 +64,25 @@ def submit_packages(packager):
if not packageurl:
show()
elif not packagerev:
- raise CgiError, "No revision provided!"
+ raise CgiError("No revision provided!")
else:
targetname = form.getfirst("target")
if not targetname:
- raise CgiError, "No target selected!"
+ raise CgiError("No target selected!")
for target in get_targets():
if target.name == targetname:
break
else:
- raise CgiError, "Target not found!"
+ raise CgiError("Target not found!")
try:
tmp = int(packagerev)
except ValueError:
- raise CgiError, "Invalid revision provided!"
+ raise CgiError("Invalid revision provided!")
for allowed in target.allowed:
if packageurl.startswith(allowed):
break
else:
- raise CgiError, "%s is not allowed for this target!" % packageurl
+ raise CgiError("%s is not allowed for this target!" % packageurl)
get_srpm(packageurl,
revision=packagerev,
targetdirs=target.target,
@@ -93,10 +93,10 @@ def submit_packages(packager):
show("Package submitted!")
def main():
- if not os.environ.has_key('REQUEST_METHOD'):
+ if 'REQUEST_METHOD' not in os.environ:
sys.stderr.write("error: this program is meant to be used as a cgi\n")
sys.exit(1)
- print "Content-type: text/html\n\n"
+ print("Content-type: text/html\n\n")
try:
username = os.environ.get("REMOTE_USER")
method = os.environ.get("REQUEST_METHOD")
@@ -105,12 +105,11 @@ def main():
else:
useremail = config.get("users", username)
if not useremail:
- raise CgiError, \
- "Your email was not found. Contact the administrator!"
+ raise CgiError("Your email was not found. Contact the administrator!")
submit_packages(useremail)
- except CgiError, e:
+ except CgiError as e:
show(str(e), error=1)
- except Error, e:
+ except Error as e:
error = str(e)
show(error[0].upper()+error[1:], error=1)
except:
diff --git a/MgaRepo/cgi/xmlrpcserver.py b/MgaRepo/cgi/xmlrpcserver.py
index 8521b4f..a1b2b73 100644
--- a/MgaRepo/cgi/xmlrpcserver.py
+++ b/MgaRepo/cgi/xmlrpcserver.py
@@ -5,7 +5,7 @@ from MgaRepo.cgiutil import CgiError, get_targets
import sys
import os
-import xmlrpclib, cgi
+import xmlrpc.client, cgi
class XmlRpcIface:
def author_email(self, author):
@@ -15,28 +15,28 @@ class XmlRpcIface:
username = os.environ.get("REMOTE_USER")
packager = config.get("users", username)
if not packager:
- raise CgiError, "your email was not found"
+ raise CgiError("your email was not found")
elif not packagerev:
- raise CgiError, "no revision provided"
+ raise CgiError("no revision provided")
elif not targetname:
- raise CgiError, "no target provided"
+ raise CgiError("no target provided")
else:
targetname = targetname.lower()
for target in get_targets():
if target.name.lower() == targetname:
break
else:
- raise CgiError, "target not found"
+ raise CgiError("target not found")
try:
tmp = int(packagerev)
except ValueError:
- raise CgiError, "invalid revision provided"
+ raise CgiError("invalid revision provided")
for allowed in target.allowed:
if packageurl.startswith(allowed):
break
else:
- raise CgiError, "%s is not allowed for this target" \
- % packageurl
+ raise CgiError("%s is not allowed for this target" \
+ % packageurl)
get_srpm(packageurl,
revision=packagerev,
targetdirs=target.target,
@@ -70,10 +70,10 @@ Content-type: text/html
def show(msg="", error=0):
if error:
msg = '<font color="red">%s</font>' % msg
- print TEMPLATE % {"message":msg}
+ print(TEMPLATE % {"message":msg})
def main():
- if not os.environ.has_key('REQUEST_METHOD'):
+ if 'REQUEST_METHOD' not in os.environ:
sys.stderr.write("error: this program is meant to be used as a cgi\n")
sys.exit(1)
username = os.environ.get("REMOTE_USER")
@@ -87,25 +87,25 @@ def main():
response = ""
try:
form = cgi.FieldStorage()
- parms, method = xmlrpclib.loads(form.value)
+ parms, method = xmlrpc.client.loads(form.value)
meth = getattr(iface, method)
response = (meth(*parms),)
- except CgiError, e:
+ except CgiError as e:
msg = str(e)
try:
msg = msg.decode("iso-8859-1")
except UnicodeError:
pass
- response = xmlrpclib.Fault(1, msg)
- except Exception, e:
+ response = xmlrpc.client.Fault(1, msg)
+ except Exception as e:
msg = str(e)
try:
msg = msg.decode("iso-8859-1")
except UnicodeError:
pass
- response = xmlrpclib.Fault(1, msg)
+ response = xmlrpc.client.Fault(1, msg)
sys.stdout.write("Content-type: text/xml\n\n")
- sys.stdout.write(xmlrpclib.dumps(response, methodresponse=1))
+ sys.stdout.write(xmlrpc.client.dumps(response, methodresponse=1))
# vim:et:ts=4:sw=4