From 08b241824bed4ea65f687edf57d1d6529eebc2dc Mon Sep 17 00:00:00 2001 From: jiang <1446935823@qq.com> Date: Fri, 19 Apr 2024 16:20:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tools/Tools.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Tools/Tools.py b/Tools/Tools.py index b326549..f727f9a 100755 --- a/Tools/Tools.py +++ b/Tools/Tools.py @@ -1,5 +1,8 @@ +# coding=utf-8 +#!/bin/python - +import sys +import os def newuser(name,password,int): import base64 @@ -28,4 +31,35 @@ def ifuser(name,password): ifpass = base64.b64decode(ifpass) if ifpass == password.encode("utf-8"): text = 'yes' - return text \ No newline at end of file + return text + +def port(): + if len(sys.argv) == 2: + if os.path.exists(".config/main/port"): + fs = open(".config/main/port", "rb") + ini = fs.read().decode("utf-8") + print("port [" + ini + "]") + elif len(sys.argv) == 3: + if not os.path.exists(".config"): + os.mkdir(".config") + if not os.path.exists(".config/main"): + os.mkdir(".config/main") + fs = open(".config/main/port","w") + fs.write(str(int(sys.argv[2]))) + fs.close + print("set port [" + sys.argv[2] + "]") + else: + print("port [port]") + +def help(): + print("port [port]") + +if __name__ == "__main__": + dir = sys.argv[0][:-14] + os.chdir(dir) + if len(sys.argv) == 1: + sys.argv = (sys.argv[0]+" port 8889").split(' ') + if sys.argv[1] == "help": + help() + elif sys.argv[1] == "port": + port() \ No newline at end of file