Execution timestamp is now generated before thread creation, not inside the thread. Some cleanups and fixes.
This commit is contained in:
parent
5f975f90d6
commit
62c1568b4d
4 changed files with 28 additions and 24 deletions
15
bin/uplink
15
bin/uplink
|
|
@ -20,10 +20,12 @@
|
|||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# TODO: CHECK ALL ERROR HANDLING!!!
|
||||
# TODO: Refactor all logging and make it clean and consistent.
|
||||
# TODO: become more verbose in each log level and log only to error when it really
|
||||
# is an error else log to info and even add debug messages in DEBUG level.
|
||||
"""
|
||||
TODO: CHECK ALL ERROR HANDLING!!!
|
||||
TODO: Refactor all logging and make it clean and consistent.
|
||||
TODO: become more verbose in each log level and log only to error when it really
|
||||
is an error else log to info and even add debug messages in DEBUG level.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import calendar
|
||||
|
|
@ -49,7 +51,7 @@ MINOR changes are "just-in-time" changes or small enhancements which should not
|
|||
documentation.
|
||||
FIXES should never affect anything else then stability or security.
|
||||
"""
|
||||
__version__ = '0.9.0.1'
|
||||
__version__ = '0.9.1.1'
|
||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||
|
||||
logger = logging.getLogger('uplink')
|
||||
|
|
@ -192,8 +194,9 @@ def main():
|
|||
ste.start()
|
||||
|
||||
while True:
|
||||
timestamp = calendar.timegm(time.gmtime())
|
||||
for i in range(len(configuration.get_uplinks())):
|
||||
ft = Thread(target=u.fetch_data, daemon=True, args=(i,))
|
||||
ft = Thread(target=u.fetch_data, daemon=True, args=(i, timestamp,))
|
||||
ft.start()
|
||||
try:
|
||||
time.sleep(configuration.get_interval())
|
||||
|
|
|
|||
|
|
@ -18,22 +18,19 @@
|
|||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import re
|
||||
import socket
|
||||
|
||||
from logging import getLogger
|
||||
|
||||
logger = getLogger('uplink')
|
||||
|
||||
"""
|
||||
this is for environment vars which can be set dynamically at runtime. these vars are shared across
|
||||
all objects and are readable and writable by all of them. environment variables are set at runtime
|
||||
and currently not stored in the database. the goal is to minimize all of these vars but for now it
|
||||
this is for environment vars which can be set dynamically at runtime. these vars are shared across
|
||||
all objects and are readable and writable by all of them. environment variables are set at runtime
|
||||
and currently not stored in the database. the goal is to minimize all of these vars but for now it
|
||||
is nice feature to save states without saving them for runtime execution at another place.
|
||||
|
||||
this is experimental because you can set what you want but if a env key you set already exists it
|
||||
will be overwritten. But it is an easy and maybe secure way to to set runtime variables which should
|
||||
not affect the execution of uplink but may be required variables to execute to your wanted
|
||||
|
||||
this is experimental because you can set what you want but if a env key you set already exists it
|
||||
will be overwritten. But it is an easy and maybe secure way to to set runtime variables which should
|
||||
not affect the execution of uplink but may be required variables to execute to your wanted
|
||||
configuration. Core functionality must not be affected when using this class!
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,10 @@
|
|||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# TODO: Select a template engine for easy output creation. Mako preferred but need to
|
||||
# take a look at Jinja.
|
||||
"""
|
||||
TODO: Select a template engine for easy output creation. Mako preferred but need to
|
||||
take a look at Jinja.
|
||||
"""
|
||||
|
||||
import cherrypy
|
||||
import json
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@
|
|||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# TODO: Make the use of a database optional and only output to stdout and/or in a logfile (use rich
|
||||
# for colorizing the std output (https://github.com/Textualize/rich)); Output to a CSV file should
|
||||
# be optional too. Also reinvent SQLite as database backend.
|
||||
"""
|
||||
TODO: Make the use of a database optional and only output to stdout and/or in a logfile (use rich
|
||||
for colorizing the std output (https://github.com/Textualize/rich)); Output to a CSV file should
|
||||
be optional too. Also reinvent SQLite as database backend.
|
||||
"""
|
||||
|
||||
import calendar
|
||||
import socket
|
||||
|
|
@ -43,8 +45,7 @@ class Uplink(Daemon):
|
|||
self.__configuration = configuration
|
||||
self.__environment = environment
|
||||
|
||||
def fetch_data(self, i):
|
||||
timestamp = calendar.timegm(time.gmtime())
|
||||
def fetch_data(self, i, timestamp):
|
||||
local_time = time.localtime(timestamp)
|
||||
date_formatted = time.strftime('%Y-%m-%d', local_time)
|
||||
time_formatted = time.strftime('%H:%M:%S', local_time)
|
||||
|
|
@ -172,7 +173,8 @@ class Uplink(Daemon):
|
|||
stt.start()
|
||||
|
||||
while True:
|
||||
timestamp = calendar.timegm(time.gmtime())
|
||||
for i in range(len(self.__configuration.get_uplinks())):
|
||||
ut = Thread(target=self.fetch_data, daemon=True, args=(i,))
|
||||
ut = Thread(target=self.fetch_data, daemon=True, args=(i, timestamp,))
|
||||
ut.start()
|
||||
time.sleep(self.__configuration.get_interval())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue