From 1d72166490c6cf53d5617e4b5add91c870ffd685 Mon Sep 17 00:00:00 2001 From: Chaskiel Grundman Date: Thu, 11 Feb 2016 10:02:02 -0500 Subject: [PATCH] Fix pylint warnings in autograde_wrapper.py --- autodriver/autograde_wrapper.py | 41 +++++++++++++++++---------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/autodriver/autograde_wrapper.py b/autodriver/autograde_wrapper.py index 5e45fdbf..ce27a822 100644 --- a/autodriver/autograde_wrapper.py +++ b/autodriver/autograde_wrapper.py @@ -12,33 +12,34 @@ # interesting process exits class WaitLoop(object): def __init__(self, pid=None): - self.waitfor=pid - self.status=None + self.waitfor = pid + self.status = None def __call__(self): try: - (np, self.status)=os.wait() - while np is None or np != self.waitfor: - (np, self.status)=os.wait() + (nextpid, self.status) = os.wait() + while nextpid is None or nextpid != self.waitfor: + (nextpid, self.status) = os.wait() except OSError: - if np: - print("Chld process {} never exited, but no more children left".format(self.waitfor)) - self.status=-1 + if nextpid: + print("Chld process {} never exited, but no more children left". + format(self.waitfor)) + self.status = -1 def main(): - for f in os.listdir("mount"): - src=os.path.join("mount", f) - dst=os.path.join("autolab", f) + for copyfile in os.listdir("mount"): + src = os.path.join("mount", copyfile) + dst = os.path.join("autolab", copyfile) shutil.copy(src, dst) - autolabuser=pwd.getpwnam("autolab") - (r_p, w_p)=os.pipe() - pid=os.fork() + autolabuser = pwd.getpwnam("autolab") + (r_p, w_p) = os.pipe() + pid = os.fork() if pid == 0: os.close(r_p) os.setgroups([]) os.setgid(autolabuser.pw_gid) os.setuid(autolabuser.pw_uid) - args=["autodriver"] + args = ["autodriver"] args.extend(sys.argv[1:]) args.append("autolab") if w_p != 1: @@ -49,19 +50,19 @@ def main(): os.close(w_p) os.execvp(args[0], args) os.close(w_p) - waiter=WaitLoop(pid) - thr=threading.Thread(target=waiter) + waiter = WaitLoop(pid) + thr = threading.Thread(target=waiter) thr.start() - rpf=os.fdopen(r_p) + rpf = os.fdopen(r_p) shutil.copyfileobj(rpf, open("mount/feedback", "w")) #print("Copied output") rpf.close() thr.join() # if core, exit -1, else pass through code. if os.WIFSIGNALED(waiter.status): - status=-1 + status = -1 else: - status=os.WEXITSTATUS(waiter.status) + status = os.WEXITSTATUS(waiter.status) #print("Status is {}".format(status)) sys.exit(status)