From c787e3b7752db086132d7bd9babdac21054ce6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=80=D0=BE=D0=BA=D0=B8=D0=BD=20=D0=90=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Thu, 9 Jun 2016 13:31:29 +0300 Subject: [PATCH] fixed typos, imports; pep8 --- py/Process.py | 26 ++++++++++++++------------ py/Wash.py | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/py/Process.py b/py/Process.py index 82f415b..cc891a1 100644 --- a/py/Process.py +++ b/py/Process.py @@ -1,10 +1,11 @@ #!/usr/bin/python -from Configuration import Configuration -from Color import Color - -from subprocess import Popen, call, PIPE import time +from subprocess import Popen, PIPE + +from Color import Color +from Configuration import Configuration + class Process(object): ''' Represents a running/ran process ''' @@ -15,7 +16,7 @@ class Process(object): return open('/dev/null', 'w') @staticmethod - def call(command, cwd=None,shell=False): + def call(command, cwd=None, shell=False): ''' Calls a command (either string or list of args). Returns tuple: @@ -48,7 +49,7 @@ class Process(object): stdout = p.stdout().strip() stderr = p.stderr().strip() - if stdout == '' and err == '': + if stdout == '' and stderr == '': return False return True @@ -130,7 +131,7 @@ class Process(object): pid = self.pid.pid kill(pid, SIGINT) - wait_time = 0 # Time since Interrupt was sent + wait_time = 0 # Time since Interrupt was sent while self.pid.poll() == None: # Process is still running wait_time += 0.1 @@ -141,26 +142,27 @@ class Process(object): kill(pid, SIGTERM) self.pid.terminate() break - + except OSError, e: if 'No such process' in e.__str__(): return raise e # process cannot be killed + if __name__ == '__main__': p = Process('ls') print p.stdout(), p.stderr() p.interrupt() # Calling as list of arguments - (out,err) = Process.call(['ls', '-lah']) - print out,err + (out, err) = Process.call(['ls', '-lah']) + print out, err print '\n---------------------\n' # Calling as string - (out,err) = Process.call('ls -l | head -2') - print out,err + (out, err) = Process.call('ls -l | head -2') + print out, err print '"reaver" exists:', Process.exists('reaver') diff --git a/py/Wash.py b/py/Wash.py index a01818e..6369e26 100644 --- a/py/Wash.py +++ b/py/Wash.py @@ -23,7 +23,7 @@ class Wash(object): wash_name = 'wash' if not Process.exists(wash_name): wash_name = 'walsh' - if not Proces.exists(wash_name): + if not Process.exists(wash_name): # Wash isn't found, drop out return