diff --git a/bin/uplink b/bin/uplink index 8d347c9..2eb5f1d 100755 --- a/bin/uplink +++ b/bin/uplink @@ -37,9 +37,9 @@ import time from uplink.configuration import Configuration from uplink.uplink import Uplink -# MAJOR_RELEASE.MAJOR CHANGES.MINOR_CHANGES.BUG_FIXES -# Related to: https://wiki.unixpeople.org/linux_kernel_version_numbering -__version__ = '0.8.2' +# According to: https://wiki.unixpeople.org/linux_kernel_version_numbering +# MAJOR_RELEASE.MAJOR_CHANGES.MINOR_CHANGES.BUG_FIXES +__version__ = '0.8.3.0' __author__ = 'Johannes Findeisen ' logger = logging.getLogger('uplink') diff --git a/uplink/configuration.py b/uplink/configuration.py index c964244..9ebebfc 100644 --- a/uplink/configuration.py +++ b/uplink/configuration.py @@ -35,6 +35,7 @@ class Configuration: self.__database_host = None self.__database_name = None self.__database_password = None + self.__database_port = 3306 self.__database_user = None # environment vars which can be set dynamically at runtime. these vars are shared across all # objects and readable and writable by all of them. @@ -73,6 +74,9 @@ class Configuration: else: raise Exception('database_password required!') + if 'database_port' in self.__configuration: + self.__database_port = self.__configuration['database_port'] + if 'database_user' in self.__configuration: self.__database_user = self.__configuration['database_user'] else: @@ -163,9 +167,6 @@ class Configuration: raise Exception('uplinks required!') # get methods - def get_base_configuration(self): - return self - def get_database_host(self): return self.__database_host @@ -175,6 +176,9 @@ class Configuration: def get_database_password(self): return self.__database_password + def get_database_port(self): + return self.__database_port + def get_database_user(self): return self.__database_user diff --git a/uplink/database.py b/uplink/database.py index c26e802..ef27211 100644 --- a/uplink/database.py +++ b/uplink/database.py @@ -33,9 +33,10 @@ class Database: def write_log_to_db(self, model): try: con = pymysql.connect(host=self.__configuration.get_database_host(), - user=self.__configuration.get_database_user(), + database=self.__configuration.get_database_name(), password=self.__configuration.get_database_password(), - database=self.__configuration.get_database_name()) + port=self.__configuration.get_database_port(), + user=self.__configuration.get_database_user()) sql = 'INSERT INTO log (' \ 'timestamp, ' \