def upload(): restful_str = "wget -O /tmp/last_upload.log \"" + Conf.Restful_URL + "topic=" + Conf.APP_ID + "&device_id=" + Conf.DEVICE_ID + "&key=" + Conf.SecureKey + "&msg=" + msg + "\"" color.print_p("restful_str:") print(restful_str) os.system(restful_str)
def storage(): #CSV_items = ['device_id', 'date', 'time', 'Tmp', 'RH', 'PM2.5','PM10', 'PM1.0','RGB_R','RGB_G','RGB_B','RGB_C','Lux', 'CO2', 'TVOC'] #CSV_type = ['string', 'date', 'time', 'float','float','int', 'int', 'int', 'int', 'int' ,'int', 'int', 'int', 'int', 'int' ] CSV_items = [ 'device_id', 'date', 'time', 's_t0', 's_h0', 's_d0', 's_d1', 's_d2', 's_lr', 's_lg', 's_lb', 's_lc', 's_l0', 's_gh', 's_gg' ] CSV_msg = "" for item in CSV_items: if item in values: CSV_msg = CSV_msg + str(values[item]) + ',' else: CSV_msg = CSV_msg + "N/A" + ',' CSV_msg = CSV_msg[:-1] #to get rid of ',' from last data #print(COLOR_PURPLE + "CSV_MSG:" + COLOR_REST) color.print_p("CSV_MSG:") print(CSV_msg) #remember to add USB drive storage!! with open(values["date"] + ".csv", "a") as f: #f.write(msg_headers + "\n") f.write(CSV_msg + "\n") f.write(CSV_msg + "\n") f.write(CSV_msg + "\n") f.write(CSV_msg + "\n") f.write(CSV_msg + "\n")
values["s_lr"] = 3250 values["s_lg"] = 3370 values["s_lb"] = 4147 values["s_lc"] = 1003 values["s_gh"] = 600 values["s_gg"] = 1337 msg = "" for item in values: msg = msg + "|" + item + "=" + str(values[item]) msg = msg + "|" #print("\033[35m%s\033[0m" %("base msg:")) #print(COLOR_PURPLE + "base msg:" + COLOR_REST) color.print_p("base msg:") print(msg) ##data storage #=================================# def storage(): if len(os.listdir("/media/pi")): path = "/media/pi/" + os.listdir("/media/pi")[0] else: path = Conf.FS_SD #CSV_items = ['device_id', 'date', 'time', 'Tmp', 'RH', 'PM2.5','PM10', 'PM1.0','RGB_R','RGB_G','RGB_B','RGB_C','Lux', 'CO2', 'TVOC'] #CSV_type = ['string', 'date', 'time', 'float','float','int', 'int', 'int', 'int', 'int' ,'int', 'int', 'int', 'int', 'int' ]
import libs.color_text as color print("HI") color.print_r("rI") color.print_g("gi") color.print_p("pu") #c_print(text,text_color,style = "no" ,background = "B"): color.c_print("HELLO") color.c_print("HELLO", "r", "B", "w") color.c_print("HELLO", "c", "B", "r") color.c_print("TEST\n", "p", "no", "B") color.c_print("TEST\n", "w", "B", "B") color.c_print("TEST\n", "w", "U", "B") color.c_print("TEST\n", "w", "N1", "B") color.c_print("TEST\n", "w", "N2", "B") print("===========================") print("\033[0;37;40m Normal text\n") print("\033[4;37;40m Underlined text\033[0;37;40m \n") print("\033[9;37;40m Strikethrough text\033[0;37;40m \n") print("\033[1;37;40m Bright Colour\033[0;37;40m \n") print("\033[3;37;40m Negative Colour1\033[0;37;40m \n") print("\033[5;37;40m Negative Colour2\033[0;37;40m\n") #print("\033[6;37;40m Negative Colour3\033[0;37;40m\n")