Răsfoiți Sursa

add dh-python as build dependency, change configuration file format to json

Helmut Pozimski 8 ani în urmă
părinte
comite
e79600a074
9 a modificat fișierele cu 34 adăugiri și 34 ștergeri
  1. 1 0
      Changelog
  2. 0 1
      TODO
  3. 7 0
      debian/changelog
  4. 1 1
      debian/control
  5. 1 1
      debian/stdd.init
  6. 1 0
      debian/stdd.install
  7. 12 12
      doc/stdd.1
  8. 2 2
      setup.py
  9. 9 17
      stddlib/configuration.py

+ 1 - 0
Changelog

@@ -2,6 +2,7 @@
 
 
     changed the init script to create a separate directory for the PID file
     changed the init script to create a separate directory for the PID file
     create the PID file in the separate directory and rename it to stdd.pid
     create the PID file in the separate directory and rename it to stdd.pid
+    changed the main configuration file to json format
 
 
 2014-07-12  Helmut Pozimski  <helmut@pozimski.eu>
 2014-07-12  Helmut Pozimski  <helmut@pozimski.eu>
 
 

+ 0 - 1
TODO

@@ -1,4 +1,3 @@
 * Add stdd.postrm?
 * Add stdd.postrm?
 * Check code with pylint and improve it
 * Check code with pylint and improve it
 * Make code pep8 clean
 * Make code pep8 clean
-* Change configuration file to json

+ 7 - 0
debian/changelog

@@ -1,3 +1,10 @@
+stdd (0.9.4-1) unstable; urgency=low
+
+  * New upstream release
+  * Add dh-python as build dependency
+
+ -- Helmut Pozimski <helmut@pozimski.eu>  Sun, 02 Aug 2015 12:44:00 +0200
+
 stdd (0.9.3-1) unstable; urgency=low
 stdd (0.9.3-1) unstable; urgency=low
 
 
   * New upstream release
   * New upstream release

+ 1 - 1
debian/control

@@ -4,7 +4,7 @@ Maintainer: Helmut Pozimski <helmut@pozimski.eu>
 Homepage: https://dev.intranet.helmut-pozimski.de/stdd
 Homepage: https://dev.intranet.helmut-pozimski.de/stdd
 Section: python
 Section: python
 Priority: optional
 Priority: optional
-Build-Depends: python (>= 2.6), debhelper (>= 9)
+Build-Depends: python (>= 2.6), debhelper (>= 9), dh-python
 Standards-Version: 3.9.6
 Standards-Version: 3.9.6
 
 
 Package: stdd
 Package: stdd

+ 1 - 1
debian/stdd.init

@@ -22,7 +22,7 @@ DAEMON=/usr/bin/$NAME
 # Read configuration variable file if it is present
 # Read configuration variable file if it is present
 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
 
-DAEMON_ARGS="-d -c /etc/stdd.conf -u $STDD_USER -g $STDD_GROUP"
+DAEMON_ARGS="-d -c /etc/stdd.json -u $STDD_USER -g $STDD_GROUP"
 SCRIPTNAME=/etc/init.d/$NAME
 SCRIPTNAME=/etc/init.d/$NAME
 
 
 if [ -d /run ]; then
 if [ -d /run ]; then

+ 1 - 0
debian/stdd.install

@@ -1 +1,2 @@
 default/stdd /etc/default/
 default/stdd /etc/default/
+config/stdd.json /etc/

+ 12 - 12
doc/stdd.1

@@ -37,32 +37,32 @@ define the path to your stdd configuration file. This is usually needed to start
 print version information and exit.
 print version information and exit.
 .SH EXAMPLES
 .SH EXAMPLES
 .TP
 .TP
-.B stdd -c /etc/stdd.conf
+.B stdd -c /etc/stdd.json
 minimal example using the default configuration file
 minimal example using the default configuration file
 .TP
 .TP
-.B stdd -c /etc/stdd.conf -u i2cuser -g i2c -d
+.B stdd -c /etc/stdd.json -u i2cuser -g i2c -d
 start with the privileges of user i2cuser, group i2c and run as daemon
 start with the privileges of user i2cuser, group i2c and run as daemon
 .SH CONFIGURATION
 .SH CONFIGURATION
-The following options can and should be set in the configuration file:
+The configuration file is in json format and usually found in /etc/stdd.json. The following options can and should be set in the configuration file:
 .P
 .P
-HW_ADDRESS:	hardware address for your display, a common value is "0x70" use i2cdetect to find yours if it doesn't match
+hw_address:	hardware address for your display, a common value is "0x70" use i2cdetect to find yours if it doesn't match
 .P
 .P
-BLINK_COLON:	define if you want the middle colon to blink, 0 = off, 1 = on
+blink_colon:	define if you want the middle colon to blink, false = off, true = on
 .P
 .P
-BRIGHTNESS_HIGH:	value used for "high" brightness, valid values are 0-15
+brightness_high:	value used for "high" brightness, valid values are 0-15
 .P
 .P
-BRIGHTNESS_LOW:	value used for "low" brightness, valid values are 0-15
+brightness_low:	value used for "low" brightness, valid values are 0-15
 .P
 .P
-SET_BRIGHTNESS_LOW:	value used for "low" brightness, valid values are 0-15
+set_brightness_low:	time of the day to change the brightness from high to low
 .P
 .P
-SET_BRIGHTNESS_HIGH:	time of the day to change the brightness from low to high
+set_brightness_high:	time of the day to change the brightness from low to high
 .P
 .P
-SYSLOG_LEVEL:	maximum syslog level to log, stdd uses debug, info and error
+syslog_level:	maximum syslog level to log, stdd uses debug, info and error
 .P
 .P
-SYSLOG_FACILITY:	syslog facility to use for logging (default: user, can also be daemon)
+syslog_facility:	syslog facility to use for logging (default: user, can also be daemon)
 .SH FILES
 .SH FILES
 .TP
 .TP
-.B /etc/stdd.conf
+.B /etc/stdd.json
 the default path to the configuration file
 the default path to the configuration file
 .SH "SEE ALSO"
 .SH "SEE ALSO"
 .TP 
 .TP 

+ 2 - 2
setup.py

@@ -10,7 +10,7 @@ from distutils.core import setup
 
 
 setup(
 setup(
     name="stdd",
     name="stdd",
-    version="0.9.3",
+    version="0.9.4",
     author_email="helmut@pozimski.eu",
     author_email="helmut@pozimski.eu",
     description="stdd, simple time display daemon",
     description="stdd, simple time display daemon",
     long_description=("stdd is a small daemon written in python which displays"
     long_description=("stdd is a small daemon written in python which displays"
@@ -19,5 +19,5 @@ setup(
     license="3-clause BSD license",
     license="3-clause BSD license",
     packages=["adafruit_7segment", "stddlib"],
     packages=["adafruit_7segment", "stddlib"],
     scripts=["stdd"],
     scripts=["stdd"],
-    data_files=[('/etc', ['config/stdd.conf'])]
+    data_files=[('/etc', ['config/stdd.json']), ('/etc/default', ['default/stdd'])  ]
 )
 )

+ 9 - 17
stddlib/configuration.py

@@ -5,7 +5,7 @@
 # licensed under the 3-clause BSD license
 # licensed under the 3-clause BSD license
 
 
 import datetime
 import datetime
-
+import json
 
 
 class Conf(object):
 class Conf(object):
     def __init__(self):
     def __init__(self):
@@ -34,19 +34,14 @@ class Conf(object):
         self.syslog_level = ""
         self.syslog_level = ""
         self.syslog_facility = ""
         self.syslog_facility = ""
 
 
-    def Read(self, file_path="/etc/stdd.conf"):
+    def Read(self, file_path="/etc/stdd.json"):
         """reads the configuration file from the path given to the function,
         """reads the configuration file from the path given to the function,
         default to /etc/stdd.conf if empty"""
         default to /etc/stdd.conf if empty"""
         self.__conffile = open(file_path, "r")
         self.__conffile = open(file_path, "r")
-        for line in self.__conffile:
-            if "#" in line:
-                continue
-            else:
-                self.__line_stripped = line.strip()
-                if self.__line_stripped != "":
-                    self.__tmpvalue = self.__line_stripped.split("=")
-                    self.__values[self.__tmpvalue[0].lower()] =\
-                        self.__tmpvalue[1]
+        config_read = json.load(self.__conffile)
+        for value in config_read:
+            if value:
+                self.__values[value] = config_read[value]
         self.__conffile.close()
         self.__conffile.close()
 
 
     def Analyze(self):
     def Analyze(self):
@@ -55,12 +50,9 @@ class Conf(object):
 
 
         """
         """
         self.hw_address = int(self.__values["hw_address"], 16)
         self.hw_address = int(self.__values["hw_address"], 16)
-        if self.__values["blink_colon"] == "1":
-            self.blink_colon = True
-        else:
-            self.blink_colon = False
-        self.brightness_high = int(self.__values["brightness_high"])
-        self.brightness_low = int(self.__values["brightness_low"])
+        self.blink_colon = self.__values["blink_colon"]
+        self.brightness_high = self.__values["brightness_high"]
+        self.brightness_low = self.__values["brightness_low"]
         self.__timetemp = self.__values["set_brightness_high"].split(":")
         self.__timetemp = self.__values["set_brightness_high"].split(":")
         self.set_brightness_high = datetime.time(int(self.__timetemp[0]),
         self.set_brightness_high = datetime.time(int(self.__timetemp[0]),
                                                  int(self.__timetemp[1]))
                                                  int(self.__timetemp[1]))