mirror of
https://github.com/snowykami/server-status-client.git
synced 2024-11-22 23:27:45 +08:00
✨ 降低python版本依赖
This commit is contained in:
parent
b6f6eba1cf
commit
eb6a57d5a7
39
main.py
39
main.py
@ -1,41 +1,4 @@
|
||||
import sys
|
||||
|
||||
from server_status.api import *
|
||||
from server_status.cmd_parser import server_status_alc
|
||||
|
||||
|
||||
def main():
|
||||
raw_msg = "server_status " + " ".join(sys.argv[1:])
|
||||
arp = server_status_alc.parse(raw_msg)
|
||||
|
||||
if arp.query("run"):
|
||||
sub_opts = arp.subcommands["run"].options
|
||||
client = Client(
|
||||
addr=arp["server"],
|
||||
token=arp["token"],
|
||||
client_id=arp["id"],
|
||||
name=sub_opts["name"].args["name"],
|
||||
location=sub_opts["location"].args["location"],
|
||||
labels=sub_opts["labels"].args["labels"],
|
||||
interval=sub_opts["interval"].args["interval"],
|
||||
)
|
||||
client.start()
|
||||
|
||||
elif arp.query("rm"):
|
||||
client = Client(
|
||||
addr=arp["server"],
|
||||
token=arp["token"],
|
||||
client_id=arp["id"],
|
||||
)
|
||||
resp = client.remove(arp["id"])
|
||||
if resp.status_code == 200:
|
||||
log("Host removed successfully")
|
||||
else:
|
||||
log(f"Failed to remove host: {resp.text}")
|
||||
|
||||
else:
|
||||
log("Unknown command, use 'server_status --help' for help/未知命令或参数错误,请使用 'server_status --help' 获取帮助")
|
||||
|
||||
from server_status.__main__ import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
41
server_status/__main__.py
Normal file
41
server_status/__main__.py
Normal file
@ -0,0 +1,41 @@
|
||||
import sys
|
||||
|
||||
from server_status.api import *
|
||||
from server_status.cmd_parser import server_status_alc
|
||||
|
||||
|
||||
def main():
|
||||
raw_msg = "server_status " + " ".join(sys.argv[1:])
|
||||
arp = server_status_alc.parse(raw_msg)
|
||||
|
||||
if arp.query("run"):
|
||||
sub_opts = arp.subcommands["run"].options
|
||||
client = Client(
|
||||
addr=arp["server"],
|
||||
token=arp["token"],
|
||||
client_id=arp["id"],
|
||||
name=sub_opts["name"].args["name"],
|
||||
location=sub_opts["location"].args["location"],
|
||||
labels=sub_opts["labels"].args["labels"],
|
||||
interval=sub_opts["interval"].args["interval"],
|
||||
)
|
||||
client.start()
|
||||
|
||||
elif arp.query("rm"):
|
||||
client = Client(
|
||||
addr=arp["server"],
|
||||
token=arp["token"],
|
||||
client_id=arp["id"],
|
||||
)
|
||||
resp = client.remove(arp["id"])
|
||||
if resp.status_code == 200:
|
||||
log("Host removed successfully")
|
||||
else:
|
||||
log(f"Failed to remove host: {resp.text}")
|
||||
|
||||
else:
|
||||
log("Unknown command, use 'server_status --help' for help/未知命令或参数错误,请使用 'server_status --help' 获取帮助")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user