summaryrefslogtreecommitdiff
path: root/poezio/daemon.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2017-11-12 15:03:09 +0100
committermathieui <mathieui@mathieui.net>2017-11-12 15:03:09 +0100
commitd55cc5872503567775f0d7a7731d6f489bf2299b (patch)
tree725f9e7b8144d36054447b3c82edfb45bda8df1d /poezio/daemon.py
parent92496db823db34f7f7fb1ab31eaef093a707c3e8 (diff)
downloadpoezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.gz
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.bz2
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.xz
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.zip
yapf -ir
Diffstat (limited to 'poezio/daemon.py')
-rwxr-xr-xpoezio/daemon.py10
1 files changed, 8 insertions, 2 deletions
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()