Newer
Older
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'''
global command functions
1.1
'''
import sys
import os
import signal
from ctypes import Structure, c_int
from shell import device_list
from shell.ais_shell import GetListInformation, AISGetLibraryVersionStr, AisShellpGetProgramVersion, AISRestart, \
AISDestroy, AISOpen, AISClose
from ais_http import AisHttpGetProgramVersion
dev = device_list.S_DEVICE
class LocalArgs(Structure):
_fields_ = [('device', c_int)]
def GetDLLVersion():
return "AIS_GetDLLVersion() >> %s\n" % AISGetLibraryVersionStr()
def GetProgramVersion():
return '{0}\n{1}\n'.format(AisHttpGetProgramVersion(), AisShellpGetProgramVersion())
def GetExitApp():
if sys.platform.startswith('linux'):
os.system('pkill -9 python')
os.kill(os.getpid(), signal.SIGINT)
elif sys.platform.startswith('win'):
os._exit(0)
return '\nServer stopped !\nClose program !\n'
def GetAISRestart():
try:
return AISRestart(dev)
except TypeError as exc:
return exc
def GetAISDestroy():
try:
return AISDestroy(dev)
except TypeError as exc:
return exc
def GetAISOpenDevice():
try:
return AISOpen(dev)
except TypeError as exc:
return exc
def GetAISCloseDevice():
try:
return AISClose(dev)
except TypeError as exc:
return exc
action = {'q': GetListInformation,
'v': GetDLLVersion,
'V': GetProgramVersion,
'X': GetExitApp,
'R': GetAISRestart,
'D': GetAISDestroy,
'o': GetAISOpenDevice,
'c': GetAISCloseDevice}
def command(getfunction, device, ldev):
global dev
dev = ldev
return action[getfunction].__call__()