Fix linting issues (py3)

master
Ferry Boender 4 years ago
parent 6f8557ef1d
commit 60f7a56d5a
  1. 2
      build.sla
  2. 9
      src/daemon.py
  3. 1
      src/formconfig.py
  4. 5
      src/formdefinition.py
  5. 9
      src/scriptform.py
  6. 4
      src/webapp.py
  7. 1
      src/webserver.py

@ -22,7 +22,7 @@ test () {
# Code quality linting (pylint)
cd $ROOTDIR
cd src && pylint --reports=n -dR -d star-args -d no-member *.py || true
cd src && pylint --reports=n -dR -d subprocess-popen-preexec-fn -d invalid-name -d star-args -d no-member *.py || true
cd $ROOTDIR
}

@ -15,7 +15,6 @@ class DaemonError(Exception):
"""
Default error for Daemon class.
"""
pass
class Daemon(object): # pragma: no cover
@ -97,7 +96,8 @@ class Daemon(object): # pragma: no cover
return None
try:
pid = int(file(self.pid_file, 'r').read().strip())
with open(self.pid_file, "r") as fh:
pid = int(fh.read().strip())
except ValueError:
return None
@ -137,9 +137,8 @@ class Daemon(object): # pragma: no cover
pid = os.fork()
if pid > 0:
self.log.info("PID = %s", pid)
pidfile = file(self.pid_file, 'w')
pidfile.write(str(pid))
pidfile.close()
with open(self.pid_file, "w") as fh:
fh.write(str(pid))
sys.exit(0) # End parent
atexit.register(self._cleanup)

@ -13,7 +13,6 @@ class FormConfigError(Exception):
"""
Default error for FormConfig errors
"""
pass
class FormConfig(object):

@ -10,8 +10,9 @@ import runscript
class ValidationError(Exception):
"""Default exception for Validation errors"""
pass
"""
Default exception for Validation errors
"""
class FormDefinition(object):

@ -12,7 +12,6 @@ import json
import logging
import threading
import hashlib
import socket
if hasattr(sys, 'dont_write_bytecode'):
sys.dont_write_bytecode = True
@ -68,7 +67,8 @@ class ScriptForm(object):
if 'static_dir' in config:
static_dir = config['static_dir']
if 'custom_css' in config:
custom_css = file(config['custom_css'], 'r').read()
with open(config["custom_css"], "r") as fh:
custom_css = fh.read()
if 'users' in config:
users = config['users']
for form in config['forms']:
@ -186,10 +186,11 @@ def main(): # pragma: no cover
if plain_pw != getpass.getpass('Repeat password: '):
sys.stderr.write("Passwords do not match.\n")
sys.exit(1)
sys.stdout.write(hashlib.sha256(plain_pw.encode('utf8')).hexdigest() + '\n')
sha = hashlib.sha256(plain_pw.encode('utf8')).hexdigest()
sys.stdout.write("{}\n".format(sha))
sys.exit(0)
else:
if not options.action_stop and len(args) < 1:
if not options.action_stop and not args:
parser.error("Insufficient number of arguments")
if not options.action_stop and not options.action_start:
options.action_start = True

@ -3,7 +3,6 @@ The webapp part of Scriptform, which takes care of serving requests and
handling them.
"""
import cgi
import html
import logging
import tempfile
@ -214,7 +213,8 @@ class ScriptFormWebApp(RequestHandler):
if auth_header is not None:
# Validate the username and password
auth_unpw = auth_header.split(' ', 1)[1].encode('utf-8')
username, password = base64.b64decode(auth_unpw).decode('utf-8').split(":", 1)
username, password = \
base64.b64decode(auth_unpw).decode('utf-8').split(":", 1)
pw_hash = hashlib.sha256(password.encode('utf-8')).hexdigest()
if username in form_config.users and \
pw_hash == form_config.users[username]:

@ -29,7 +29,6 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
"""
Base class for multithreaded HTTP servers.
"""
pass
class RequestHandler(BaseHTTPRequestHandler):

Loading…
Cancel
Save