From 8333eb92c7c557acbda22f03fcc53472b2c591af Mon Sep 17 00:00:00 2001 From: kirbylife Date: Mon, 2 Dec 2019 02:48:52 -0600 Subject: [PATCH] now the client check updates on the folder --- client.py | 18 +++++++++++++++--- compare_json.py | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/client.py b/client.py index 09b2b7a..3b9201a 100755 --- a/client.py +++ b/client.py @@ -49,11 +49,10 @@ class MunyalClient(pystray.Icon): name="downloader", daemon=True) thread_uploader.start() - thread_downloader.start() + # thread_downloader.start() self.run(self.__run) def __run(self, icon): - print("_run") icon.visible = True sleep(60) self.stop() @@ -63,8 +62,21 @@ class MunyalClient(pystray.Icon): def uploader(self): print("Uploader") + folder = self.config["folder"] + last = get_json(folder) while True: - sleep(5) + sleep(1) + actual = get_json(folder) + _actual = deepcopy(actual) + delete, add = compare_json(last, actual) + + if delete: + print("Cosas eliminadas:") + print(delete) + if add: + print("Cosas agregadas:") + print(add) + last = _actual def __upload(self, path): pass diff --git a/compare_json.py b/compare_json.py index 183ecc7..34a2833 100644 --- a/compare_json.py +++ b/compare_json.py @@ -31,8 +31,8 @@ def compare_json(json1, json2): if __name__ == "__main__": try: - json1 = get_json("/home/kirbylife/Munyal/test_1") - json2 = get_json("/home/kirbylife/Munyal/test_2") + json1 = get_json("/home/kirbylife/Munyal") + json2 = get_json("/home/kirbylife/Munyal") except Exception: print("error outside") json1, json2 = compare_json(json1, json2)