-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathacrcloud_stop.py
50 lines (40 loc) · 1.36 KB
/
acrcloud_stop.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
50
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import time
import json
import tools_memcache
from acrcloud_config import config
class MonitorClient:
def __init__(self):
self.mc = tools_memcache.Client(['127.0.0.1:{0}'.format(config['server']['port'])])
def refresh(self):
print self.mc.set('refresh', '')
def restart(self, id):
print self.mc.set('restart', json.dumps({'stream_id':str(id), 'stream_url':''}))
def pause(self, id):
print self.mc.set('pause', json.dumps({'stream_id':str(id), 'stream_url':''}))
def stop(self):
print self.mc.set('stop', '')
def state(self, id):
state = self.mc.get('state-'+str(id))
jsonstate = json.loads(state)
print jsonstate
def start(self):
while 1:
cmd = raw_input('(1.refresh, 2.restart, 3.state, 4.pause, 5.stop): ')
if cmd == '1':
self.refresh()
elif cmd == '2':
id = raw_input('stream_id: ')
self.restart(id.strip())
elif cmd == '3':
id = raw_input('stream_id: ')
self.state(id.strip())
elif cmd == '4':
id = raw_input('stream_id: ')
self.pause(id.strip())
elif cmd == '5':
self.stop()
if __name__ == '__main__':
mc = MonitorClient()
mc.stop()