-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathacrcloud_client.py
More file actions
38 lines (30 loc) · 939 Bytes
/
acrcloud_client.py
File metadata and controls
38 lines (30 loc) · 939 Bytes
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
#!/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(b'refresh', b''))
def stop(self):
print (self.mc.set(b'stop', b''))
def state(self, id):
state = self.mc.get(('state:'+str(id)).encode())
#jsonstate = json.loads(state)
print (state)
def start(self):
while 1:
cmd = raw_input("(1.refresh, 2.state, 3.stop): ")
if cmd == '1':
self.refresh()
elif cmd == '2':
id = raw_input('stream_id: ')
self.state(id.strip())
elif cmd == '3':
self.stop()
if __name__ == '__main__':
mc = MonitorClient()
mc.start()