aboutsummaryrefslogtreecommitdiffstats
path: root/TSGroupAssigner
diff options
context:
space:
mode:
authornico <nico@magicbroccoli.de>2019-12-22 04:05:41 +0100
committernico <nico@magicbroccoli.de>2019-12-22 04:05:41 +0100
commita604e18853c3be192e439889b30a372f18740230 (patch)
tree97bd66b5c215bc81e4f2e3bd0d475367cd9ab312 /TSGroupAssigner
parent43a03eaf920c1371d033feaf6679771b6c3016a5 (diff)
setup is difficult
* inversed checkdate to simplify * finished setup.py + add MANIFEST file
Diffstat (limited to 'TSGroupAssigner')
-rw-r--r--TSGroupAssigner/__init__.py2
-rw-r--r--TSGroupAssigner/group_assign.py45
2 files changed, 25 insertions, 22 deletions
diff --git a/TSGroupAssigner/__init__.py b/TSGroupAssigner/__init__.py
index e434073..6feef67 100644
--- a/TSGroupAssigner/__init__.py
+++ b/TSGroupAssigner/__init__.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# version
-__version__ = "0.0.1"
+__version__ = "0.1"
# modules
from .group_assign import GroupAssigner
diff --git a/TSGroupAssigner/group_assign.py b/TSGroupAssigner/group_assign.py
index c3ae371..c39711d 100644
--- a/TSGroupAssigner/group_assign.py
+++ b/TSGroupAssigner/group_assign.py
@@ -21,16 +21,18 @@ class GroupAssigner:
self.port = port
self.user = user
self.pw = password
- self.sid = sid
- # group
+ # server and group id
+ self.sid = sid
self.gid = gid
# start date and delta
self.sleepstart = date - dt.timedelta(days=1)
self.startdate = date
self.enddate = date + delta
- self.delta = delta
+
+ # init connection handler
+ self.conn = None
def __connect(self):
""" establish query connection and return connection handler """
@@ -54,9 +56,9 @@ class GroupAssigner:
pass
# broad exception if something unexpected happens
- except ts3.TS3Error as TS3Error:
+ except ts3.TS3Error as err:
# log exception
- logging.error(TS3Error)
+ logging.error(err)
# exit
sys.exit()
@@ -65,15 +67,15 @@ class GroupAssigner:
""" method to check if the current date is still in the configured date range """
now = dt.date.today()
- # check if target date is in the configured range
- if self.startdate <= now <= self.enddate:
- logging.debug('target date within configured date range')
- return True
-
+ # check if still in the configured range
+ if not self.startdate <= now <= self.enddate:
# if date range is exceeded shutdown gracefully
logging.info('the current date exceeds the configured date range -- exiting')
self.__disconnect()
+ # else continue
+ logging.debug('heartbeat - target date within configured date range')
+
def __start_sleepstart(self):
""" method to check if the process is eligible to sleepstart """
now = dt.date.today()
@@ -144,19 +146,20 @@ class GroupAssigner:
self.__start_sleepstart()
# proceed only if target date is inside the date range
- if self.__checkdate():
- try:
- # init connection
- self.__connect()
+ self.__checkdate()
+
+ try:
+ # init connection
+ self.__connect()
- # break if credentials are invalid
- except ts3.query.TS3QueryError as err:
- # log error
- logging.error(err)
- self.__disconnect()
+ # break if credentials are invalid
+ except ts3.query.TS3QueryError as err:
+ # log error
+ logging.error(err)
+ self.__disconnect()
- # start processing
- self.__main()
+ # start processing
+ self.__main()
def __main(self):
""" bots main loop """