From d55cc5872503567775f0d7a7731d6f489bf2299b Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 12 Nov 2017 15:03:09 +0100 Subject: yapf -ir --- poezio/daemon.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'poezio/daemon.py') diff --git a/poezio/daemon.py b/poezio/daemon.py index 6de0ec3a..c8225a07 100755 --- a/poezio/daemon.py +++ b/poezio/daemon.py @@ -5,7 +5,6 @@ # # Poezio is free software: you can redistribute it and/or modify # it under the terms of the zlib license. See the COPYING file. - """ This file is a standalone program that reads commands on stdin and executes them (each line should be a command). @@ -29,6 +28,7 @@ from subprocess import DEVNULL log = logging.getLogger(__name__) + class Executor(threading.Thread): """ Just a class to execute commands in a thread. This way, the execution @@ -37,6 +37,7 @@ class Executor(threading.Thread): WARNING: Be careful to properly escape what is untrusted by using shlex.quote for example. """ + def __init__(self, command, remote=False): threading.Thread.__init__(self) self.command = command @@ -58,7 +59,10 @@ class Executor(threading.Thread): try: stdout = open(self.filename, self.redirection_mode) except OSError: - log.error('Could not open redirection file: %s', self.filename, exc_info=True) + log.error( + 'Could not open redirection file: %s', + self.filename, + exc_info=True) return try: subprocess.call(self.command, stdout=stdout, stderr=DEVNULL) @@ -69,6 +73,7 @@ class Executor(threading.Thread): else: log.error('Could not execute %s:', self.command, exc_info=True) + def main(): while True: line = sys.stdin.readline() @@ -78,5 +83,6 @@ def main(): e = Executor(command, remote=True) e.start() + if __name__ == '__main__': main() -- cgit v1.2.3