Flake8 compliance.

pull/7/head
Ferry Boender 10 years ago
parent efbffea672
commit 0ebdcc87f9
  1. 31
      src/scriptform.py

@ -17,7 +17,6 @@ import BaseHTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler
from SocketServer import ThreadingMixIn
import cgi
import re
import datetime
import subprocess
import base64
@ -179,7 +178,6 @@ class ScriptForm:
path = self.config_file
config = json.load(file(path, 'r'))
title = config['title']
forms = []
callbacks = self.callbacks
users = None
@ -231,6 +229,7 @@ class ScriptForm:
# same thread.
raise SystemExit()
class FormConfig:
"""
FormConfig is the in-memory representation of a form configuration JSON
@ -315,7 +314,7 @@ class FormConfig:
else:
# Raw output
pass
except Exception,e :
except Exception, e:
return {
'stdout': '',
'stderr': str(e),
@ -533,7 +532,7 @@ class WebAppHandler(BaseHTTPRequestHandler):
qs = urlparse.parse_qs(url_comp.query)
# Only return the first value of each query var. E.g. for
# "?foo=1&foo=2" return '1'.
vars = dict( [(k, v[0]) for k, v in qs.items()] )
vars = dict([(k, v[0]) for k, v in qs.items()])
return (path.strip('/'), vars)
def _call(self, path, params):
@ -562,7 +561,7 @@ class WebAppHandler(BaseHTTPRequestHandler):
self.send_error(404, "Not found")
return
method_cb(**params)
except Exception, e:
except Exception:
self.send_error(500, "Internal server error")
raise
@ -678,7 +677,7 @@ class ScriptFormWebApp(WebAppHandler):
required = ''
if field.get('required', None):
required='required'
required = 'required'
if field['type'] == 'string':
input = tpl.format(required, field['name'])
@ -711,10 +710,7 @@ class ScriptFormWebApp(WebAppHandler):
cols
)
elif field['type'] == 'select':
options = ''.join([
tpl.format(o[0], o[1]) for o in field['options']
]
)
options = ''.join([tpl.format(o[0], o[1]) for o in field['options']])
input = '<select {0} name="{1}">{2}</select>'.format(required, field['name'], options)
else:
raise ValueError("Unsupported field type: {0}".format(
@ -726,12 +722,9 @@ class ScriptFormWebApp(WebAppHandler):
<p class="form-field-title">{title}</p>
<p class="form-field-input">{input} <span class="error">{errors}</span></p>
</li>
'''.format(
title=field['title'],
'''.format(title=field['title'],
input=input,
errors=', '.join(errors)
)
)
errors=', '.join(errors)))
# Make sure the user is allowed to access this form.
form_def = form_config.get_form_def(form_name)
@ -995,10 +988,10 @@ if __name__ == "__main__":
parser.add_option("-g", "--generate-pw", dest="generate_pw", action="store_true", default=False, help="Generate password")
parser.add_option("-p", "--port", dest="port", action="store", type="int", default=80, help="Port to listen on")
parser.add_option("-f", "--foreground", dest="foreground", action="store_true", default=False, help="Run in foreground (debugging)")
parser.add_option( "--pid-file", dest="pid_file", action="store", default=None, help="Pid file")
parser.add_option( "--log-file", dest="log_file", action="store", default=None, help="Log file")
parser.add_option( "--start", dest="action_start", action="store_true", default=None, help="Start daemon")
parser.add_option( "--stop", dest="action_stop", action="store_true", default=None, help="Stop daemon")
parser.add_option("--pid-file", dest="pid_file", action="store", default=None, help="Pid file")
parser.add_option("--log-file", dest="log_file", action="store", default=None, help="Log file")
parser.add_option("--start", dest="action_start", action="store_true", default=None, help="Start daemon")
parser.add_option("--stop", dest="action_stop", action="store_true", default=None, help="Stop daemon")
(options, args) = parser.parse_args()

Loading…
Cancel
Save