From a5a386ec2a49a89ffd52e074d705bf92fa22f739 Mon Sep 17 00:00:00 2001 From: justuser31 Date: Wed, 8 Mar 2023 15:40:23 +0300 Subject: [PATCH] Move db to home path --- dump.py | 9 +++++++-- ping.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dump.py b/dump.py index abab08c..6ec1389 100644 --- a/dump.py +++ b/dump.py @@ -1,8 +1,13 @@ +#Get home dir +from subprocess import getoutput +global home +home = getoutput("echo $HOME") + #Json import json def read(): - global db - with open('db.json', 'r') as openfile: + global db, home + with open(f'{home}/db.json', 'r') as openfile: db = json.load(openfile) diff --git a/ping.py b/ping.py index 62a1766..1eccd26 100644 --- a/ping.py +++ b/ping.py @@ -1,17 +1,22 @@ from mctools import PINGClient -ping = PINGClient('play.dmcraft.online') +ping = PINGClient('135.181.170.94',25630) #stats = ping.get_stats() +#Get home dir +from subprocess import getoutput +global home +home = getoutput("echo $HOME") + #Work with JSON import json def read(): - global db - with open('db.json', 'r') as openfile: + global db, home + with open(f'{home}/db.json', 'r') as openfile: db = json.load(openfile) def write(): global db js = json.dumps(db, indent=4) - with open("db.json", "w") as outfile: + with open(f'{home}/db.json', 'w') as outfile: outfile.write(js) #My libraries @@ -39,6 +44,6 @@ while True: ttime = 0 except Exception as e: - ping = PINGClient('play.dmcraft.online') + ping = PINGClient('135.181.170.94',25630) print(e)