From 4d43e402b2b4e27bbbbfe557216d95963a27af72 Mon Sep 17 00:00:00 2001 From: gabrielgio Date: Wed, 14 Jul 2021 21:23:44 +0200 Subject: feat: Add nextcloud path param Add a new param to input the nextcloud root path. --- util.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 util.py (limited to 'util.py') diff --git a/util.py b/util.py deleted file mode 100644 index cd80506..0000000 --- a/util.py +++ /dev/null @@ -1,40 +0,0 @@ -import argparse -import json -import os -from time import sleep -from typing import Dict - -import jsonpickle -import requests - -headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} - -parser = argparse.ArgumentParser(description="Monitor saved") -parser.add_argument('-c', '--client-id', help="Reddit client id", default=os.environ.get('CLIENT_ID', '')) -parser.add_argument('-s', '--client-secret', help="Reddit client secret", default=os.environ.get('CLIENT_SECRET', '')) -parser.add_argument('-u', '--reddit-username', help="Reddit username", default=os.environ.get('REDDIT_USERNAME', '')) -parser.add_argument('-p', '--reddit-password', help="Reddit user password", default=os.environ.get('REDDIT_PASSWORD', '')) -parser.add_argument('-P', '--nextcloud-password', help="Nextcloud Password", default=os.environ.get('NEXTCLOUD_PASSWORD', '')) -parser.add_argument('-U', '--nextcloud-username', help="Nextcloud Username", default=os.environ.get('NEXTCLOUD_USERNAME', '')) -parser.add_argument('-o', '--nextcloud-host', help="Nextcloud Host", default=os.environ.get('NEXTCLOUD_HOST', 'localhost')) - - -def try_post(url, json_string, count=0): - try: - if count > 10: - return - r = requests.post(url, data=json_string, headers=headers) - if r.status_code != 200: - sleep(60 * count) - try_post(url, json_string, count + 1) - except: - sleep(60 * count) - try_post(url, json_string, count + 1) - - -def jsonfy(post): - json_string = jsonpickle.encode(post) - json_dict: Dict = json.loads(json_string) - json_dict.pop('_reddit') - json_dict.pop('py/object') - return json.dumps(json_dict) -- cgit v1.2.3