Newer
Older
if serv.isAlive():
serv.join(timeout = SERV_JOIN)
except (KeyboardInterrupt,SystemExit,Exception) as e:
httpd.server_close()
if sys.platform.startswith('linux'):
os.system('pkill -9 python')
elif sys.platform.startswith('win'):
sys.exit(0)
break
def handler_server():
while not shut_event.is_set():
my_lock.acquire()
httpd.handle_request()
my_lock.release()
time.sleep(THD_SLEEP)
def init():
print GetDLLVersion()
global httpd
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
httpd = HTTPServer((HTTP_SERVER_NAME,HTTP_SERVER_PORT),GetHandler)
httpd.socket.setsockopt(SOL_SOCKET,SO_REUSEADDR,1)
RunAll()
def GetDLLVersion():
dll_ver = mySO.AIS_GetDLLVersion
dll_ver.restype = c_char_p
return dll_ver()
#=========================== helper functions =======================
def wr_status(funct_name,dl_status):
res = funct_name + ': {%d(%s): %s}\n' % (dl_status,hex(dl_status),E_ERROR_CODES[dl_status])
return res
# def dbg_action2str(action_value):
# res = '[%d(%s):%s]' % (action_value,hex(action_value),E_CARD_ACTION[action_value])
# return res
# def dl_status2str(status):
# res = '[%d(%s):%s]' % (status,hex(status),E_ERROR_CODES[status])
# return res
def dbg_action2str(action_value):
dbg_a = mySO.dbg_action2str
dbg_a.argtype = c_int
dbg_a.restype = c_char_p
return dbg_a(action_value)
def dl_status2str(status):
dl_s = mySO.dl_status2str
dl_s.argtype = DL_STATUS
dl_s.restype = c_char_p
return dl_s(status)
def sys_get_timezone():
s_tz = mySO.sys_get_timezone
s_tz.restype = c_long
return s_tz()
def sys_get_daylight():
s_dl = mySO.sys_get_daylight
s_dl.restype = c_int
return s_dl()
def sys_get_dstbias():
s_dstb = mySO.sys_get_dstbias
s_dstb.restype = c_long
return s_dstb()
def sys_get_timezone_info():
s_tzinfo = mySO.sys_get_timezone_info
s_tzinfo.restype = c_char_p
return s_tzinfo()
#======================================================================
mojFormat = "| {0:3d} | {1:016X} | {2} | {3:7d} | {4:2d} | {5} | {6:7d} | {7:10s} | {8:5d} | {9:8d} | {10:9d} |"
format_grid = ["--------------------------------------------------------------------------------------------------------------------",
"| indx| Reader HANDLE | SerialNm | Type h/d | ID | FW | speed | FTDI: sn | opened | DevStatus | SysStatus |",
"--------------------------------------------------------------------------------------------------------------------"
]
rte_list_header=["-----------------------------------------------------------------------------------------------------------------------------------------",
"| Idx | ACTION | RD ID | Card ID | JobNr | NFC [length] : UID | Time-stamp | Date - Time |",
"----------------------------------------------------------------------------------------------------------------------------------------"
]
rte_format = "| {0:5d} | {1:28s} | {2:5d} | {3:7d} | {4:5d} | {5:24s} | {6:10d} | {7:s} | "
log_format = "| {0:5d} | {1:32s} | {2:5d} | {3:7d} | {4:5d} | {5:24s} | {6:#10d} | {7:s} | "
my_lock = threading.Lock()
shut_event = threading.Event()
if __name__ == '__main__':
global httpd
global mySO
mySO = GetPlatformLib()
init()