Python 2.6 compatibility
mmilitzer opened this issue · 1 comments
mmilitzer commented
I've just upgraded our very old install of localshop to the latest version and then noticed it didn't work anymore. Seems the problem is that our system Python is still v2.6. I'm not sure if Python 2.6 is supposed to be still supported by the project at all but I seem to have get everything working again with just a few minor changes.
Since it's really just a few lines of code, I'm too lazy to prepare a pull request. So here's the patches just pasted in-line below (patch is against the 0.9.3 release):
--- /usr/lib/python2.6/site-packages/localshop/utils.py 2016-08-12 12:30:02.440684000 +0000
+++ ./localshop/utils.py 2016-08-12 12:07:49.576485816 +0000
@@ -35,8 +35,8 @@
def generate_key(function, *args, **kwargs):
args_string = ','.join([str(arg) for arg in args] +
- ['{}={}'.format(k, v) for k, v in kwargs.items()])
- return '{}({})'.format(function.__name__, args_string)
+ ['{0}={1}'.format(k, v) for k, v in kwargs.items()])
+ return '{0}({1})'.format(function.__name__, args_string)
def enqueue(function, *args, **kwargs):
-bash-4.1$ diff -u /usr/lib/python2.6/site-packages/localshop/apps/packages/views.py ./localshop/apps/packages/views.py
--- /usr/lib/python2.6/site-packages/localshop/apps/packages/views.py 2016-08-12 12:30:02.451684000 +0000
+++ ./localshop/apps/packages/views.py 2016-08-12 12:07:39.954516042 +0000
@@ -92,7 +92,7 @@
package = models.Package.objects.get(condition)
except ObjectDoesNotExist:
enqueue(fetch_package, slug)
- return redirect('https://pypi.python.org/simple/{}'.format(slug))
+ return redirect('https://pypi.python.org/simple/{0}'.format(slug))
# Redirect if slug is not an exact match
if slug != package.name:
-bash-4.1$ diff -u /usr/lib/python2.6/site-packages/localshop/apps/packages/tasks.py ./localshop/apps/packages/tasks.py
--- /usr/lib/python2.6/site-packages/localshop/apps/packages/tasks.py 2016-08-12 12:30:02.451684000 +0000
+++ ./localshop/apps/packages/tasks.py 2016-08-12 12:07:44.543501610 +0000
@@ -20,7 +20,7 @@
"""
logging.info('start fetch_package: %s', slug)
- response = requests.get(settings.LOCALSHOP_PYPI_URL + '/{}/json'.format(slug))
+ response = requests.get(settings.LOCALSHOP_PYPI_URL + '/{0}/json'.format(slug))
if response.status_code == 404:
return
canassa commented
Python 2.6 is not supported even by Django itself, so even with this patch you are likely to run into issues. I strongly suggest you to update your Python to 2.7.