Lot of cleanups
This commit is contained in:
parent
7e8e3545a4
commit
05b056a30c
2 changed files with 11 additions and 9 deletions
11
uplink.py
11
uplink.py
|
|
@ -110,9 +110,9 @@ if __name__ == "__main__":
|
|||
with open(config_path, 'r') as configfile:
|
||||
config_data = configfile.read()
|
||||
config = json.loads(config_data)
|
||||
except "OSError, PermissionDenied, RuntimeError, ValueError" as err:
|
||||
except Exception as err:
|
||||
# TODO: Replace all lines like this with generic Python logging
|
||||
print(str("Uplink: Configuration Error!" + err))
|
||||
print(str("Uplink: Configuration Error!" + str(err)))
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
|
|
@ -141,8 +141,7 @@ if __name__ == "__main__":
|
|||
time.sleep(config["interval"])
|
||||
except KeyboardInterrupt as err:
|
||||
print(str("uplink: program terminated by user!"))
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
else:
|
||||
|
||||
print("uplink: error: no run mode selected; use --cron (-c), --daemon (-d) or --foreground (-f) to run uplink. "
|
||||
"use --help for more information")
|
||||
print("uplink: error: no run mode selected; use --cron (-c), --daemon (-d) or "
|
||||
"--foreground (-f) to run uplink. use --help for more information")
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@
|
|||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import pymysql
|
||||
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import calendar
|
||||
|
||||
|
|
@ -29,12 +30,14 @@ except ImportError:
|
|||
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||
|
||||
from threading import Thread
|
||||
import pymysql
|
||||
from uplink.daemon import Daemon
|
||||
|
||||
|
||||
class Uplink(Daemon):
|
||||
|
||||
def __init__(self, pid_file, config):
|
||||
super().__init__(pid_file)
|
||||
self.pid_file = pid_file
|
||||
self.config = config
|
||||
|
||||
|
|
@ -50,7 +53,7 @@ class Uplink(Daemon):
|
|||
except Exception as err:
|
||||
# TODO: Replace all lines like this with generic Python logging
|
||||
print(str("Uplink: Database connection failed: " + str(err)))
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
timestamp = calendar.timegm(time.gmtime())
|
||||
local_time = time.localtime(timestamp)
|
||||
|
|
@ -74,7 +77,7 @@ class Uplink(Daemon):
|
|||
with con.cursor() as cur:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
if fc.is_connected:
|
||||
status = "UP"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue