-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (43 loc) · 1.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import argparse
import logging
import sys
import sentry_sdk
from jobs import jobs, run
# region sentry
sentry_sdk.init(
"https://b9865f81742941e1b658462ed983cfe7@o996799.ingest.sentry.io/5975280",
traces_sample_rate=1.0,
)
sentry_sdk.set_user({"ip_address": "{{auto}}"})
# endregion
# region logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
# endregion
# region parser
parser = argparse.ArgumentParser(
description="执行自动化规则。",
epilog=jobs.info,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"index",
help="任务编号,231代表所有任务",
type=int,
choices=list(range(jobs.num)) + [231],
)
parser.add_argument(
"-s",
"--simulate",
help="不对服务器内容做任何实际更改,只显示将更改的内容",
action="store_true",
)
# endregion
if __name__ == "__main__":
args = parser.parse_args()
try:
run(index=args.index, simulate=args.simulate)
except KeyboardInterrupt:
sys.exit(130)