Prechádzať zdrojové kódy

performed some coding style adjustments

Helmut Pozimski 10 rokov pred
rodič
commit
dca48e5aae
2 zmenil súbory, kde vykonal 12 pridanie a 9 odobranie
  1. 9 7
      stdd
  2. 3 2
      stddlib/configuration.py

+ 9 - 7
stdd

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

+ 3 - 2
stddlib/configuration.py

@@ -6,6 +6,7 @@
 
 
 import datetime
 import datetime
 
 
+
 class Conf(object):
 class Conf(object):
 	def __init__(self):
 	def __init__(self):
 		"""creates the object prepopulated with some reasonable default values"""
 		"""creates the object prepopulated with some reasonable default values"""
@@ -43,13 +44,13 @@ class Conf(object):
 					self.__tmpvalue = self.__line_stripped.split("=")
 					self.__tmpvalue = self.__line_stripped.split("=")
 					self.__values[self.__tmpvalue[0].lower()] = self.__tmpvalue[1]
 					self.__values[self.__tmpvalue[0].lower()] = self.__tmpvalue[1]
 		self.__conffile.close()
 		self.__conffile.close()
-	
+
 	def Analyze(self):
 	def Analyze(self):
 		"""takes the values from the list, converts them to the needed data types
 		"""takes the values from the list, converts them to the needed data types
 		and writes them into the prepared attributes
 		and writes them into the prepared attributes
 
 
 		"""
 		"""
-		self.hw_address = int(self.__values["hw_address"],16)
+		self.hw_address = int(self.__values["hw_address"], 16)
 		if self.__values["blink_colon"] == "1":
 		if self.__values["blink_colon"] == "1":
 			self.blink_colon = True
 			self.blink_colon = True
 		else:
 		else: