misc: add python 3 compat
This commit is contained in:
parent
0bcb3351fb
commit
fdf04887c0
|
@ -9,7 +9,7 @@ X-Python-Version: >= 2.7
|
|||
Package: python-scrutiny
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, ${python:Depends},
|
||||
python-django (>= 1.7),
|
||||
python-django (>= 1.8),
|
||||
python-gadjo
|
||||
Recommends: python-django-mellon
|
||||
Description: Tracker of installed modules
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
django >= 1.7, < 1.8
|
||||
django >= 1.7, < 1.9
|
||||
gadjo
|
||||
requests
|
||||
|
|
|
@ -15,13 +15,13 @@ class Command(BaseCommand):
|
|||
if not service.url.endswith('/'):
|
||||
service.url = '%s/' % service.url
|
||||
if self.verbose:
|
||||
print 'Checking', service.url
|
||||
print('Checking %s' % service.url)
|
||||
try:
|
||||
response = requests.get('%s__version__' % service.url,
|
||||
timeout=5, verify=False)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
print 'Error with', service.url, e
|
||||
print('Error with %s (%r)' % (service.url, e))
|
||||
continue
|
||||
|
||||
versions = response.json()
|
||||
|
|
|
@ -55,7 +55,7 @@ class Service(models.Model):
|
|||
uninstalled_modules.append(installed_version.version.module)
|
||||
continue
|
||||
modules[installed_version.version.module.name] = installed_version.version.module
|
||||
return sorted(modules.values(), lambda x, y: cmp(x.name, y.name))
|
||||
return sorted(modules.values(), key=lambda x: x.name)
|
||||
|
||||
def get_installed_service(self, platform):
|
||||
try:
|
||||
|
@ -144,7 +144,7 @@ class Module(models.Model):
|
|||
p = subprocess.Popen(cmd, **kws)
|
||||
stdout = p.communicate()[0]
|
||||
p.wait()
|
||||
return stdout
|
||||
return stdout.decode('utf-8')
|
||||
|
||||
def get_all_installed_versions(self):
|
||||
versions = set()
|
||||
|
|
|
@ -61,7 +61,7 @@ class ModuleIssuesView(TemplateView):
|
|||
issue = issues[int(issue.id)]
|
||||
issue.add_commit(commit)
|
||||
|
||||
issues_list = issues.items()
|
||||
issues_list = list(issues.items())
|
||||
issues_list.sort()
|
||||
context['issues'] = [x[1] for x in issues_list]
|
||||
|
||||
|
@ -118,12 +118,12 @@ class ProjectSummaryHistoryView(DetailView):
|
|||
'name': installed.version.module.name,
|
||||
'current_version': installed.version.version,
|
||||
}
|
||||
versions_sorted_by_day = versions_and_day.values()
|
||||
versions_sorted_by_day = list(versions_and_day.values())
|
||||
versions_sorted_by_day.sort(key=lambda x: x.get('day'))
|
||||
|
||||
previous_versions = {}
|
||||
for version_and_day in versions_sorted_by_day:
|
||||
for module_name, module_versions in version_and_day['modules'].items():
|
||||
for module_name, module_versions in list(version_and_day['modules'].items()):
|
||||
if module_name in previous_versions:
|
||||
module_versions['previous_version'] = previous_versions[module_name]
|
||||
if module_versions['previous_version'] == module_versions['current_version']:
|
||||
|
@ -235,7 +235,7 @@ class IssuesSnippet(TemplateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super(IssuesSnippet, self).get_context_data(**kwargs)
|
||||
|
||||
modules = json.loads(self.request.read())
|
||||
modules = json.loads(self.request.read().decode('utf-8'))
|
||||
|
||||
issues = {}
|
||||
for module_info in modules.values():
|
||||
|
@ -258,7 +258,7 @@ class IssuesSnippet(TemplateView):
|
|||
issues[int(issue.id)].modules = {}
|
||||
issues[int(issue.id)].modules[module_info['name']] = True
|
||||
|
||||
context['issues'] = issues.values()
|
||||
context['issues'] = list(issues.values())
|
||||
context['issues'].sort(key=lambda x: x.closed_on)
|
||||
context['issues'].reverse() # most recent on top
|
||||
return context
|
||||
|
|
|
@ -100,4 +100,4 @@ REDMINE_API_KEY = None
|
|||
local_settings_file = os.environ.get('SCRUTINY_SETTINGS_FILE',
|
||||
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
|
||||
if os.path.exists(local_settings_file):
|
||||
execfile(local_settings_file)
|
||||
exec(open(local_settings_file).read())
|
||||
|
|
Loading…
Reference in New Issue