mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-17 21:56:07 -04:00
Adding log information to events
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import os
|
||||
import languageHandler
|
||||
import logging
|
||||
log = logging.getLogger("mysc.localization")
|
||||
|
||||
def get(rootFolder):
|
||||
log.debug("Getting documentation folder. RootFolder: %s" % (rootFolder,))
|
||||
defaultLocale = languageHandler.curLang
|
||||
if len(defaultLocale) > 2:
|
||||
defaultLocale = defaultLocale[:2]
|
||||
log.debug("Locale: %s" % (defaultLocale,))
|
||||
if os.path.exists(rootFolder+"/"+defaultLocale):
|
||||
return defaultLocale
|
||||
else:
|
||||
log.debug("The folder does not exist, using the English folder...")
|
||||
return "en"
|
||||
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import threading
|
||||
import logging
|
||||
log = logging.getLogger("mysc.repeating_timer")
|
||||
|
||||
class RepeatingTimer(threading.Thread):
|
||||
"""Call a function after a specified number of seconds, it will then repeat again after the specified number of seconds
|
||||
@@ -20,6 +22,7 @@ class RepeatingTimer(threading.Thread):
|
||||
|
||||
def cancel(self):
|
||||
"""Stop the timer if it hasn't finished yet"""
|
||||
log.debug("Stopping repeater for %s" % (self.function,))
|
||||
self.finished.set()
|
||||
stop = cancel
|
||||
|
||||
@@ -27,8 +30,7 @@ class RepeatingTimer(threading.Thread):
|
||||
while not self.finished.is_set():
|
||||
self.finished.wait(self.interval)
|
||||
if not self.finished.is_set(): #In case someone has canceled while waiting
|
||||
# try:
|
||||
self.function(*self.args, **self.kwargs)
|
||||
# except:
|
||||
# pass
|
||||
# logging.exception("Execution failed. Function: %r args: %r and kwargs: %r" % (self.function, self.args, self.kwargs))
|
||||
try:
|
||||
self.function(*self.args, **self.kwargs)
|
||||
except:
|
||||
log.exception("Execution failed. Function: %r args: %r and kwargs: %r" % (self.function, self.args, self.kwargs))
|
||||
|
@@ -12,7 +12,8 @@ def call_threaded(func, *args, **kwargs):
|
||||
func(*a, **k)
|
||||
except TwythonRateLimitError:
|
||||
pass
|
||||
# except:
|
||||
except:
|
||||
logging.exception("Thread %d with function %r, args of %r, and kwargs of %r failed to run." % (threading.current_thread().ident, func, a, k))
|
||||
# pass
|
||||
thread = threading.Thread(target=new_func, args=args, kwargs=kwargs)
|
||||
thread.daemon = True
|
||||
@@ -21,7 +22,6 @@ def call_threaded(func, *args, **kwargs):
|
||||
|
||||
def stream_threaded(func, *args, **kwargs):
|
||||
def new_func(*a, **k):
|
||||
# global session
|
||||
try:
|
||||
func(**k)
|
||||
except:
|
||||
|
Reference in New Issue
Block a user