Move db to home path

main
justuser31 2 years ago
parent eb80896b3a
commit a5a386ec2a

@ -1,8 +1,13 @@
#Get home dir
from subprocess import getoutput
global home
home = getoutput("echo $HOME")
#Json #Json
import json import json
def read(): def read():
global db global db, home
with open('db.json', 'r') as openfile: with open(f'{home}/db.json', 'r') as openfile:
db = json.load(openfile) db = json.load(openfile)

@ -1,17 +1,22 @@
from mctools import PINGClient from mctools import PINGClient
ping = PINGClient('play.dmcraft.online') ping = PINGClient('135.181.170.94',25630)
#stats = ping.get_stats() #stats = ping.get_stats()
#Get home dir
from subprocess import getoutput
global home
home = getoutput("echo $HOME")
#Work with JSON #Work with JSON
import json import json
def read(): def read():
global db global db, home
with open('db.json', 'r') as openfile: with open(f'{home}/db.json', 'r') as openfile:
db = json.load(openfile) db = json.load(openfile)
def write(): def write():
global db global db
js = json.dumps(db, indent=4) 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) outfile.write(js)
#My libraries #My libraries
@ -39,6 +44,6 @@ while True:
ttime = 0 ttime = 0
except Exception as e: except Exception as e:
ping = PINGClient('play.dmcraft.online') ping = PINGClient('135.181.170.94',25630)
print(e) print(e)

Loading…
Cancel
Save