Permalink
Browse files

PEP8 cleanup

  • Loading branch information...
1 parent 49e49af commit 001a28c786046620d83089fa6c5b68cb56af87f1 @william-gr william-gr committed Jun 28, 2013
Showing with 59 additions and 39 deletions.
  1. +59 −39 gui/system/views.py
View
@@ -69,11 +69,13 @@ def _system_info(request=None):
platform = subprocess.check_output(['sysctl', '-n', 'hw.model'])
physmem = str(int(int(
subprocess.check_output(['sysctl', '-n', 'hw.physmem'])
- ) / 1048576)) + 'MB'
+ ) / 1048576)) + 'MB'
# All this for a timezone, because time.asctime() doesn't add it in.
date = time.strftime('%a %b %d %H:%M:%S %Z %Y') + '\n'
- uptime = subprocess.check_output("env -u TZ uptime | "
- "awk -F', load averages:' '{ print $1 }'", shell=True)
+ uptime = subprocess.check_output(
+ "env -u TZ uptime | awk -F', load averages:' '{ print $1 }'",
+ shell=True
+ )
loadavg = "%.2f, %.2f, %.2f" % os.getloadavg()
freenas_build = "Unrecognized build (%s missing?)" % VERSION_FILE
@@ -132,7 +134,7 @@ def config_upload(request):
form._errors['__all__'] = \
form.error_class([
_('The uploaded file is not valid.'),
- ])
+ ])
else:
request.session['allow_reboot'] = True
return render(request, 'system/config_ok.html', variables)
@@ -240,9 +242,11 @@ def top(request):
def reboot_dialog(request):
if request.method == "POST":
request.session['allow_reboot'] = True
- return JsonResp(request,
- message=_("Reboot is being issued"),
- events=['window.location="%s"' % reverse('system_reboot')])
+ return JsonResp(
+ request,
+ message=_("Reboot is being issued"),
+ events=['window.location="%s"' % reverse('system_reboot')]
+ )
return render(request, 'system/reboot_dialog.html')
@@ -265,7 +269,8 @@ def reboot_run(request):
def shutdown_dialog(request):
if request.method == "POST":
request.session['allow_shutdown'] = True
- return JsonResp(request,
+ return JsonResp(
+ request,
message=_("Shutdown is being issued"),
events=['window.location="%s"' % reverse('system_shutdown')])
return render(request, 'system/shutdown_dialog.html')
@@ -299,11 +304,13 @@ def testmail(request):
email = bsdUsers.objects.get(bsdusr_username='root').bsdusr_email
if not email:
- return JsonResp(request,
+ return JsonResp(
+ request,
error=True,
- message=_("You must configure the root email"
- " (Accounts->Users->root)"),
- )
+ message=_(
+ "You must configure the root email (Accounts->Users->root)"
+ ),
+ )
sid = transaction.savepoint()
form.save()
@@ -329,15 +336,16 @@ def clearcache(request):
error = False
errmsg = ''
- os.system("(/usr/local/bin/python "
+ os.system(
+ "(/usr/local/bin/python "
"/usr/local/www/freenasUI/tools/cachetool.py expire >/dev/null 2>&1 &&"
" /usr/local/bin/python /usr/local/www/freenasUI/tools/cachetool.py "
"fill >/dev/null 2>&1) &")
return HttpResponse(simplejson.dumps({
'error': error,
'errmsg': errmsg,
- }))
+ }))
class DojoFileStore(object):
@@ -346,9 +354,12 @@ def __init__(self, path, dirsonly=False, root="/", filterVolumes=True):
self.root = os.path.abspath(str(root))
self.filterVolumes = filterVolumes
if self.filterVolumes:
- self.mp = [os.path.abspath(mp.mp_path.encode('utf8')) \
+ self.mp = [
+ os.path.abspath(mp.mp_path.encode('utf8'))
for mp in MountPoint.objects.filter(
- mp_volume__vol_fstype__in=('ZFS', 'UFS'))]
+ mp_volume__vol_fstype__in=('ZFS', 'UFS')
+ )
+ ]
self.path = os.path.join(self.root, path.replace("..", ""))
self.path = os.path.abspath(self.path)
@@ -382,10 +393,13 @@ def children(self, entry):
continue
full_path = os.path.join(self.path, _entry)
if self.filterVolumes and len(
- [f for f in self.mp \
- if full_path.startswith(f + '/') or full_path == f or \
- full_path.startswith('/mnt')]
- ) > 0:
+ [
+ f for f in self.mp if (
+ full_path.startswith(f + '/') or full_path == f or
+ full_path.startswith('/mnt')
+ )
+ ]
+ ) > 0:
_children.append(self._item(self.path, _entry))
if self.dirsonly:
_children = [child for child in _children if child['directory']]
@@ -407,16 +421,15 @@ def _item(self, path, entry):
'name': os.path.basename(full_path),
'directory': isdir,
'path': path,
- }
+ }
if isdir:
item['children'] = True
item['$ref'] = os.path.abspath(
reverse(self._lookupurl, kwargs={
'path': path + '?root=' + urllib.quote_plus(self.root),
- }
- )
- )
+ })
+ )
item['id'] = item['$ref']
return item
@@ -426,10 +439,11 @@ def directory_browser(request, path='/'):
#if not path.startswith('/'):
# path = '/%s' % path
- directories = DojoFileStore(path,
+ directories = DojoFileStore(
+ path,
dirsonly=True,
root=request.GET.get("root", "/"),
- ).items()
+ ).items()
context = directories
content = simplejson.dumps(context)
return HttpResponse(content, mimetype='application/json')
@@ -440,10 +454,11 @@ def file_browser(request, path='/'):
#if not path.startswith('/'):
# path = '/%s' % path
- directories = DojoFileStore(path,
+ directories = DojoFileStore(
+ path,
dirsonly=False,
root=request.GET.get("root", "/"),
- ).items()
+ ).items()
context = directories
content = simplejson.dumps(context)
return HttpResponse(content, mimetype='application/json')
@@ -454,39 +469,39 @@ def smarttests(request):
return render(request, "system/smarttest.html", {
'smarttests': tests,
'model': models.SMARTTest,
- })
+ })
def rsyncs(request):
syncs = models.Rsync.objects.all().order_by('id')
return render(request, 'system/rsync.html', {
'rsyncs': syncs,
'model': models.Rsync,
- })
+ })
def sysctls(request):
sysctls = models.Sysctl.objects.all().order_by('id')
return render(request, 'system/sysctl.html', {
'sysctls': sysctls,
'model': models.Sysctl,
- })
+ })
def tunables(request):
tunables = models.Tunable.objects.all().order_by('id')
return render(request, 'system/tunable.html', {
'tunables': tunables,
'model': models.Tunable,
- })
+ })
def ntpservers(request):
ntpservers = models.NTPServer.objects.all().order_by('id')
return render(request, 'system/ntpserver.html', {
'ntpservers': ntpservers,
'model': models.NTPServer,
- })
+ })
def restart_httpd(request):
@@ -531,7 +546,7 @@ def debug_save(request):
'attachment; filename=debug-%s-%s.txt' % (
hostname.encode('utf-8'),
time.strftime('%Y%m%d%H%M%S'),
- )
+ )
return response
@@ -584,15 +599,19 @@ def __init__(self, addr):
def __request(self, methodname, params):
# call a method on the remote server
- request = xmlrpclib.dumps(params, methodname, encoding=self.__encoding,
- allow_none=self.__allow_none)
+ request = xmlrpclib.dumps(
+ params,
+ methodname,
+ encoding=self.__encoding,
+ allow_none=self.__allow_none,
+ )
response = self.__transport.request(
self.__host,
self.__handler,
request,
verbose=self.__verbose
- )
+ )
if len(response) == 1:
response = response[0]
@@ -625,9 +644,10 @@ def terminal(request):
try:
if alive:
if k:
- multiplex.proc_write(sid,
+ multiplex.proc_write(
+ sid,
xmlrpclib.Binary(bytearray(k.encode('utf-8')))
- )
+ )
time.sleep(0.002)
content_data = '<?xml version="1.0" encoding="UTF-8"?>' + \
multiplex.proc_dump(sid)

0 comments on commit 001a28c

Please sign in to comment.