2022-07-14 19:03:06 -05:00
|
|
|
#The third file shall contain logging and email communication.
|
|
|
|
|
|
|
|
def torlog(self):
|
2022-07-20 11:34:13 -05:00
|
|
|
"""Setting up the log file, if self.use_log is set to true and self.loglevel is DEBUG OR INFO"""
|
2022-07-20 10:19:12 -05:00
|
|
|
if self.use_log:
|
|
|
|
if self.loglevel == 'DEBUG':
|
|
|
|
self.tl.basicConfig(filename=self.logpath, format='%(asctime)s:%(levelname)s:%(message)s', encoding='utf-8', datefmt='%m/%d/%Y %I:%M:%S %p',level=self.tl.DEBUG)
|
|
|
|
elif self.loglevel == 'INFO':
|
|
|
|
self.tl.basicConfig(filename=self.logpath, format='%(asctime)s:%(levelname)s:%(message)s', encoding='utf-8', datefmt='%m/%d/%Y %I:%M:%S %p',level=self.tl.INFO)
|
2022-07-14 20:33:53 -05:00
|
|
|
|
2022-07-20 09:57:22 -05:00
|
|
|
def tornotify(self):
|
2022-07-20 11:34:13 -05:00
|
|
|
"""Seting up to use pushover, if self.use_pushover is set to true and
|
|
|
|
if valid self.po_key and self.po_token is provided in the config file"""
|
2022-07-20 09:57:22 -05:00
|
|
|
if self.use_pushover:
|
|
|
|
self.poc = self.po.Client(self.po_key, api_token=self.po_token)
|
2022-07-20 10:19:12 -05:00
|
|
|
|
|
|
|
def tornotifytest(self):
|
2022-07-20 11:34:13 -05:00
|
|
|
"""Used to make sure tornotify is working and messages are getting to the client"""
|
2022-07-20 10:19:12 -05:00
|
|
|
self.poc.send_message("Test Message", title="qbit-maid")
|
|
|
|
|
|
|
|
def tornotifysummary(self):
|
2022-07-20 11:34:13 -05:00
|
|
|
"""Main notification method when the app is used in an automated fashion"""
|
2022-07-20 10:19:12 -05:00
|
|
|
self.poc.send_message(f' Protected torrents: {len(self.tracker_protected_list)}\n\
|
|
|
|
Non-protected torrents: {len(self.tracker_nonprotected_list)}\n\
|
|
|
|
Total torrents set for deletion: {len(self.torrent_hash_delete_list)}', title="qbit-maid summary")
|
|
|
|
|
2022-07-14 19:03:06 -05:00
|
|
|
def getunixtimestamp(self):
|
2022-07-20 11:34:13 -05:00
|
|
|
"""Used for debuging and development related to unixtimestamps, not used in main script but useful"""
|
2022-07-14 19:03:06 -05:00
|
|
|
self.uts = self.t.time()
|
|
|
|
self.tl.info(self.uts)
|