Added database_port to configuration and a cleanup.
This commit is contained in:
parent
384cd2071f
commit
71b118afd1
3 changed files with 13 additions and 8 deletions
|
|
@ -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 <you@hanez.org>'
|
||||
|
||||
logger = logging.getLogger('uplink')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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, ' \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue