Just typo fixes.
This commit is contained in:
parent
7bc85caba5
commit
9d200a5942
3 changed files with 18 additions and 18 deletions
|
|
@ -16,7 +16,7 @@ import atexit
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
|
|
||||||
# TODO.md: Check why pid files are not being deleted when sending the TERM signal
|
# TODO: Check why pid files are not being deleted when sending the TERM signal
|
||||||
class Daemon:
|
class Daemon:
|
||||||
|
|
||||||
def __init__(self, pid_file):
|
def __init__(self, pid_file):
|
||||||
|
|
|
||||||
18
uplink
18
uplink
|
|
@ -29,15 +29,15 @@ from uplink import Uplink
|
||||||
# Version format: MAJOR.FEATURE.FIXES
|
# Version format: MAJOR.FEATURE.FIXES
|
||||||
__version__ = "0.3.0-development"
|
__version__ = "0.3.0-development"
|
||||||
|
|
||||||
# TODO.md: Implement logging
|
# TODO: Implement logging
|
||||||
# TODO.md: Implement --no-daemon for a single run e.g. "cron mode"
|
# TODO: Implement --no-daemon for a single run e.g. "cron mode"
|
||||||
# TODO.md: Implement CLI output messages
|
# TODO: Implement CLI output messages
|
||||||
# TODO.md: IDEA: Implement a small webserver inline to get statistics and graphs over the network? Or maybe better as a
|
# TODO: IDEA: Implement a small webserver inline to get statistics and graphs over the network? Or maybe better as a
|
||||||
# separate daemon
|
# separate daemon
|
||||||
|
|
||||||
|
|
||||||
# TODO.md: Make use of the args passed to the script
|
# TODO: Make use of the args passed to the script
|
||||||
# TODO.md: Cleanup args and reduce to only what makes sense
|
# TODO: Cleanup args and reduce to only what makes sense
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="uplink is a tool to monitor the link status of AVM FRITZ!Box Cable and DSL based routers.",
|
description="uplink is a tool to monitor the link status of AVM FRITZ!Box Cable and DSL based routers.",
|
||||||
|
|
@ -97,16 +97,16 @@ def parse_args():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
# TODO.md: Read --version argument and print program version; then exit.
|
# TODO: Read --version argument and print program version; then exit.
|
||||||
|
|
||||||
# TODO.md: Cleanup config.json and only define what really is needed
|
# TODO: Cleanup config.json and only define what really is needed
|
||||||
config_path = args.config
|
config_path = args.config
|
||||||
try:
|
try:
|
||||||
with open(config_path, 'r') as configfile:
|
with open(config_path, 'r') as configfile:
|
||||||
config_data = configfile.read()
|
config_data = configfile.read()
|
||||||
_config = json.loads(config_data)
|
_config = json.loads(config_data)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
# TODO.md: Replace all lines like this with generic Python logging
|
# TODO: Replace all lines like this with generic Python logging
|
||||||
print(str("Uplink: Configuration Error!"))
|
print(str("Uplink: Configuration Error!"))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
|
||||||
16
uplink.py
16
uplink.py
|
|
@ -17,14 +17,14 @@ class Uplink(Daemon):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_data(config, inc):
|
def get_data(config, inc):
|
||||||
try:
|
try:
|
||||||
# TODO.md: Think about using a DB ORM (SQLAlchemy?) to make this program supporting different databases like
|
# TODO: Think about using a DB ORM (SQLAlchemy?) to make this program supporting different databases like
|
||||||
# sqlite and Postgres
|
# sqlite and Postgres
|
||||||
con = pymysql.connect(host=config["database_host"],
|
con = pymysql.connect(host=config["database_host"],
|
||||||
user=config["database_user"],
|
user=config["database_user"],
|
||||||
password=config["database_password"],
|
password=config["database_password"],
|
||||||
database=config["database"])
|
database=config["database"])
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
# TODO.md: Replace all lines like this with generic Python logging
|
# TODO: Replace all lines like this with generic Python logging
|
||||||
print(str("Uplink: Database connection failed: " + str(err)))
|
print(str("Uplink: Database connection failed: " + str(err)))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
@ -36,16 +36,16 @@ class Uplink(Daemon):
|
||||||
try:
|
try:
|
||||||
fc = FritzStatus(address=config["uplinks"][inc]["ip"], password=config["uplinks"][inc]["password"])
|
fc = FritzStatus(address=config["uplinks"][inc]["ip"], password=config["uplinks"][inc]["password"])
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
# TODO.md: Replace all lines like this with generic Python logging
|
# TODO: Replace all lines like this with generic Python logging
|
||||||
print(str(str(err) + " on device with ip: " + config["uplinks"][inc]["ip"]))
|
print(str(str(err) + " on device with ip: " + config["uplinks"][inc]["ip"]))
|
||||||
# TODO.md: Fix to long lines and make the SQL statement more readable
|
# TODO: Fix to long lines and make the SQL statement more readable
|
||||||
sql = 'INSERT INTO log (timestamp, date, time, internal_ip, is_linked, is_connected, provider, message, ' \
|
sql = 'INSERT INTO log (timestamp, date, time, internal_ip, is_linked, is_connected, provider, message, ' \
|
||||||
'source_host) VALUES (\"' + str(timestamp) + '\",\"' + str(d) + '\",\"' + str(t) + '\",\"' + \
|
'source_host) VALUES (\"' + str(timestamp) + '\",\"' + str(d) + '\",\"' + str(t) + '\",\"' + \
|
||||||
str(config["uplinks"][inc]["ip"]) + '\",\"' + "0" + '\",\"' + "0" + '\",\"' + \
|
str(config["uplinks"][inc]["ip"]) + '\",\"' + "0" + '\",\"' + "0" + '\",\"' + \
|
||||||
str(config["uplinks"][inc]["provider"]) + '\",\"ERROR: ' + str(err) + '\",\"' + socket.gethostname() + \
|
str(config["uplinks"][inc]["provider"]) + '\",\"ERROR: ' + str(err) + '\",\"' + socket.gethostname() + \
|
||||||
'\")'
|
'\")'
|
||||||
|
|
||||||
# TODO.md: Replace all lines like this with generic Python logging
|
# TODO: Replace all lines like this with generic Python logging
|
||||||
print(str(sql))
|
print(str(sql))
|
||||||
with con.cursor() as cur:
|
with con.cursor() as cur:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
|
|
@ -57,10 +57,10 @@ class Uplink(Daemon):
|
||||||
else:
|
else:
|
||||||
status = "DOWN"
|
status = "DOWN"
|
||||||
|
|
||||||
# TODO.md: Replace all lines like this with generic Python logging
|
# TODO: Replace all lines like this with generic Python logging
|
||||||
print(str(config["uplinks"][inc]["provider"] + " " + status))
|
print(str(config["uplinks"][inc]["provider"] + " " + status))
|
||||||
|
|
||||||
# TODO.md: Fix to long lines and make the SQL statement more readable
|
# TODO: Fix to long lines and make the SQL statement more readable
|
||||||
sql = 'INSERT INTO log (timestamp, date, time, uptime, internal_ip, external_ip, external_ipv6, is_linked, ' \
|
sql = 'INSERT INTO log (timestamp, date, time, uptime, internal_ip, external_ip, external_ipv6, is_linked, ' \
|
||||||
'is_connected, str_transmission_rate_up, str_transmission_rate_down, str_max_bit_rate_up, ' \
|
'is_connected, str_transmission_rate_up, str_transmission_rate_down, str_max_bit_rate_up, ' \
|
||||||
'str_max_bit_rate_down, str_max_linked_bit_rate_up, str_max_linked_bit_rate_down, modelname, ' \
|
'str_max_bit_rate_down, str_max_linked_bit_rate_up, str_max_linked_bit_rate_down, modelname, ' \
|
||||||
|
|
@ -74,7 +74,7 @@ class Uplink(Daemon):
|
||||||
str(fc.fc.system_version) + '\",\"' + str(config["uplinks"][inc]["provider"]) + '\",\"' + status + '\",\"' + \
|
str(fc.fc.system_version) + '\",\"' + str(config["uplinks"][inc]["provider"]) + '\",\"' + status + '\",\"' + \
|
||||||
socket.gethostname() + '\")'
|
socket.gethostname() + '\")'
|
||||||
|
|
||||||
# TODO.md: Replace all lines like this with generic Python logging
|
# TODO: Replace all lines like this with generic Python logging
|
||||||
print(str(sql))
|
print(str(sql))
|
||||||
with con.cursor() as cur:
|
with con.cursor() as cur:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue