Commit b249ba4a authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

pep8 changes

parent 9ba2f9b6
......@@ -65,8 +65,8 @@ urlpatterns = patterns(
name='send_activation'),
url(r'^resources/?$', 'resource_usage', {}, name='resource_usage'),
# url(r'^billing/?$', 'billing', {}, name='billing'),
# url(r'^timeline/?$', 'timeline', {}, name='timeline'),
# url(r'^billing/?$', 'billing', {}, name='billing'),
# url(r'^timeline/?$', 'timeline', {}, name='timeline'),
url(r'^projects/add/?$', 'project_add', {}, name='project_add'),
url(r'^projects/?$', 'project_list', {}, name='project_list'),
......
......@@ -31,7 +31,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.conf.urls.defaults import patterns, url
from django.conf.urls.defaults import url
urlpatterns = (
url(r'^login$', 'astakos.im.views.target.redirect.login',
......
......@@ -32,7 +32,6 @@
# or implied, of GRNET S.A.
from django.conf.urls.defaults import include, patterns
from synnefo.lib import join_urls
from astakos.im.settings import (
BASE_PATH, ACCOUNTS_PREFIX, VIEWS_PREFIX, KEYSTONE_PREFIX, WEBLOGIN_PREFIX)
from snf_django.lib.api.utils import prefix_pattern
......
......@@ -32,15 +32,14 @@
# or implied, of GRNET S.A.
from django.conf.urls.defaults import *
from django.conf import settings
from snf_django.lib.api.proxy import proxy
from snf_django.lib.api.utils import prefix_pattern
from snf_django.utils.urls import extend_with_root_redirects
from snf_django.lib.api.urls import api_patterns
from synnefo.cyclades_settings import (
BASE_URL, BASE_HOST, BASE_PATH, COMPUTE_PREFIX, VMAPI_PREFIX,
BASE_PATH, COMPUTE_PREFIX, VMAPI_PREFIX,
PLANKTON_PREFIX, HELPDESK_PREFIX, UI_PREFIX, ASTAKOS_BASE_URL,
USERDATA_PREFIX, ADMIN_PREFIX, ASTAKOS_BASE_PATH, BASE_ASTAKOS_PROXY_PATH,
USERDATA_PREFIX, ADMIN_PREFIX, BASE_ASTAKOS_PROXY_PATH,
ASTAKOS_ACCOUNTS_PREFIX, ASTAKOS_VIEWS_PREFIX, PROXY_USER_SERVICES,
cyclades_services)
......
from django.conf.urls.defaults import patterns, url
urlpatterns = patterns('',
urlpatterns = patterns(
'',
url(r'^$', 'synnefo.helpdesk.views.index', name='helpdesk-index'),
url(r'^actions/vm-suspend/(?P<vm_id>[0-9]+)$',
'synnefo.helpdesk.views.vm_suspend',
......@@ -17,4 +18,3 @@ urlpatterns = patterns('',
url(r'^(?P<search_query>.*)$', 'synnefo.helpdesk.views.account',
name='helpdesk-details'),
)
......@@ -33,9 +33,9 @@
#
from django.conf.urls.defaults import *
from django.conf import settings
import os
urlpatterns = patterns('',
urlpatterns = patterns(
'',
url(r'^$', 'synnefo.ui.views.home', name='ui_index'),
url(r'^machines/console$', 'synnefo.ui.views.machines_console',
name='ui_machines_console'),
......@@ -44,7 +44,5 @@ urlpatterns = patterns('',
)
if settings.DEBUG or settings.TEST:
urlpatterns += patterns('',
url(r'^jstests$', 'synnefo.ui.views.js_tests', name='js_tests'),)
urlpatterns += patterns(
'', url(r'^jstests$', 'synnefo.ui.views.js_tests', name='js_tests'),)
......@@ -40,13 +40,14 @@ from django.http import Http404
def index(request):
raise Http404
urlpatterns = patterns('',
urlpatterns = patterns(
'',
url(r'^$', index, name='ui_userdata'),
url(r'^keys$',
views.PublicKeyPairCollectionView.as_view('ui_keys_resource'),
name='ui_keys_collection'),
url(r'^keys/(?P<id>\d+)',
views.PublicKeyPairResourceView.as_view('ui_keys_resource'),
views.PublicKeyPairResourceView.as_view('ui_keys_resource'),
name="ui_keys_resource"),
url(r'keys/generate', views.generate_key_pair,
name="ui_generate_public_key"),
......
......@@ -35,9 +35,10 @@ from django.core import urlresolvers
from django.views.decorators import csrf
from django.conf.urls.defaults import patterns
def _patch_pattern(regex_pattern):
"""
Patch pattern callback using csrf_exempt. Enforce
Patch pattern callback using csrf_exempt. Enforce
RegexURLPattern callback to get resolved if required.
"""
if not regex_pattern._callback:
......@@ -45,7 +46,8 @@ def _patch_pattern(regex_pattern):
regex_pattern._get_callback()
regex_pattern._callback = \
csrf.csrf_exempt(regex_pattern._callback)
csrf.csrf_exempt(regex_pattern._callback)
def _patch_resolver(r):
"""
......@@ -65,9 +67,10 @@ def _patch_resolver(r):
else:
_patch_pattern(entry)
def api_patterns(*args, **kwargs):
"""
Protect all url patterns from csrf attacks.
Protect all url patterns from csrf attacks.
"""
_patterns = patterns(*args, **kwargs)
for entry in _patterns:
......
......@@ -48,15 +48,15 @@ pithos_api_patterns = api_patterns(
'pithos.api.functions',
(r'^$', 'top_demux'),
(r'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$',
'object_demux'),
'object_demux'),
(r'^(?P<v_account>.+?)/(?P<v_container>.+?)/?$',
'container_demux'),
'container_demux'),
(r'^(?P<v_account>.+?)/?$', 'account_demux'))
pithos_view_patterns = patterns(
'pithos.api.views',
(r'^view/(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$',
'object_read'))
'object_read'))
pithos_patterns = patterns(
'',
......
......@@ -40,15 +40,18 @@ from synnefo_stats.stats_settings import BASE_PATH
from synnefo_stats.grapher import grapher
graph_types_re = '((cpu|net)-(bar|(ts(-w)?)))'
stats_v1_patterns = patterns('',
stats_v1_patterns = patterns(
'',
(r'^(?P<graph_type>%s)/(?P<hostname>[^ /]+)$' % graph_types_re, grapher),
)
stats_patterns = patterns('',
stats_patterns = patterns(
'',
(r'^v1.0/', include(stats_v1_patterns)),
(r'^.*', api_endpoint_not_found),
)
urlpatterns = patterns('',
urlpatterns = patterns(
'',
(prefix_pattern(BASE_PATH), include(stats_patterns)),
)
......@@ -49,12 +49,12 @@ The extended class provides the following:
"""
from django.core.management import ManagementUtility, setup_environ, \
BaseCommand, LaxOptionParser, handle_default_options, find_commands, \
load_command_class
BaseCommand, LaxOptionParser, handle_default_options, find_commands, \
load_command_class
from django.core import management
from django.utils.importlib import import_module
from optparse import Option, make_option
from optparse import make_option
from synnefo.util.version import get_component_version
from synnefo.lib.dictconfig import dictConfig
......@@ -90,9 +90,9 @@ def find_modules(name, path=None):
except ImportError:
if sys.modules.get(name, None):
modpath = sys.modules[name].__path__
if (isinstance(modpath, basestring)
and not ('', modpath) in results):
results.append(('', sys.modules[name].__path__))
if isinstance(modpath, basestring) \
and not ('', modpath) in results:
results.append(('', sys.modules[name].__path__))
else:
for mp in modpath:
if not ('', mp) in results:
......@@ -164,8 +164,8 @@ def get_commands():
"""
global _commands
if _commands is None:
_commands = dict([(name, 'django.core') for name in \
find_commands(management.__path__[0])])
_commands = dict([(name, 'django.core') for name in
find_commands(management.__path__[0])])
# Find the installed apps
try:
......@@ -222,7 +222,8 @@ class SynnefoManagementUtility(ManagementUtility):
# --settings-dir option
# will remove it later to avoid django commands from raising errors
option_list = BaseCommand.option_list + (
make_option('--settings-dir',
make_option(
'--settings-dir',
action='store',
dest='settings_dir',
default=None,
......@@ -344,8 +345,8 @@ class EncodedStdOut(object):
def main():
# no need to run setup_environ
# we already know our project
os.environ['DJANGO_SETTINGS_MODULE'] = os.environ.get('DJANGO_SETTINGS_MODULE',
'synnefo.settings')
os.environ['DJANGO_SETTINGS_MODULE'] = \
os.environ.get('DJANGO_SETTINGS_MODULE', 'synnefo.settings')
configure_logging()
mu = SynnefoManagementUtility(sys.argv)
mu.execute()
......
......@@ -8,8 +8,8 @@ DATABASES = {
# 'sqlite3' or 'oracle'
'ENGINE': 'sqlite3',
# ATTENTION: This *must* be the absolute path if using sqlite3.
# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
# ATTENTION: This *must* be the absolute path if using sqlite3.
# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
'NAME': '/usr/share/synnefo/synnefo_database.sqlite',
'USER': '', # Not used with sqlite3.
......@@ -29,4 +29,3 @@ DATABASES = {
#}
}
}
......@@ -47,7 +47,8 @@ if ROOT_REDIRECT:
urlpatterns += patterns('django.views.generic.simple',
url(r'^$', 'redirect_to', {'url': ROOT_REDIRECT}))
urlpatterns += patterns('',
urlpatterns += patterns(
'',
(r'^lang/$', 'synnefo.webproject.i18n.set_language')
)
......@@ -70,32 +71,40 @@ if getattr(settings, 'WEBPROJECT_SERVE_STATIC', settings.DEBUG):
urlns = ns
url_r = r'^%s%s/(?P<path>.*)$' % (settings.MEDIA_URL.lstrip("/"),
urlns)
urlpatterns += patterns('', url(url_r,
'django.views.static.serve',
{'document_root': static_root,
'show_indexes': getattr(settings,
'WEBPROJECT_STATIC_SHOW_INDEXES', True)}))
urlpatterns += patterns(
'', url(url_r,
'django.views.static.serve',
{'document_root': static_root,
'show_indexes': getattr(
settings, 'WEBPROJECT_STATIC_SHOW_INDEXES', True)
}))
else:
# app contains static files in <appname>/static/<appname>
for fpath in os.listdir(static_root):
urlns = ns + fpath
url_r = r'^%s%s/(?P<path>.*)$' % (settings.MEDIA_URL.lstrip("/"), urlns)
url_r = r'^%s%s/(?P<path>.*)$' % \
(settings.MEDIA_URL.lstrip("/"), urlns)
static_root = os.path.join(static_root, urlns)
urlpatterns += patterns('', url(url_r,
'django.views.static.serve',
{'document_root': static_root,
'show_indexes': getattr(settings,
'WEBPROJECT_STATIC_SHOW_INDEXES', True)}))
urlpatterns += patterns(
'', url(url_r,
'django.views.static.serve',
{'document_root': static_root,
'show_indexes': getattr(
settings,
'WEBPROJECT_STATIC_SHOW_INDEXES', True)
}))
# also serve the media root after all explicitly defined paths
# to be able to serve uploaded files
urlpatterns += patterns('', url(r'^%s(?P<path>.*)$' % \
settings.MEDIA_URL.lstrip("/"),
'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT,
'show_indexes': getattr(settings,
'WEBPROJECT_STATIC_SHOW_INDEXES', True)}))
urlpatterns += patterns(
'', url(r'^%s(?P<path>.*)$' %
settings.MEDIA_URL.lstrip("/"),
'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT,
'show_indexes': getattr(
settings, 'WEBPROJECT_STATIC_SHOW_INDEXES', True)
}))
urlpatterns = extend_urls(urlpatterns, 'synnefo')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment