misc: add python 3 compat

This commit is contained in:
Frédéric Péters 2016-07-30 09:43:38 +02:00
parent 0bcb3351fb
commit fdf04887c0
7 changed files with 13 additions and 13 deletions

2
debian/control vendored
View File

@ -9,7 +9,7 @@ X-Python-Version: >= 2.7
Package: python-scrutiny Package: python-scrutiny
Architecture: all Architecture: all
Depends: ${misc:Depends}, ${python:Depends}, Depends: ${misc:Depends}, ${python:Depends},
python-django (>= 1.7), python-django (>= 1.8),
python-gadjo python-gadjo
Recommends: python-django-mellon Recommends: python-django-mellon
Description: Tracker of installed modules Description: Tracker of installed modules

View File

@ -1,3 +1,3 @@
django >= 1.7, < 1.8 django >= 1.7, < 1.9
gadjo gadjo
requests requests

View File

@ -15,13 +15,13 @@ class Command(BaseCommand):
if not service.url.endswith('/'): if not service.url.endswith('/'):
service.url = '%s/' % service.url service.url = '%s/' % service.url
if self.verbose: if self.verbose:
print 'Checking', service.url print('Checking %s' % service.url)
try: try:
response = requests.get('%s__version__' % service.url, response = requests.get('%s__version__' % service.url,
timeout=5, verify=False) timeout=5, verify=False)
response.raise_for_status() response.raise_for_status()
except requests.RequestException as e: except requests.RequestException as e:
print 'Error with', service.url, e print('Error with %s (%r)' % (service.url, e))
continue continue
versions = response.json() versions = response.json()

View File

@ -55,7 +55,7 @@ class Service(models.Model):
uninstalled_modules.append(installed_version.version.module) uninstalled_modules.append(installed_version.version.module)
continue continue
modules[installed_version.version.module.name] = installed_version.version.module 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): def get_installed_service(self, platform):
try: try:
@ -144,7 +144,7 @@ class Module(models.Model):
p = subprocess.Popen(cmd, **kws) p = subprocess.Popen(cmd, **kws)
stdout = p.communicate()[0] stdout = p.communicate()[0]
p.wait() p.wait()
return stdout return stdout.decode('utf-8')
def get_all_installed_versions(self): def get_all_installed_versions(self):
versions = set() versions = set()

View File

@ -61,7 +61,7 @@ class ModuleIssuesView(TemplateView):
issue = issues[int(issue.id)] issue = issues[int(issue.id)]
issue.add_commit(commit) issue.add_commit(commit)
issues_list = issues.items() issues_list = list(issues.items())
issues_list.sort() issues_list.sort()
context['issues'] = [x[1] for x in issues_list] context['issues'] = [x[1] for x in issues_list]
@ -118,12 +118,12 @@ class ProjectSummaryHistoryView(DetailView):
'name': installed.version.module.name, 'name': installed.version.module.name,
'current_version': installed.version.version, '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')) versions_sorted_by_day.sort(key=lambda x: x.get('day'))
previous_versions = {} previous_versions = {}
for version_and_day in versions_sorted_by_day: 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: if module_name in previous_versions:
module_versions['previous_version'] = previous_versions[module_name] module_versions['previous_version'] = previous_versions[module_name]
if module_versions['previous_version'] == module_versions['current_version']: if module_versions['previous_version'] == module_versions['current_version']:
@ -235,7 +235,7 @@ class IssuesSnippet(TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(IssuesSnippet, self).get_context_data(**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 = {} issues = {}
for module_info in modules.values(): for module_info in modules.values():
@ -258,7 +258,7 @@ class IssuesSnippet(TemplateView):
issues[int(issue.id)].modules = {} issues[int(issue.id)].modules = {}
issues[int(issue.id)].modules[module_info['name']] = True 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'].sort(key=lambda x: x.closed_on)
context['issues'].reverse() # most recent on top context['issues'].reverse() # most recent on top
return context return context

View File

@ -100,4 +100,4 @@ REDMINE_API_KEY = None
local_settings_file = os.environ.get('SCRUTINY_SETTINGS_FILE', local_settings_file = os.environ.get('SCRUTINY_SETTINGS_FILE',
os.path.join(os.path.dirname(__file__), 'local_settings.py')) os.path.join(os.path.dirname(__file__), 'local_settings.py'))
if os.path.exists(local_settings_file): if os.path.exists(local_settings_file):
execfile(local_settings_file) exec(open(local_settings_file).read())

View File

@ -42,7 +42,7 @@ setup(name='scrutiny',
scripts=['manage.py'], scripts=['manage.py'],
include_package_data = True, include_package_data = True,
install_requires=[ install_requires=[
'django >= 1.7, < 1.8', 'django >= 1.7, < 1.9',
'requests', 'requests',
'gadjo', 'gadjo',
], ],