Add from __future__ import unicode_literals, issue #37

This commit is contained in:
Roberto Rosario
2015-01-19 04:06:40 -04:00
parent efbac7300c
commit d59ea3ede2
334 changed files with 2452 additions and 2268 deletions
+5 -5
View File
@@ -1,4 +1,4 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from django.db.utils import DatabaseError
from django.dispatch import receiver
@@ -35,22 +35,22 @@ def check_first_run():
register_model_list_columns(PropertyNamespace, [
{
'name': _(u'Label'),
'name': _('Label'),
'attribute': 'label'
},
{
'name': _(u'Items'),
'name': _('Items'),
'attribute': encapsulate(lambda entry: len(entry.get_properties()))
}
])
register_model_list_columns(Property, [
{
'name': _(u'Label'),
'name': _('Label'),
'attribute': 'label'
},
{
'name': _(u'Value'),
'name': _('Value'),
'attribute': 'value'
}
])
+1 -1
View File
@@ -1,4 +1,4 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from collections import namedtuple
from json import dumps
+4 -4
View File
@@ -1,9 +1,9 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
from .permissions import PERMISSION_INSTALLATION_DETAILS
link_menu_link = {'text': _(u'Installation details'), 'view': 'installation:namespace_list', 'icon': 'interface_preferences.png', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
link_namespace_list = {'text': _(u'Installation property namespaces'), 'view': 'installation:namespace_list', 'famfam': 'layout', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
link_namespace_details = {'text': _(u'Details'), 'view': 'installation:namespace_details', 'args': 'object.id', 'famfam': 'layout_link', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
link_menu_link = {'text': _('Installation details'), 'view': 'installation:namespace_list', 'icon': 'interface_preferences.png', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
link_namespace_list = {'text': _('Installation property namespaces'), 'view': 'installation:namespace_list', 'famfam': 'layout', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
link_namespace_details = {'text': _('Details'), 'view': 'installation:namespace_details', 'args': 'object.id', 'famfam': 'layout_link', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
+2
View File
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
FORM_SUBMIT_URL = 'https://docs.google.com/spreadsheet/formResponse'
FORM_KEY = 'dGZrYkw3SDl5OENMTG15emp1UFFEUWc6MQ'
FORM_RECEIVER_FIELD = 'entry.0.single'
+46 -46
View File
@@ -1,4 +1,4 @@
from __future__ import absolute_import
from __future__ import unicode_literals
import os
import sys
@@ -49,90 +49,90 @@ class Installation(SingletonModel):
return self._properties.values()
def os_properties(self):
namespace = PropertyNamespace('os', _(u'Operating system'))
namespace = PropertyNamespace('os', _('Operating system'))
if LSB:
namespace.add_property('is_lsb', _(u'LSB OS'), True, True)
namespace.add_property('distributor_id', _(u'Distributor ID'), lsb_release('-i', '-s'), True)
namespace.add_property('description', _(u'Description'), lsb_release('-d', '-s'), True)
namespace.add_property('release', _(u'Release'), lsb_release('-r', '-s'), True)
namespace.add_property('codename', _(u'Codename'), lsb_release('-c', '-s'), True)
namespace.add_property('sysinfo', _(u'System info'), uname('-a'), True)
namespace.add_property('is_lsb', _('LSB OS'), True, True)
namespace.add_property('distributor_id', _('Distributor ID'), lsb_release('-i', '-s'), True)
namespace.add_property('description', _('Description'), lsb_release('-d', '-s'), True)
namespace.add_property('release', _('Release'), lsb_release('-r', '-s'), True)
namespace.add_property('codename', _('Codename'), lsb_release('-c', '-s'), True)
namespace.add_property('sysinfo', _('System info'), uname('-a'), True)
else:
namespace.add_property('is_lsb', _(u'LSB OS'), False)
namespace.add_property('is_lsb', _('LSB OS'), False)
namespace.add_property('architecture', _(u'OS architecture'), platform.architecture(), report=True)
namespace.add_property('python_version', _(u'Python version'), platform.python_version(), report=True)
namespace.add_property('hostname', _(u'Hostname'), platform.node())
namespace.add_property('platform', _(u'Platform'), sys.platform, report=True)
namespace.add_property('machine', _(u'Machine'), platform.machine(), report=True)
namespace.add_property('processor', _(u'Processor'), platform.processor(), report=True)
namespace.add_property('cpus', _(u'Number of CPUs'), psutil.cpu_count(), report=True)
namespace.add_property('total_phymem', _(u'Total physical memory'), pretty_size(psutil.virtual_memory().total), report=True)
namespace.add_property('disk_partitions', _(u'Disk partitions'), '; '.join(['%s %s %s %s' % (partition.device, partition.mountpoint, partition.fstype, partition.opts) for partition in psutil.disk_partitions()]))
namespace.add_property('architecture', _('OS architecture'), platform.architecture(), report=True)
namespace.add_property('python_version', _('Python version'), platform.python_version(), report=True)
namespace.add_property('hostname', _('Hostname'), platform.node())
namespace.add_property('platform', _('Platform'), sys.platform, report=True)
namespace.add_property('machine', _('Machine'), platform.machine(), report=True)
namespace.add_property('processor', _('Processor'), platform.processor(), report=True)
namespace.add_property('cpus', _('Number of CPUs'), psutil.cpu_count(), report=True)
namespace.add_property('total_phymem', _('Total physical memory'), pretty_size(psutil.virtual_memory().total), report=True)
namespace.add_property('disk_partitions', _('Disk partitions'), '; '.join(['%s %s %s %s' % (partition.device, partition.mountpoint, partition.fstype, partition.opts) for partition in psutil.disk_partitions()]))
def binary_dependencies(self):
namespace = PropertyNamespace('bins', _(u'Binary dependencies'))
namespace = PropertyNamespace('bins', _('Binary dependencies'))
try:
tesseract = sh.Command(TESSERACT_PATH)
except sh.CommandNotFound:
namespace.add_property('tesseract', _(u'tesseract version'), _(u'not found'), report=True)
namespace.add_property('tesseract', _('tesseract version'), _('not found'), report=True)
except Exception:
namespace.add_property('tesseract', _(u'tesseract version'), _(u'error getting version'), report=True)
namespace.add_property('tesseract', _('tesseract version'), _('error getting version'), report=True)
else:
namespace.add_property('tesseract', _(u'tesseract version'), tesseract('-v').stderr, report=True)
namespace.add_property('tesseract', _('tesseract version'), tesseract('-v').stderr, report=True)
try:
unpaper = sh.Command(UNPAPER_PATH)
except sh.CommandNotFound:
namespace.add_property('unpaper', _(u'unpaper version'), _(u'not found'), report=True)
namespace.add_property('unpaper', _('unpaper version'), _('not found'), report=True)
except Exception:
namespace.add_property('unpaper', _(u'unpaper version'), _(u'error getting version'), report=True)
namespace.add_property('unpaper', _('unpaper version'), _('error getting version'), report=True)
else:
namespace.add_property('unpaper', _(u'unpaper version'), unpaper('-V').stdout, report=True)
namespace.add_property('unpaper', _('unpaper version'), unpaper('-V').stdout, report=True)
try:
pdftotext = sh.Command(PDFTOTEXT_PATH)
except sh.CommandNotFound:
namespace.add_property('pdftotext', _(u'pdftotext version'), _(u'not found'), report=True)
namespace.add_property('pdftotext', _('pdftotext version'), _('not found'), report=True)
except Exception:
namespace.add_property('pdftotext', _(u'pdftotext version'), _(u'error getting version'), report=True)
namespace.add_property('pdftotext', _('pdftotext version'), _('error getting version'), report=True)
else:
namespace.add_property('pdftotext', _(u'pdftotext version'), pdftotext('-v').stderr, report=True)
namespace.add_property('pdftotext', _('pdftotext version'), pdftotext('-v').stderr, report=True)
def mayan_properties(self):
namespace = PropertyNamespace('mayan', _(u'Mayan EDMS'))
namespace = PropertyNamespace('mayan', _('Mayan EDMS'))
namespace.add_property('uuid', _(u'UUID'), self.uuid, report=True)
namespace.add_property('mayan_version', _(u'Mayan EDMS version'), mayan_version, report=True)
namespace.add_property('uuid', _('UUID'), self.uuid, report=True)
namespace.add_property('mayan_version', _('Mayan EDMS version'), mayan_version, report=True)
def git_properties(self):
namespace = PropertyNamespace('git', _(u'Git repository'))
namespace = PropertyNamespace('git', _('Git repository'))
try:
repo = Repo(os.path.abspath(os.path.join(settings.BASE_DIR, '..')))
except:
namespace.add_property('is_git_repo', _(u'Running from a Git repository'), False)
namespace.add_property('is_git_repo', _('Running from a Git repository'), False)
else:
repo.config_reader()
headcommit = repo.head.commit
namespace.add_property('is_git_repo', _(u'Running from a Git repository'), True)
namespace.add_property('repo_remotes', _(u'Repository remotes'), ', '.join([unicode(remote) for remote in repo.remotes]), report=True)
namespace.add_property('repo_remotes_urls', _(u'Repository remotes URLs'), ', '.join([unicode(remote.url) for remote in repo.remotes]), report=True)
namespace.add_property('repo_head_reference', _(u'Branch'), repo.head.reference, report=True)
namespace.add_property('headcommit_hexsha', _(u'HEAD commit hex SHA'), headcommit.hexsha, report=True)
namespace.add_property('headcommit_author', _(u'HEAD commit author'), headcommit.author)
namespace.add_property('headcommit_authored_date', _(u'HEAD commit authored date'), time.asctime(time.gmtime(headcommit.authored_date)), report=True)
namespace.add_property('headcommit_committer', _(u'HEAD commit committer'), headcommit.committer)
namespace.add_property('headcommit_committed_date', _(u'HEAD commit committed date'), time.asctime(time.gmtime(headcommit.committed_date)), report=True)
namespace.add_property('headcommit_message', _(u'HEAD commit message'), headcommit.message, report=True)
namespace.add_property('is_git_repo', _('Running from a Git repository'), True)
namespace.add_property('repo_remotes', _('Repository remotes'), ', '.join([unicode(remote) for remote in repo.remotes]), report=True)
namespace.add_property('repo_remotes_urls', _('Repository remotes URLs'), ', '.join([unicode(remote.url) for remote in repo.remotes]), report=True)
namespace.add_property('repo_head_reference', _('Branch'), repo.head.reference, report=True)
namespace.add_property('headcommit_hexsha', _('HEAD commit hex SHA'), headcommit.hexsha, report=True)
namespace.add_property('headcommit_author', _('HEAD commit author'), headcommit.author)
namespace.add_property('headcommit_authored_date', _('HEAD commit authored date'), time.asctime(time.gmtime(headcommit.authored_date)), report=True)
namespace.add_property('headcommit_committer', _('HEAD commit committer'), headcommit.committer)
namespace.add_property('headcommit_committed_date', _('HEAD commit committed date'), time.asctime(time.gmtime(headcommit.committed_date)), report=True)
namespace.add_property('headcommit_message', _('HEAD commit message'), headcommit.message, report=True)
def virtualenv_properties(self):
namespace = PropertyNamespace('venv', _(u'VirtualEnv'))
namespace = PropertyNamespace('venv', _('VirtualEnv'))
try:
venv = VirtualEnv()
except PIPNotFound:
namespace.add_property('pip', 'pip', _(u'pip not found.'), report=True)
namespace.add_property('pip', 'pip', _('pip not found.'), report=True)
else:
for item, version, result in venv.get_results():
namespace.add_property(item, '%s (%s)' % (item, version), result, report=True)
@@ -171,4 +171,4 @@ class Installation(SingletonModel):
lock.release()
class Meta:
verbose_name = verbose_name_plural = _(u'Installation details')
verbose_name = verbose_name_plural = _('Installation details')
+3 -3
View File
@@ -1,8 +1,8 @@
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
from django.utils.translation import ugettext_lazy as _
from permissions.models import PermissionNamespace, Permission
namespace = PermissionNamespace('installation', _(u'Installation'))
PERMISSION_INSTALLATION_DETAILS = Permission.objects.register(namespace, 'installation_details', _(u'View installation environment details'))
namespace = PermissionNamespace('installation', _('Installation'))
PERMISSION_INSTALLATION_DETAILS = Permission.objects.register(namespace, 'installation_details', _('View installation environment details'))
+3
View File
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
import requests
from mayan.celery import app
@@ -5,6 +7,7 @@ from mayan.celery import app
from .models import Installation
# TODO: move rate_limit to literals.py
@app.task(bind=True, ignore_result=True, max_retries=None, rate_limit='1/m')
def task_details_submit(self):
try:
+2
View File
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
from django.conf.urls import patterns, url
urlpatterns = patterns('installation.views',
+3 -3
View File
@@ -1,4 +1,4 @@
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
from django.shortcuts import render_to_response
from django.template import RequestContext
@@ -18,7 +18,7 @@ def namespace_list(request):
return render_to_response('main/generic_list.html', {
'object_list': PropertyNamespace.get_all(),
'title': _(u'Installation property namespaces'),
'title': _('Installation property namespaces'),
'hide_object': True,
}, context_instance=RequestContext(request))
@@ -30,7 +30,7 @@ def namespace_details(request, namespace_id):
namespace = PropertyNamespace.get(namespace_id)
object_list = namespace.get_properties()
title = _(u'Installation namespace details for: %s') % namespace.label
title = _('Installation namespace details for: %s') % namespace.label
return render_to_response('main/generic_list.html', {
'object_list': object_list,