diff --git a/daemon.py b/daemon.py index 4647cd7..635923a 100644 --- a/daemon.py +++ b/daemon.py @@ -16,7 +16,7 @@ import atexit 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: def __init__(self, pid_file): diff --git a/uplink b/uplink index d052731..b5895b8 100755 --- a/uplink +++ b/uplink @@ -29,15 +29,15 @@ from uplink import Uplink # Version format: MAJOR.FEATURE.FIXES __version__ = "0.3.0-development" -# TODO.md: Implement logging -# TODO.md: Implement --no-daemon for a single run e.g. "cron mode" -# TODO.md: 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: Implement logging +# TODO: Implement --no-daemon for a single run e.g. "cron mode" +# TODO: Implement CLI output messages +# TODO: IDEA: Implement a small webserver inline to get statistics and graphs over the network? Or maybe better as a # separate daemon -# TODO.md: Make use of the args passed to the script -# TODO.md: Cleanup args and reduce to only what makes sense +# TODO: Make use of the args passed to the script +# TODO: Cleanup args and reduce to only what makes sense def parse_args(): parser = argparse.ArgumentParser( 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__": 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 try: with open(config_path, 'r') as configfile: config_data = configfile.read() _config = json.loads(config_data) 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!")) exit(1) diff --git a/uplink.py b/uplink.py index b980f39..85f2509 100644 --- a/uplink.py +++ b/uplink.py @@ -17,14 +17,14 @@ class Uplink(Daemon): @staticmethod def get_data(config, inc): 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 con = pymysql.connect(host=config["database_host"], user=config["database_user"], password=config["database_password"], database=config["database"]) 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))) exit(1) @@ -36,16 +36,16 @@ class Uplink(Daemon): try: fc = FritzStatus(address=config["uplinks"][inc]["ip"], password=config["uplinks"][inc]["password"]) 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"])) - # 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, ' \ 'source_host) VALUES (\"' + str(timestamp) + '\",\"' + str(d) + '\",\"' + str(t) + '\",\"' + \ str(config["uplinks"][inc]["ip"]) + '\",\"' + "0" + '\",\"' + "0" + '\",\"' + \ 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)) with con.cursor() as cur: cur.execute(sql) @@ -57,10 +57,10 @@ class Uplink(Daemon): else: 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)) - # 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, ' \ '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, ' \ @@ -74,7 +74,7 @@ class Uplink(Daemon): str(fc.fc.system_version) + '\",\"' + str(config["uplinks"][inc]["provider"]) + '\",\"' + status + '\",\"' + \ 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)) with con.cursor() as cur: cur.execute(sql)