-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
52 lines (40 loc) · 1.12 KB
/
run.py
File metadata and controls
52 lines (40 loc) · 1.12 KB
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
50
51
52
import os
import subprocess
import click
list_bots = [
'Khan'
]
def RunAll(bot:str):
if bot in AllBots():
original_dir = os.getcwd()
KillAll(bot)
os.chdir(bot)
run = subprocess.run(['tmux', 'new-session', '-d', '-s', bot, 'python bot.py'])
os.chdir(original_dir)
return f'{bot} start'
return f'{bot} not found'
def KillAll(bot:str):
if bot in AllBots():
kill = subprocess.run(['tmux', 'kill-session', '-t', bot])
return f'{bot} is killed'
return f'{bot} not found'
def AllBots():
return list_bots
@click.command()
@click.argument('command')
def main(command):
if command == 'RunAll':
for bot in AllBots():
RunAll(bot)
print(f'{bot} Run')
elif command == 'KillAll':
for bot in AllBots():
KillAll(bot)
print(f'{bot} killed')
elif command == 'AllBots':
for bot in AllBots():
print(bot)
else:
print('your command is wrong\nselect command in list :\n1 - RunAll\n2 - KillAll\n3 - AllBots')
if __name__ == "__main__":
main()