summaryrefslogtreecommitdiff
path: root/client/diagnose.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-09-11 09:53:14 -0400
committerschneefux <schneefux+commit@schneefux.xyz>2014-09-11 09:53:14 -0400
commit6be18f4b365edcf2c38e766122992cf6621fc7af (patch)
tree3b26a7e321d4d58939434364b29509af068d28d0 /client/diagnose.py
parentbf4cc2f886c5e3096871f3b8ab050afd388d58bd (diff)
downloadjasper-client-6be18f4b365edcf2c38e766122992cf6621fc7af.tar.gz
jasper-client-6be18f4b365edcf2c38e766122992cf6621fc7af.zip
PEP8 style fixes for diagnose.py
Diffstat (limited to 'client/diagnose.py')
-rwxr-xr-xclient/diagnose.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/client/diagnose.py b/client/diagnose.py
index 935abbe..415eb6e 100755
--- a/client/diagnose.py
+++ b/client/diagnose.py
@@ -5,7 +5,9 @@ import socket
import os
from subprocess import check_output, call
+
class Diagnostics:
+
"""
Set of diagnostics to be run for determining the health of the
host running Jasper
@@ -25,15 +27,15 @@ class Diagnostics:
host = socket.gethostbyname("www.google.com")
# connect to the host -- tells us if the host is actually
# reachable
- s = socket.create_connection((host, 80), 2)
- except Exception as e:
+ socket.create_connection((host, 80), 2)
+ except Exception:
return False
else:
return True
@classmethod
def check_phonetisaurus_dictionary_file(cls):
- return os.path.isfile(os.path.join(cls.jasper_modules_path(), "phonetisaurus/g014b2b.fst"))
+ return os.path.isfile(os.path.join(cls.jasper_modules_path(), "phonetisaurus/g014b2b.fst"))
@classmethod
def check_phonetisaurus_program(cls):
@@ -41,13 +43,16 @@ class Diagnostics:
@classmethod
def info_git_revision(cls):
- return check_output(['git','rev-parse','HEAD'])
+ return check_output(['git', 'rev-parse', 'HEAD'])
+
class DiagnosticRunner:
+
"""
Performs a series of checks against the system, printing the results to the
console and also saving them to diagnostic.log
"""
+
def __init__(self, diagnostics):
self.diagnostics = diagnostics
@@ -66,17 +71,16 @@ class DiagnosticRunner:
else:
self.log("%d checks failed\n" % self.failed_checks)
-
def select_methods(self, prefix):
def is_match(method_name):
- return callable(getattr(self.diagnostics, method_name)) and re.match(r"\A" + prefix +"_", method_name)
+ return callable(getattr(self.diagnostics, method_name)) and re.match(r"\A" + prefix + "_", method_name)
return [method_name for method_name in dir(self.diagnostics) if is_match(method_name)]
def initialize_log(self):
self.output = open('diagnostic.log', 'w')
self.log("Starting jasper diagnostic\n")
- self.log(time.strftime("%c")+"\n")
+ self.log(time.strftime("%c") + "\n")
def log(self, msg):
print msg,
@@ -102,4 +106,3 @@ class DiagnosticRunner:
if __name__ == '__main__':
DiagnosticRunner(Diagnostics).run()
-