aboutsummaryrefslogtreecommitdiff
path: root/voctocore/voctocore.py
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2016-09-15 22:55:36 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2016-09-15 22:55:36 +0200
commit9ffea4ad9ef0f0b23e5b4e5ebbfe5f140ecf5450 (patch)
tree54b1279870df9ce4fa828373d35d879e8ef431d7 /voctocore/voctocore.py
parent746d75dee7fb6291a900e0162345354e6eb41c13 (diff)
voctocore: pep8ify
* Indent by 4 spaces * Reformat some argument lists * Two newlines before free functions * One newline before methods * Spaces around infix operators
Diffstat (limited to 'voctocore/voctocore.py')
-rwxr-xr-xvoctocore/voctocore.py109
1 files changed, 59 insertions, 50 deletions
diff --git a/voctocore/voctocore.py b/voctocore/voctocore.py
index 1d04c4f..fd20163 100755
--- a/voctocore/voctocore.py
+++ b/voctocore/voctocore.py
@@ -1,91 +1,100 @@
#!/usr/bin/env python3
-import gi, signal, logging, sys
+import gi
+import signal
+import logging
+import sys
# import GStreamer and GLib-Helper classes
gi.require_version('Gst', '1.0')
gi.require_version('GstNet', '1.0')
from gi.repository import Gst, GstNet, GObject
+# import local classes
+from lib.args import Args
+from lib.loghandler import LogHandler
+
# check min-version
minGst = (1, 5)
minPy = (3, 0)
Gst.init([])
if Gst.version() < minGst:
- raise Exception("GStreamer version", Gst.version(), 'is too old, at least', minGst, 'is required')
+ raise Exception('GStreamer version', Gst.version(),
+ 'is too old, at least', minGst, 'is required')
if sys.version_info < minPy:
- raise Exception("Python version", sys.version_info, 'is too old, at least', minPy, 'is required')
+ raise Exception('Python version', sys.version_info,
+ 'is too old, at least', minPy, 'is required')
# init GObject & Co. before importing local classes
GObject.threads_init()
-# import local classes
-from lib.args import Args
-from lib.loghandler import LogHandler
# main class
class Voctocore(object):
- def __init__(self):
- # import local which use the config or the logging system
- # this is required, so that we can cnfigure logging, before reading the config
- from lib.pipeline import Pipeline
- from lib.controlserver import ControlServer
- self.log = logging.getLogger('Voctocore')
- self.log.debug('creating GObject-MainLoop')
- self.mainloop = GObject.MainLoop()
+ def __init__(self):
+ # import local which use the config or the logging system
+ # this is required, so that we can configure logging,
+ # before reading the config
+ from lib.pipeline import Pipeline
+ from lib.controlserver import ControlServer
+
+ self.log = logging.getLogger('Voctocore')
+ self.log.debug('creating GObject-MainLoop')
+ self.mainloop = GObject.MainLoop()
- # initialize subsystem
- self.log.debug('creating A/V-Pipeline')
- self.pipeline = Pipeline()
+ # initialize subsystem
+ self.log.debug('creating A/V-Pipeline')
+ self.pipeline = Pipeline()
- self.log.debug('creating ControlServer')
- self.controlserver = ControlServer(self.pipeline)
+ self.log.debug('creating ControlServer')
+ self.controlserver = ControlServer(self.pipeline)
- def run(self):
- self.log.info('running GObject-MainLoop')
- try:
- self.mainloop.run()
- except KeyboardInterrupt:
- self.log.info('Terminated via Ctrl-C')
+ def run(self):
+ self.log.info('running GObject-MainLoop')
+ try:
+ self.mainloop.run()
+ except KeyboardInterrupt:
+ self.log.info('Terminated via Ctrl-C')
- def quit(self):
- self.log.info('quitting GObject-MainLoop')
- self.mainloop.quit()
+ def quit(self):
+ self.log.info('quitting GObject-MainLoop')
+ self.mainloop.quit()
# run mainclass
def main():
- # configure logging
- docolor = (Args.color == 'always') or (Args.color == 'auto' and sys.stderr.isatty())
+ # configure logging
+ docolor = (Args.color == 'always') or (Args.color == 'auto' and
+ sys.stderr.isatty())
- handler = LogHandler(docolor, Args.timestamp)
- logging.root.addHandler(handler)
+ handler = LogHandler(docolor, Args.timestamp)
+ logging.root.addHandler(handler)
- if Args.verbose >= 2:
- level = logging.DEBUG
- elif Args.verbose == 1:
- level = logging.INFO
- else:
- level = logging.WARNING
+ if Args.verbose >= 2:
+ level = logging.DEBUG
+ elif Args.verbose == 1:
+ level = logging.INFO
+ else:
+ level = logging.WARNING
- logging.root.setLevel(level)
+ logging.root.setLevel(level)
- # make killable by ctrl-c
- logging.debug('setting SIGINT handler')
- signal.signal(signal.SIGINT, signal.SIG_DFL)
+ # make killable by ctrl-c
+ logging.debug('setting SIGINT handler')
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
- logging.info('Python Version: %s', sys.version_info)
- logging.info('GStreamer Version: %s', Gst.version())
+ logging.info('Python Version: %s', sys.version_info)
+ logging.info('GStreamer Version: %s', Gst.version())
- # init main-class and main-loop
- logging.debug('initializing Voctocore')
- voctocore = Voctocore()
+ # init main-class and main-loop
+ logging.debug('initializing Voctocore')
+ voctocore = Voctocore()
- logging.debug('running Voctocore')
- voctocore.run()
+ logging.debug('running Voctocore')
+ voctocore.run()
if __name__ == '__main__':
- main()
+ main()