df_alert_min_date = df_alert.loc[df_alert['Date'] == df_alert['Date'].max(), 'Date'].values[0] if df_min_date > df_alert_min_date: df = df.loc[df['Date'] > df_alert_min_date, :] for i in range(len(df)): date = df.loc[i, 'Date'].strftime('%Y-%m-%d %H:%M:%S') flow = df.loc[i, 'Flow'] tag = df.loc[i, 'Tag'] amount = df.loc[i, 'Amount'] line.sendtext(f'\nDate: {date} \ \nFlow: {flow} \ \nTag: {tag} \ \nAmount: {amount}') print('Sending notification to LINE') df.to_csv(r'.\log\alert_log.csv', index=False, mode='a', header=False) else: pass except Exception as e: print("Something wrong, Please checkc errorlog") line.sendtext('Something wrong, Please checkc errorlog"')
def make_csv(): with open('homeWork.csv', mode='w',encoding='utf-8',newline="") as cvs_file: csv_writer = csv.writer(cvs_file, delimiter=',') for i in range(len(data)): csv_writer.writerow(data[i]) line = LINE("4vV3B81Wt7BLoVytgmE2U4H7o8ZaYSFCx0LL1X9gQzJ") data = [] with open("homeWork.csv",mode="r",encoding='utf-8')as cvs_file: csv_reader = csv.reader(cvs_file, delimiter=',') for row in csv_reader: data.append(row) print(data) while True: now = datetime.datetime.now() day = str(now.day)+"/"+str(now.month)+"/"+str(now.year) time = str(now.now().hour)+":"+str(now.minute)+":"+str(now.second) if time != "6:0:0": for i in range(len(data)): subject =str("วิชา :"+data[i][0]) sent_time = str("วันที่ส่ง :"+data[i][1]) discrip =str("รายละเอียด :"+data[i][2]) text = day+"\n"+subject+"\n"+sent_time+"\n"+discrip line.sendtext(text) if str(data[i][1]) == str(day): del data[i] make_csv() break Time.sleep(1)
for(x,y,w,h) in faces: color = {"blue":(255,0,0), "red":(0,0,255), "green":(0,255,0), "white":(255,255,255)} cv2.rectangle(img,(x,y),(x+w,y+h),color['green'], 2) id, confidence = recognizer.predict(gray[y:y+h,x:x+w]) # Check if confidence is less them 100 ==> "0" is perfect match if (confidence < 80): id = names[id] confidence = " {0}%".format(round(100 - confidence)) print(confidence) else: id = "unknown" confidence = " {0}%".format(round(100 - confidence)) print("unknown : ",confidence) line.sendtext("ผู้คนแปลกหน้า") line.sendimage(img[:, :, ::-1]) time.sleep(5) cv2.putText(img, str(id), (x+5,y-5), font, 1, color['white'], 2) cv2.putText(img, str(confidence), (x+5,y+h-5), font, 1, (255,255,0), 1) cv2.imshow('camera',img) if(cv2.waitKey(1) & 0xFF== ord('q')): break camera.release() out.release() cv2.destroyAllWindows()
conn = psycopg2.connect( host="localhost", database="postgres", user="******", password="******") token_kmitl = 'SuWZzmcKMMH5RvFaglsCT8jWlIDEBltqjEwhNR7aepd' x = datetime.datetime.now() print(x.strftime("%x")) #ex. 12/31/18 print(x.strftime("%A")) #Weekday, full version Wednesday line = LINE(token_kmitl) msg ='''Morning report 3/19/2021 Name Arrival Status Tachrat 9.00 on time Kree 9.45 late ''' line.sendtext(msg) def line_guest(data): #มีรูปมีข้อความรับ 3 ค่า return def Morning_report(): #รับค่าดาต้าbaseรายวัน txt = "Morning report"+ x.strftime("%x") +"\n" +"Name Arrival Status" +"\n" # if Arrival > 9.30: # txt += " late" # elif Arrival < 9.30: # txt += " on time" # elif Arrival == null: # txt += " absent" # txt += "tacharat" line.sendtext(txt)