1
0
mirror of https://github.com/pypiserver/pypiserver synced 2025-02-22 19:19:37 +01:00

make core.py and manage.py compatible with python 3 without running 2to3

This commit is contained in:
Ralf Schmitt 2011-11-23 22:59:31 +01:00
parent 7134ffc966
commit 3e253b3bbd
2 changed files with 10 additions and 4 deletions

@ -240,7 +240,8 @@ def main(argv=None):
try:
opts, roots = getopt.getopt(argv[1:], "i:p:r:d:Uuxh", ["interface=", "port=", "root=", "server=", "disable-fallback", "version", "help"])
except getopt.GetoptError, err:
except getopt.GetoptError:
err = sys.exc_info()[1]
sys.exit("usage error: %s" % (err,))
for k, v in opts:
@ -280,7 +281,8 @@ def main(argv=None):
try:
os.listdir(root)
except Exception, err:
except Exception:
err = sys.exc_info()[1]
sys.exit("Error: while trying to list %r: %s" % (root, err))
packages = pkgset(root)

@ -1,7 +1,11 @@
import sys, os, re, xmlrpclib
import sys, os, re
from pypiserver import core
if sys.version_info >= (3,0):
from xmlrpc.client import Server
else:
from xmlrpclib import Server
# --- the following two functions were copied from distribute's pkg_resources module
component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE)
@ -65,7 +69,7 @@ def find_updates(pkgset, stable_only=True):
sys.stdout.write(s)
sys.stdout.flush()
pypi = xmlrpclib.Server("http://pypi.python.org/pypi/")
pypi = Server("http://pypi.python.org/pypi/")
pkgname2latest = {}
pkgfiles = [pkgfile(x) for x in pkgset.find_packages()]