From a604e18853c3be192e439889b30a372f18740230 Mon Sep 17 00:00:00 2001 From: nico Date: Sun, 22 Dec 2019 04:05:41 +0100 Subject: setup is difficult * inversed checkdate to simplify * finished setup.py + add MANIFEST file --- MANIFEST.in | 3 +++ TSGroupAssigner/__init__.py | 2 +- TSGroupAssigner/group_assign.py | 45 ++++++++++++++++++++++------------------- setup.py | 28 +++++++++++++++++-------- 4 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..4ac345f --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include README.md +include LICENCE.md +include requirements.txt \ No newline at end of file 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 """ diff --git a/setup.py b/setup.py index 3fbb8aa..2bccdd9 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ from setuptools import setup, find_packages from TSGroupAssigner import __version__ +# long readme with open("README.md", "r") as fh: long_description = fh.read() @@ -13,19 +14,30 @@ setup( author='nico wellpott', author_email='nico@magicbroccoli.de', classifiers=[ - 'Programming Language :: Python :: 3', 'Intended Audience :: System Administrators', - 'Operating System :: Unix', + 'Natural Language :: English', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - "Topic :: Communications", - "Topic :: Internet" - ], + 'Operating System :: Unix', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: Implementation :: CPython', + 'Topic :: Communications', + 'Topic :: Internet' + ], license='GPLv3', description='date based TeamSpeak Group Assigner', long_description=long_description, long_description_content_type='text/markdown', keywords='automation TeamSpeak teamspeak ts3 ts3server ts', - install_requires='ts3>=1.0.11', - packages=find_packages(exclude=("tests",)), - python_requires='>=3.6' + install_requires=[ + 'ts3>=1.0.11,<2' + ], + packages=find_packages(exclude=('tests',)), + python_requires='>=3.6', + project_urls={ + 'Source': 'https://github.com/mightyBroccoli/TSGroupAssigner', + 'Issue-Tracker': 'https://github.com/mightyBroccoli/TSGroupAssigner/issues' + } ) -- cgit v1.2.3-18-g5258