1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/ausx-audb

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
main.py 3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Danny Отправлено 10.05.2022 05:28 1c88d71
import json,sys,os,re,multiprocessing
if __name__ == '__main__':
print("AUDB v1.5 DEV预览版")
import user,rsaop,server
if os.path.isdir('data/')==False:
os.mkdir('data/')
user.init()
print("read config")
def readfile(file):
f=open(file,'r')
re=f.read()
f.close()
return re
def writefile(file,data):
with open(file,'w') as f:
return f.write(data)==len(data)
def start(conf):server.init(conf)
if os.path.isfile('audb.json')==False:
writefile('audb.json','{"Server":{"port":1217,"key":"1-27*5`。#@%¥%。;,@","maximum_connection":100},"anti_ddos":true,"anti_cracking":true}')
conf=json.loads(readfile('audb.json'))
print("starting server,port:",conf['Server']['port'])
server.init(conf)
print('done!')
def runcode(c):
code=re.split(" ",c)
if code[0]=='exit':
exit()
elif code[0]=='restart':
python = sys.executable
os.execl(python, python, * sys.argv)
elif code[0]=='conf':
if len(code)-1>=1:
if code[1]=='see':
print(conf)
elif len(code)-1>=3 and code[1]=='set':
isjson=True
try:
json.loads(code[3])
except:
isjson=False
if code[2] in conf:
if isjson:
conf[code[2]]==json.loads(code[3])
else:
conf[code[2]]==code[3]
writefile('audb.json',json.dumps(conf))
print('Modified successfully')
else:
print(code[2],"is not define")
elif code[0]=='':
1+1==1# do nothing
elif code[0]=='create':
if len(code)-1>=3:
if code[1]=='user':
if user.createuser(code[2],code[3],code[4]):
print('create user seccessfullyp')
else:
print('create user false')
elif code[1]=="db":
if user.checkuser(code[2]):
if user.checkdb(code[2],code[3]):
print('The database already exists')
else:
user.createdb(code[2],code[3])
else:
print('user is not define')
else:
print('There is no such command:',code[0])
if len(sys.argv)>1:
if os.path.isfile(sys.argv[1]):
with open(sys.argv[1]) as file:
codej = re.split('\n',file.read())
for i in codej:
runcode(i)
while True:
runcode(input(">>"))
else:print("请不要以import方式调用!!!!,如需import,请将if __name__ == '__main__':与else删除")

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/ausx-audb.git
git@api.gitlife.ru:oschina-mirror/ausx-audb.git
oschina-mirror
ausx-audb
ausx-audb
master