|
@@ -39,10 +39,9 @@ parser.add_option("-c", "--config", dest="config", help="define an\
|
|
|
alternative path to the configuration file")
|
|
|
(options, arguments) = parser.parse_args()
|
|
|
|
|
|
-
|
|
|
-
|
|
|
""" define a sighandler to properly catch signals """
|
|
|
|
|
|
+
|
|
|
def sighandler(signum, frame):
|
|
|
if signum == 2:
|
|
|
logger.info("received SIGINT, stopping daemon")
|
|
@@ -57,9 +56,9 @@ def sighandler(signum, frame):
|
|
|
sys.exit(0)
|
|
|
else:
|
|
|
logger.error("stopping daemon failed, PID file was not deleted!")
|
|
|
- sys,exit(1)
|
|
|
+ sys.exit(1)
|
|
|
sys.exit(0)
|
|
|
-
|
|
|
+
|
|
|
""" create the configuration object according to the given parameters and
|
|
|
read the file itself
|
|
|
|
|
@@ -94,7 +93,8 @@ elif config.syslog_facility == "daemon":
|
|
|
facility=logging.handlers.SysLogHandler.LOG_DAEMON)
|
|
|
console_handler = logging.StreamHandler()
|
|
|
|
|
|
-formatter = logging.Formatter("%(name)s[" +str(os.getpid()) + "]: %(message)s")
|
|
|
+formatter = logging.Formatter("%(name)s[" + str(os.getpid()) +
|
|
|
+ "]: %(message)s")
|
|
|
|
|
|
syslog_handler.setFormatter(formatter)
|
|
|
console_handler.setFormatter(formatter)
|
|
@@ -118,7 +118,7 @@ if options.daemon is True:
|
|
|
daemon.SetName("stdd", cmdline)
|
|
|
if options.user is not None and options.group is not None:
|
|
|
""" To determine the user and group id, use the passwd
|
|
|
- and group files
|
|
|
+ and group files
|
|
|
|
|
|
"""
|
|
|
passwd = open("/etc/passwd", "r")
|
|
@@ -151,6 +151,8 @@ else:
|
|
|
display.setBrightness(config.brightness_low)
|
|
|
|
|
|
"""Define the main loop"""
|
|
|
+
|
|
|
+
|
|
|
def main():
|
|
|
while True:
|
|
|
date_now = datetime.datetime.now()
|
|
@@ -159,7 +161,7 @@ def main():
|
|
|
hour = date_now.hour
|
|
|
if config.blink_colon is True:
|
|
|
logger.debug("blinking middle colon")
|
|
|
- display.setColon(date_now.second %2)
|
|
|
+ display.setColon(date_now.second % 2)
|
|
|
else:
|
|
|
display.setColon(True)
|
|
|
"""set the display brightness high or low when the point in time defined
|