diff --git a/qbit-maid.py b/qbit-maid.py index a8e7faf..88eb542 100644 --- a/qbit-maid.py +++ b/qbit-maid.py @@ -2,6 +2,7 @@ import qbittorrentapi import pushover from json import load +from json import dump from qlist import * from qlogging import * from qprocess import * @@ -66,6 +67,9 @@ class Qbt: self.torrentlist = {} # Pulling all torrent data self.torrentlist = self.qbt_client.torrents_info() + self.d = dump + self.l = load + writetor(self) #Main process block #debugpremecal(self) if self.use_log: diff --git a/qlogging.py b/qlogging.py index 3b36379..3605e55 100644 --- a/qlogging.py +++ b/qlogging.py @@ -47,12 +47,15 @@ def getunixtimestamp(self): self.uts = self.t.time() self.tl.info(self.uts) -def writetor(self, filepath='./torrentinfo.txt'): +def writetor(self, filepath='./torrentinfo.json'): """Write all torrent data to a file. Useful for development of new features. """ - with open(filepath, 'w') as fp: - fp.write(str(self.torrentlist)) + json_init = self.l(self.torrentlist) + print(json_init) + # json_object = self.d(self.torrentlist, indent=4) + # with open(filepath, 'w') as fp: + # fp.write(json_object) def listfirsttor(self, index=0): """Only lists the first torrent""" @@ -86,4 +89,7 @@ def getscriptruntime(self): if self.use_log: self.tl.info(f'Execution time: [{elapsed_time}]') if self.use_pushover: - self.extm = f"Execution time: [{elapsed_time}]" \ No newline at end of file + self.extm = f"Execution time: [{elapsed_time}]" + +def getobjecttype(object): + print(type(object)) \ No newline at end of file diff --git a/test_qbitmaid.py b/test_qbitmaid.py index 9621b98..3d2ce5e 100644 --- a/test_qbitmaid.py +++ b/test_qbitmaid.py @@ -1,12 +1,18 @@ import unittest from qprocess import torprocessor -from json import loads +import json +import logging +import sys class TestQprocess(unittest.TestCase): - def test_protected_ratio_below(self): - self.ti = open("./test/torrentinfo.txt") - self.tracker_list = loads(self.ti) - torprocessor(self) - + def test_log_and_test_data(self): + self.log= logging.getLogger( "SomeTest.testSomething" ) + self.tracker_list = open("./test/torrentinfo.txt", "r") + self.log.debug(self.tracker_list) + assert self.tracker_list + + # torprocessor(self) if __name__ == '__main__': + logging.basicConfig( stream=sys.stderr ) + logging.getLogger( "SomeTest.testSomething" ).setLevel( logging.DEBUG ) unittest.main() \ No newline at end of file