Browse Source

Apply pep8 to visualization

Felix Schultze 9 years ago
parent
commit
f0ef2517bd

+ 0 - 1
manage.py

@@ -8,4 +8,3 @@ if __name__ == "__main__":
     from django.core.management import execute_from_command_line
 
     execute_from_command_line(sys.argv)
-

+ 2 - 1
visualization/context_processor.py

@@ -1,5 +1,6 @@
 def add_settings(request):
-    import json, os
+    import json
+    import os
     from django.conf import settings
     packageJson = json.load(open(os.path.join(settings.BASE_DIR, 'package.json'), 'r'))
     version = packageJson['version']

+ 15 - 8
visualization/memcached.py

@@ -3,23 +3,30 @@ from django.core.cache.backends.memcached import BaseMemcachedCache
 import memcache
 DEFAULT_MAX_VALUE_LENGTH = 1024 * 1024 * 15
 
+
 class MemcachedCache(BaseMemcachedCache):
     def __init__(self, server, params):
-        #options from the settings['CACHE'][connection]
         self._options = params.get("OPTIONS", {})
         memcache.SERVER_MAX_VALUE_LENGTH = self._options.get('SERVER_MAX_VALUE_LENGTH', DEFAULT_MAX_VALUE_LENGTH)
 
-        super(MemcachedCache, self).__init__(server, params,
-                                             library=memcache,
-                                             value_not_found_exception=ValueError)
+        super(MemcachedCache, self).__init__(
+            server,
+            params,
+            library=memcache,
+            value_not_found_exception=ValueError
+        )
 
     @property
     def _cache(self):
         if getattr(self, '_client', None) is None:
             server_max_value_length = memcache.SERVER_MAX_VALUE_LENGTH
-            #one could optionally send more parameters here through the options settings,
-            #I simplified here for brevity
-            self._client = self._lib.Client(self._servers,
-                server_max_value_length=server_max_value_length)
+            '''
+            one could optionally send more parameters here through the options settings,
+            I simplified here for brevity
+            '''
+            self._client = self._lib.Client(
+                self._servers,
+                server_max_value_length=server_max_value_length
+            )
 
         return self._client

+ 5 - 0
visualization/mongodb/gridfshelper.py

@@ -1,21 +1,26 @@
 from mongoengine.django.storage import GridFSStorage
 
+
 def fileexists(filename):
     fs = GridFSStorage()
     return fs.exists(filename)
 
+
 def savefile(filename, content):
     fs = GridFSStorage()
     return fs.save(filename, content)
 
+
 def openfile(filename):
     fs = GridFSStorage()
     return fs.open(filename)
 
+
 def listfiles():
     fs = GridFSStorage()
     return fs.listdir()
 
+
 def deletefile(filename):
     fs = GridFSStorage()
     return fs.delete(filename)

+ 5 - 13
visualization/settings.py

@@ -10,11 +10,11 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 import os
-import sys
-BASE_DIR = os.path.dirname(os.path.dirname(__file__))
-
 from . import settings_env
+from mongoengine import register_connection
+
 
+BASE_DIR = os.path.dirname(os.path.dirname(__file__))
 ENVIRONMENT = settings_env.ENVIRONMENT
 globalConfiguration = settings_env.globalConfiguration
 
@@ -29,13 +29,13 @@ if os.path.exists(PATH_MMAP) is False:
     os.makedirs(PATH_MMAP)
 
 
-
 PATH_FIJI = globalConfiguration['fiji-path']
 
 DEFAULT_IMPORT_PATH = globalConfiguration['default-import-path']
 
-## good value may be 676 = 26 ^ 2
+# good value may be 676 = 26 ^ 2
 MAX_NUMBER_SLICES_PER_MAP = 700.0
+
 # defaul: True
 Z_DOWNSCALING_ACTIVATED = True
 
@@ -44,8 +44,6 @@ REDUCE_HARDDISK_ACCESS_FOR_DEV = globalConfiguration['reduce-harddisk-access']
 
 MAX_NUMBER_SLICES_PER_MAP = float(MAX_NUMBER_SLICES_PER_MAP)
 
-#sys.path.append(os.environ['PYTHON_TOMOGRAPHY'])
-
 # Quick-start development settings - unsuitable for production
 # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
 
@@ -232,9 +230,6 @@ USE_L10N = True
 
 USE_TZ = True
 
-#IMAGE_PROCESSING_PATH = os.environ['DJANGO_IMAGE_PROC']
-
-
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/1.7/howto/static-files/
 STATIC_URL = globalConfiguration['static-url-prefix'] + '/static/'
@@ -249,8 +244,5 @@ SESSION_ENGINE = 'mongoengine.django.sessions'
 MONGO_DATABASE_NAME = globalConfiguration['db-name']
 MONGO_DATABASE_TESTRESULT_NAME = globalConfiguration['db-name-tests-results']
 
-from mongoengine import register_connection
 register_connection('default', MONGO_DATABASE_NAME)
 register_connection('test_results', MONGO_DATABASE_TESTRESULT_NAME)
-
-

+ 2 - 7
visualization/urls.py

@@ -1,15 +1,10 @@
 from django.conf.urls import patterns, include, url
-from django.contrib import admin
 
 from volumes import urls as volumeurls
 from loadtests import urls as loadtesturls
 
-urlpatterns = patterns('',
-    # Examples:
-    # url(r'^$', 'visualization.views.home', name='home'),
-    # url(r'^blog/', include('blog.urls')),
-
-    #url(r'^admin/', include(admin.site.urls)),
+urlpatterns = patterns(
+    '',
     url(r'^$', include(volumeurls)),
     url(r'^volumes/', include(volumeurls, namespace='volumes', app_name='volumes')),
     url(r'^loadtests/', include(loadtesturls, namespace='loadtests', app_name='loadtests'))

+ 2 - 1
visualization/wsgi.py

@@ -8,7 +8,8 @@ https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
 """
 
 import os
+from django.core.wsgi import get_wsgi_application
+
 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "visualization.settings")
 
-from django.core.wsgi import get_wsgi_application
 application = get_wsgi_application()