From 00ee3dfca9ab9c485def03c5f8505c5c4f0c8773 Mon Sep 17 00:00:00 2001 From: karapazar Date: Fri, 25 Jun 2021 12:57:05 +0300 Subject: [PATCH] ConnectionControl --- auth.py | 88 +++++++++++++- fileList.txt | 3 +- lib/helper.py | 139 +++++++++++++++++----- lib/testHelper.py | 280 +++++++++++++++++++++++++++++++++++++++------ main.py | 20 +++- send.py | 4 +- updateUsersList.py | 1 + version.txt | 2 +- 8 files changed, 466 insertions(+), 71 deletions(-) diff --git a/auth.py b/auth.py index b13cd86..d3ce5f3 100644 --- a/auth.py +++ b/auth.py @@ -13,8 +13,58 @@ try: + def read_ssh_key(): + data = read_from_file("/root/.ssh/id_rsa.pub") + if data == None: + cmd = 'ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""' + command(cmd) + data = read_from_file("/root/.ssh/id_rsa.pub") + + if data == None: + return None + + return data.strip('\n') + + def get_device_unique(): + ssh_key = log_and_run(read_ssh_key) + params ={ 'ssh_anahtar': ssh_key } + + data = http_post(api_base_url+"rfidCihazAnahtarGetir", data=params, j=True) + if data == None: + log(ERROR, "Yeni anahtar alinamadi! (data: None, "+to_json_str(params)+")") + return "" + + if data["status"] != "success": + log(ERROR, "Yeni anahtar alinamadi! (data: "+to_json_str(data)+", params: "+to_json_str(params)+")") + return "" + + key = data["data"]["message"] + + macs = log_and_run(get_mac_adresses) + serial = log_and_run(get_cpu_serial) + + return macs[0] + serial + macs[1] + key + def get_auth(): - return '{"token": "AzqUejyZD4II3n8Wt72d72", "id": 72, "name": "Test Cihazi"}' + unique = log_and_run(get_device_unique) + if unique == "": + return "" + + params = { + "type": "rfid_cihazlar", + "unique": unique + } + + data = http_post(api_base_url+"deviceLogin", data=params, j=True) + if data == None: + log(ERROR, "Auth data alinamadi! (data: None, params: "+to_json_str(params)+")") + return "" + + if data["status"] != "success": + log(ERROR, "Auth data alinamadi! (data: "+to_json_str(data)+", params: "+to_json_str(params)+" )") + return "" + + return data["data"] def run(): auth = log_and_run(get_auth) @@ -33,7 +83,41 @@ def run(): def add_as_new_device(): global api_base_url - print("send request to backend for new device store") + ips = log_and_run(get_ip_adresses) + macs = log_and_run(get_mac_adresses) + serial = log_and_run(get_cpu_serial) + unique = log_and_run(get_device_unique) + real_ip = log_and_run(get_real_ip) + cihaz_json = read_from_file("/var/www/html/cihaz.json") + ssh_key = log_and_run(read_ssh_key) + + + detail = { + "ips": ips, + "macs": macs, + "serial": serial, + "unique": unique, + "real_ip": real_ip, + "cihaz_json": cihaz_json, + "ssh_key": ssh_key + } + + params = { + "column_set_id": 120, + "detail": to_json_str(detail), + "id": 0 + } + + url = api_base_url+"public/tables/yeni_cihazlar/store" + data = http_post(url, data=params, j=True) + + if data == None: + log(ERROR, "Yeni cihaz olarak eklenemedi! (data: None, params: "+to_json_str(params)+")") + return "" + + if data["status"] != "success": + log(ERROR, "Yeni cihaz olarak eklenemedi! (data: "+to_json_str(data)+", params: "+to_json_str(params)+" )") + return diff --git a/fileList.txt b/fileList.txt index 99eb417..b6a3a3c 100644 --- a/fileList.txt +++ b/fileList.txt @@ -19,4 +19,5 @@ lib/MFRC522.py lib/testCamera.py lib/testOled.py lib/testPins.py -lib/testRfid.py \ No newline at end of file +lib/testRfid.py +lib/testHelper.py \ No newline at end of file diff --git a/lib/helper.py b/lib/helper.py index 4a0e445..30836f1 100644 --- a/lib/helper.py +++ b/lib/helper.py @@ -47,7 +47,7 @@ restart = False started = False -debug = True +debug = False loop = False api_base_url = "https://kamu.kutahya.gov.tr/api/v1/" update_base_url = "https://kamu.kutahya.gov.tr/uploads/2021/01/01/mesaiTakipCihazi/" @@ -59,6 +59,7 @@ connected = False connection_control_timer_period = 50.0 +connection_controling = False auth = None @@ -80,6 +81,7 @@ temp = False +fileName = "" #### FUNCTIONS #### @@ -114,7 +116,11 @@ def log_temp(l, s): GPIO.cleanup() -def preload(log_file_name, online = True, disp = "no", cam = False, pins = None, rf = False): +def preload(log_file_name, online = True, disp = "no", cam = False, pins = None, rf = False): + global started, fileName + + fileName = log_file_name + log_init(log_file_name) log(INFO, "Starting...") @@ -488,25 +494,26 @@ def download_file(url, path, sllDisable = False): cmd = cmd +" --no-check-certificate" temp = command(cmd) - return True except Exception as e: return False def http_get(url, return_raw = False, j = False, force = False): + + global last_response, connected, lib_base_path, request_using + try: log(INFO, "Http GET ("+url+")") - global last_response, connected, lib_base_path, request_using - request_using = True - if connected == False and force == False: log(INFO, "Http GET by pass") return + last_response = None request_using = True - rt = requests.get(url, verify=lib_base_path+"kamu.ca-bundle") + + rt = requests.get(url, verify= False) last_response = rt.text if return_raw: @@ -515,7 +522,7 @@ def http_get(url, return_raw = False, j = False, force = False): return rt elif j: r = rt.json() - log(INFO, "Http GET OK (JSON)") + log(INFO, "Http GET OK (JSON)") request_using = False return r @@ -535,16 +542,22 @@ def http_get(url, return_raw = False, j = False, force = False): log_e(e, "Http GET ERROR (url: " + url + ", text: "+text+")") last_response = None - + def http_post(url, data = None, files = None, return_raw = False, j = False, force = False): + + global last_response, lib_base_path, request_using, connected + try: log(INFO, "Http POST ("+url+")") + + if connected == False and force == False: + log(INFO, "Http GET by pass") + return - global last_response, lib_base_path, request_using - last_response = None - + last_response = None request_using = True - rt = requests.post(url, data=data, files=files, verify=lib_base_path+"kamu.ca-bundle") + + rt = requests.post(url, data=data, files=files, verify=False) last_response = rt.text if return_raw: @@ -580,7 +593,7 @@ def get_url_for_rfid_readed(card_id, date_time = "now"): if auth == None: return "" - + return api_base_url + "device/" + auth["token"] + "/rfidReaded?card_id=" + encode_url(card_id) + "&time="+encode_url(date_time) def get_url_for_send_photo(): @@ -642,7 +655,7 @@ def restart_ip(): def connection_control(): log(INFO, "Connection control") - global api_base_url, connected, loop, connection_control_timer_period, request_using + global api_base_url, connected, loop, connection_control_timer_period, request_using, connection_controling, started, fileName temp = threading.Timer(connection_control_timer_period, connection_control) temp.daemon = True @@ -652,24 +665,70 @@ def connection_control(): log(INFO, "Connection control by pass") return - data = http_get(api_base_url, j=True, force=True) - if data != None: - if data["status"] == "success": + if connection_controling: + log(INFO, "Connection control by pass (connection_controling)") + return + + connection_controling = True + + try: + data = http_get(api_base_url, j=True, force=True) + + if data == None: + log(INFO, "Connection control error.") + connected = False + connection_controling = False + return + + if data["status"] != "success": + log(INFO, "Connection control error") + connected = False + connection_controling = False + return + + if connected == True: + log(INFO, "Connection control continue as True") + connection_controling = False + return + + if started != True: + log(INFO, "Connection control OK (started: False)") + connection_controling = False + connected = True + return + + if fileName != "main.py": + log(INFO, "Connection control OK") + connected = True + connection_controling = False + return + + log(INFO, "Connection changed False to True. Try fill auth and users") + + temp = log_and_run(fill_auth, True) + if temp == True: + temp = log_and_run(fill_users, True) + + if temp == True: connected = True log(INFO, "Connection control OK") else: - connected = False - log(INFO, "Connection control error") - else: + log(INFO, "Connection control OK but Auth or Users fail") + + except Exception as e: connected = False - log(INFO, "Connection control error.") + log_e(e, "Connection control error (ex).") + connection_controling = False def to_json_str(o): return json.dumps(o) def from_json_str(str): - return json.load(str) + try: + return json.load(str) + except Exception as e: + return json.loads(str) def create_dir_if_not_exist(dir): if os.path.isdir(dir) == False: @@ -717,10 +776,10 @@ def read_from_file(file_path, j=False): rt = "".join(r) - log(INFO, "Read from file OK ("+rt+")") + log(INFO, "Read from file OK ( "+rt+" )") if j: - return log_and_run(from_json_str(rt)) + return log_and_run(from_json_str, rt) return rt @@ -732,24 +791,52 @@ def fill_auth(force = False): global auth_py_file_path, auth_file_path, auth if force: + if os.path.isfile(auth_file_path): + log(INFO, "Delete old auth file") + os.remove(auth_file_path) + cmd = "python3 "+auth_py_file_path command(cmd) with open(auth_file_path, "r") as a: auth = from_json_str(a) + temp = "token" in auth.keys() + log(INFO, "Auth validation: " + str(temp)) + return temp + def fill_users(force = False): global update_users_list_py_file_path, users_list_path, users if force: + if os.path.isfile(users_list_path): + log(INFO, "Delete old users file") + os.remove(users_list_path) + cmd = "python3 "+update_users_list_py_file_path command(cmd) with open(users_list_path, "r") as a: users = from_json_str(a) + try: + temp = len(list(users.keys())[0].split(" ")) == 4 + log(INFO, "Users validation: " + str(temp)) + return temp + except Exception as e: + log_e(e, "Users validation exception") + return False + def command(cmd): return os.popen(cmd).read() def command_async(cmd): - return os.system(cmd) \ No newline at end of file + return os.system(cmd) + + +#Processleri her seferinde durdurmamak için yazıldı. Sadece test methodudur. +def killPyt(): + ps = command("ps -A |grep py") + psSplit = ps.split(" ") + if len(psSplit)>12: + command("kill "+psSplit[1]) diff --git a/lib/testHelper.py b/lib/testHelper.py index b4fb61b..e278ef2 100644 --- a/lib/testHelper.py +++ b/lib/testHelper.py @@ -5,8 +5,17 @@ import traceback import unittest import string -from random import * import readchar +import datetime +from random import * +import os.path +from os import path + +import urllib3 +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + +import requests +requests.packages.urllib3.disable_warnings() import RPi.GPIO as GPIO @@ -23,20 +32,20 @@ green_led = 24#green_led = 18 triger_pin = 17#triger_pin = 11 -local_debug = True - +local_debug = False class TestSum(unittest.TestCase): - + #### Variables #### temp = False - + + #### Helper Functions #### - + def get_random_str(self): allchar = string.ascii_letters + string.digits return "".join(choice(allchar) for x in range(randint(8, 12))) @@ -53,7 +62,7 @@ def control(self): self.temp = True def read_rfid(self, msg = "Kart okutunuz...."): - log(INFO, msg) + print(msg) while True: if h.loop == False: break @@ -61,7 +70,7 @@ def read_rfid(self, msg = "Kart okutunuz...."): try: card_id = get_card_id_from_rfid() if card_id != None: - log(INFO, "Card ID: " + card_id) + print("Card ID: " + card_id) return card_id except Exception as e: @@ -69,8 +78,8 @@ def read_rfid(self, msg = "Kart okutunuz...."): - #### Test Functions #### - + #### Test Functions #### + def test_start(self): self.assertEqual(sum([1, 2, 3]), 6, "Should be 6") @@ -82,6 +91,9 @@ def test_run_dynamic_function(self): self.assertEqual(h.temp, True, "Should be True") def test_log(self): + global local_debug + h.debug = True + random_str = self.get_random_str() log(INFO, "Random str for log test: " + random_str) lastLine = self.get_last_line_from_current_log_file() @@ -92,6 +104,8 @@ def test_log(self): except Exception as e: self.assertEqual(False, True, "Log file must has random_str:" + random_str) + h.debug = local_debug + def test_log_e(self): try: temp = 6 / 0 @@ -105,8 +119,11 @@ def test_log_e(self): self.assertEqual(True, True, "Temp") except Exception as e: self.assertEqual(False, True, "Log file must has random_str (for log_e):" + random_str) - + def test_log_and_run(self): + global local_debug + h.debug = True + self.temp = False h.log_and_run(self.control) @@ -121,7 +138,12 @@ def test_log_and_run(self): except Exception as e: self.assertEqual(False, True, "Log file must has info for log_and_run operations (lastLine: " + lastLine + ")") - def test_log_and_run_async(self): + h.debug = local_debug + + def test_log_and_run_async(self): + global local_debug + h.debug = True + self.temp = False h.log_and_run_async(self.control) @@ -137,6 +159,8 @@ def test_log_and_run_async(self): except Exception as e: self.assertEqual(False, True, "Log file must has info for log_and_run operations (lastLine: " + lastLine + ")") + h.debug = local_debug + def test_take_photo(self): name = take_photo() self.assertIsNotNone(name, "name should not be None") @@ -148,15 +172,18 @@ def test_take_photo(self): name = self.get_random_str() + ".jpg" - name = take_photo(name) - self.assertIsNotNone(name, "name should not be None") + tempName = take_photo(name) + + self.assertIsNotNone(tempName, "name should not be None") + self.assertEqual(tempName, name, "name should be equal tempName") + c = os.path.isfile(h.base_photo_path+name) self.assertEqual(c, True, "File should be exist in dir: " + h.base_photo_path+name) os.remove(h.base_photo_path+name) - """def test_get_card_id_from_rfid(self): + def test_get_card_id_from_rfid(self): h.last_rfid_card_id = "" h.rfid_same_count = 5 @@ -173,7 +200,7 @@ def test_take_photo(self): self.assertEqual(1, h.rfid_same_count, "Should be 1") self.read_rfid(msg = "Ayni karti okutunuz...") - self.assertEqual(2, h.rfid_same_count, "Should be 2")""" + self.assertEqual(2, h.rfid_same_count, "Should be 2") def test_pin(self): @@ -188,7 +215,7 @@ def test_pin(self): state = GPIO.input(green_led) self.assertEqual(state, False, "File should be False") - + def test_display(self): displays = ['oled'] @@ -219,46 +246,231 @@ def test_display(self): print("Was "+h.default_display+" clean? [y/n]") r = str(readchar.readkey()) self.assertEqual(r, "y", "Key should be y") + + #TODO: limit_bandwith && unlimit_bandwith + def test_download_file(self): + path = "img/logo.png" + name= "wgetDeneme.png" + url = "https://kamu.kutahya.gov.tr/uploads/2021/01/01/mesaiTakipCihazi/" + + temp = download_file(url+path, h.base_photo_path+name, sllDisable=True) + size = os.stat(h.base_photo_path+name).st_size + self.assertGreater(size,0,"File size greather then 0") + + file_exist = os.path.exists(h.base_photo_path+name) + self.assertEqual(file_exist,True,"Should be True") + os.remove(h.base_photo_path+name) + + def test_http_get(self): + temp = http_get(h.api_base_url) + self.assertEqual(temp, '{"status":"success","code":200,"data":{"message":"service.ok"}}', "Should be txt") + + temp = http_get(h.api_base_url, j = True) + self.assertEqual(temp["status"], 'success', "Should be Json") + + temp = http_get(h.api_base_url, return_raw = True) + self.assertEqual(temp.json()["status"], 'success', "Should be raw") + + def test_http_post(self): + temp = http_post(h.api_base_url) + self.assertEqual(temp, '{"status":"success","code":200,"data":{"message":"service.ok"}}', "Should be txt") + + temp = http_post(h.api_base_url, j = True) + self.assertEqual(temp["status"], 'success', "Should be Json") + + temp = http_post(h.api_base_url, return_raw = True) + self.assertEqual(temp.json()["status"], 'success', "Should be raw") + + def test_encode_url(self): + url = h.api_base_url + param = url.replace(":","%3A") + temp = encode_url(url) + self.assertEqual(temp, param,"Should be encode_url") + + def test_get_url_for_rfid_readed(self): + fill_auth() + token = h.auth["token"] + card_id = self.read_rfid(msg = "Kart okutunuz...") + encode_card_id =card_id.replace(" ", "%20") + + #EMPTY DAY, TODAY , PREV DAY , NEXT DAY + empty_day = get_url_for_rfid_readed(card_id) + self.assertEqual(empty_day,h.api_base_url+"device/"+token+"/rfidReaded?card_id="+encode_card_id + "&time=now","Should be error url") + + to_day = datetime.datetime.now() + current_time = to_day.strftime("%Y-%m-%d %H:%M:%S") + today_day = get_url_for_rfid_readed(card_id,current_time) + self.assertEqual(today_day,h.api_base_url+"device/"+token+"/rfidReaded?card_id="+encode_card_id + "&time="+encode_url(current_time),"Should be error url") + + prev_date = datetime.datetime.now() - datetime.timedelta(1) + prev_time = prev_date.strftime("%Y-%m-%d %H:%M:%S") + prev_day = get_url_for_rfid_readed(card_id, prev_time) + self.assertEqual(prev_day,h.api_base_url+"device/"+token+"/rfidReaded?card_id="+encode_card_id + "&time="+encode_url(prev_time),"Should be error url") + + #TODO 300 gun oncesi icin de bir tet yaz error donecek + + next_date = datetime.datetime.now() + datetime.timedelta(1) + next_time = next_date.strftime("%Y-%m-%d %H:%M:%S") + next_day = get_url_for_rfid_readed(card_id, next_time) + self.assertEqual(next_day,h.api_base_url+"device/"+token+"/rfidReaded?card_id="+encode_card_id + "&time="+encode_url(next_time),"Should be error url") + + empty_post = http_post(empty_day) + today_post = http_post(today_day) + next_post = http_post(next_day) + prev_post = http_post(prev_day) + self.assertEqual(json.loads(empty_post)['status'],"success","Must be success") + self.assertEqual(json.loads(today_post)['status'],"success","Must be success") + self.assertEqual(json.loads(next_post)['status'],"success","Must be success") + self.assertEqual(json.loads(prev_post)['status'],"success","Must be success") + + def test_get_url_for_send_photo(self): + fill_auth() + token = h.auth["token"] + url = "https://kamu.kutahya.gov.tr/api/v1/" + temp = get_url_for_send_photo() + param = url+"device/"+token+"/sendPhoto" + self.assertEqual(temp,param, "Should be https://kamu.kutahya.gov.tr/api/v1/device/token/sendPhoto") + + def test_get_url_for_users_list(self): + fill_auth() + token = h.auth["token"] + url = "https://kamu.kutahya.gov.tr/api/v1/" + temp = get_url_for_users_list() + param = url+"device/"+token+"/getUsersList" + self.assertEqual(temp,param, "Should be https://kamu.kutahya.gov.tr/api/v1/device/token/sendPhoto") + + def test_get_mac_adresses(self): + cmd = "ip addr | grep ether | awk -F ' ' '{print $2}'" + output = command(cmd) + param = output.split("\n") + temp = get_mac_adresses() + self.assertEqual(temp, param, "Must be the same ") + + def test_get_ip_adresses(self): + cmd = "ip addr | grep 'inet ' | awk -F ' ' '{print $2}'" + output = command(cmd) + param = output.split("\n") + temp = get_ip_adresses() + self.assertEqual(temp,param, "Must be the same ") + + def test_get_cpu_serial(self): + cpuserial = "" + try: + f = open("/proc/cpuinfo","r") + for line in f: + if line[0:6]=="Serial": + cpuserial = line[10:26] + f.close() + except: + cpuserial = "" + param = get_cpu_serial() + self.assertEqual(cpuserial,param, "Must be the same ") + + def test_connection_control(self): + h.connected = False + h.request_using = True + connection_control() + self.assertEqual(h.connected, False, "Must be the true ") + + h.request_using = False + connection_control() + self.assertEqual(h.connected, True, "Must be the true ") + def test_to_json_str(self): + temp = ["data","success"] + param = to_json_str(temp) + self.assertEqual(param,'["data", "success"]', "Data must be the same ") + + def test_from_json_str(self): + s = '{"data": "success"}' + obj = from_json_str(s) + self.assertEqual(obj, {"data": "success"}, "Must be the same ") + def test_write_to_file(self): + test_file_url = "/var/www/html/file/testwritefile.json" + temp = 'string' + write_to_file(test_file_url,temp) + f = open(test_file_url, "r") + readed = f.read() + f.close() + self.assertEqual(readed, 'string', "Must be the same ") + os.remove(test_file_url) + + obj = {"data":"success"}; + write_to_file(test_file_url, obj, j=True) + f = open(test_file_url, "r") + readed = f.read() + f.close() + self.assertEqual(readed, h.to_json_str(obj), "Must be the same ") + os.remove(test_file_url) + + def test_get_real_ip(self): + temp = h.get_real_ip().split(".") + self.assertEqual(len(temp),4, "Must be 4") + def test_read_from_file(self): + test_file_url = "/var/www/html/file/testreadfile.json" + temp = '{"data":"success"}' + write_to_file(test_file_url,temp) + + param = read_from_file(test_file_url) + self.assertEqual(param, temp, "Must be the same ") + + obj = read_from_file(test_file_url, j=True) + self.assertEqual(obj["data"], "success", "Must be the same ") + + os.remove(test_file_url) - #TODO: exit - - - - - - - - #TODO: test_end_load + def test_fill_auth(self): + temp = os.path.isfile(h.auth_file_path) + if temp: + os.remove(h.auth_file_path) + + fill_auth(True) + temp = os.path.isfile(h.auth_file_path) + self.assertEqual(temp, True, "Must be True") + + auth = read_from_file(h.auth_file_path, j=True) + + self.assertEqual("token" in auth.keys(), True, "Auth must has token attribute") + + def test_fill_users(self): + temp = os.path.isfile(h.users_list_path) + if temp: + os.remove(h.users_list_path) + + fill_users(True) + temp = os.path.isfile(h.users_list_path) + self.assertEqual(temp, True, "Must be True") + + users = read_from_file(h.users_list_path, j=True) + + try: + temp = len(list(users.keys())[0].split(" ")) == 4 + self.assertEqual(temp, True, "Users must has rfid attribute") + except Exception as e: + log_e(e, "Users validation exception") + self.assertEqual(False, True, "Users must has rfid attribute...") + - #TODO: reboot_os try: def run(): unittest.main() - - #Ana Fonksiyon if __name__ == "__main__": time.sleep(1) - h.restart = False h.loop = True h.debug = local_debug; - pin_config = {"in": [], "out": [buzzer_pin, red_led, green_led, triger_pin]} preload(file_name, online = True, disp = "oled", cam = True, rf = True, pins = pin_config) - log_and_run(run) - - except Exception as e: fn = os.path.basename(__file__) diff --git a/main.py b/main.py index 2fa046f..2fdfab3 100644 --- a/main.py +++ b/main.py @@ -50,11 +50,18 @@ def on_load(): log_and_run(set_cam) - log_and_run(fill_auth, True) - log_and_run(fill_users, True) + temp = log_and_run(fill_auth, True) + if temp == True: + temp = log_and_run(fill_users, True) + else: + log_and_run(fill_users) log_and_run(connection_control) + if temp == False: + log(INFO, "Users or Auth was failed") + h.connected = False + log_and_run(fill_scene) def set_cam(): @@ -103,7 +110,7 @@ def get_now_info_for_display(): now = datetime.datetime.now() temp = str(now.strftime("%d aaa %H:%M:%S")); - temp = temp.replace("aaa", h.months[now.month]) + temp = temp.replace("aaa", h.months[now.month-1]) temp = temp.split(" ") @@ -461,8 +468,11 @@ def read_rfid(): log_and_run(clear_display) - write_text_on_center_of_display(name, y = 5, font_size = 20) - write_text_on_center_of_display(surname, y = 32, font_size = 20) + write_text_on_center_of_display(name, y = 2, font_size = 20) + write_text_on_center_of_display(surname, y = 25, font_size = 20) + + temp = str(datetime.datetime.now().strftime("%H:%M")) + write_text_on_center_of_display(temp, y = 45, font_size = 20) time.sleep(1) diff --git a/send.py b/send.py index c92b502..a437369 100644 --- a/send.py +++ b/send.py @@ -23,7 +23,7 @@ def get_id_and_record_token_from_photo(photo): temp = temp.split("-") card_id = temp[0] temp = temp[1].split("_") - dt = temp[0] + "-" + temp[1] + "-" + temp[2] + " " + temp[3] + ":" + temp[4] + ":" + temp[5] + dt = temp[0] + "-" + temp[1] + "-" + temp[2] + " " + temp[3] + ":" + temp[4] + ":00" url = get_url_for_rfid_readed(card_id, dt) if url == "": @@ -48,7 +48,7 @@ def get_id_and_record_token_from_photo(photo): return (temp[0], temp[1]) except Exception as e: - log_e(e, "error in get_id_and_record_token_from_photo") + log_e(e, "error in get_id_and_record_token_from_photo: "+photo) return ("", "") def run(): diff --git a/updateUsersList.py b/updateUsersList.py index 1d5df6f..29427e8 100644 --- a/updateUsersList.py +++ b/updateUsersList.py @@ -14,6 +14,7 @@ file_name = os.path.basename(__file__) + try: def run(): log_and_run(fill_auth) diff --git a/version.txt b/version.txt index b9d2bdf..3bad788 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.0.5 \ No newline at end of file +2.0.12 \ No newline at end of file