def job(): global count count += 1 print('it is time to do job!') postUrl(count) quickstart.main() # main function return
def mail_summary(): #print(parameters.get('Body')) main() ezgmail.init() unreadThreads = ezgmail.unread(maxResults=5) print(unreadThreads) return unreadThreads
def handle_updates(updates): for update in updates["result"]: text = update["message"]["text"] message = update["message"] chat = update["message"]["chat"]["id"] items = ["Clock in", "Clock out"] if text == "/start": send_message("Welcome to learnseeker! Please type /command to clock-in or clock-out", chat) elif text == "/command": keyboard = build_keyboard(items) send_message("Please choose an option", chat, keyboard) elif text == "Clock in": f = open("userName.txt", "w") f.write(str(message["from"]["first_name"].encode("utf-8"))) f.close() f = open("clock.txt", "w") f.write("Clock-in") f.close() qs.main() send_message("Have a good day at work!", chat) elif text == "Clock out": f = open("userName.txt", "w") f.write(str(message["from"]["first_name"].encode("utf-8"))) f.close() f = open("clock.txt", "w") f.write("Clock-out") f.close() send_message("What did you do today? :) (Optional)", chat) else : f = open("activities.txt", "w") f.write(text) f.close() qs.main() send_message("Goodbye!", chat)
def send_mail(parameters): main() ezgmail.init() print(parameters) toEmail=parameters['email'] subject=parameters['sub_email'] body=parameters['body_email'] print(toEmail,subject,body,sep=" ") ezgmail.send(toEmail,subject,body)
def test_main(capsys: typing.Any) -> None: main(PROJECT, INSTANCE_ZONE, INSTANCE_NAME) out, _ = capsys.readouterr() assert f"Instance {INSTANCE_NAME} created." in out assert re.search(f"Instances found in {INSTANCE_ZONE}:.+{INSTANCE_NAME}", out) assert re.search(f"zones/{INSTANCE_ZONE}:.+{INSTANCE_NAME}", out) assert f"Instance {INSTANCE_NAME} deleted." in out
def alerter(listReminderTimes, listDates, listStarting, listTitle, listDescription, listEnding, numElements): #currentTime gets current time and stores it as a string currentTime = str(datetime.datetime.now()) #The currentTime string is now parsed for compairson currentDate = currentTime[0:10] currentTime = currentTime[11:16] getStuckInLoop = False shouldSendMessage = False indexNeeded = 0 #This loop compares the current time to the reminder times of each event grabbed for Google calendar #If there is a match shouldSendMessage is made to True for ix in range(0, len(listReminderTimes)): print("current time ", currentTime, "reminder time ", listReminderTimes[ix], "List Starting", str(listDates[ix])) if (currentTime == listReminderTimes[ix] and str(currentDate) == str(listDates[ix])): indexNeeded = ix shouldSendMessage = True global counterOfMessages counterOfMessages = counterOfMessages + 1 orderedPair = str(listReminderTimes[ix][0:2]) + "," + str( counterOfMessages) + "\n" outputFile.write(orderedPair) #print( "the hour", listReminderTimes[ix][0:2]) #This if statment is necessary when shouldSendMessage becomes true because it the sends text message to the user if (shouldSendMessage): messageSender.sendChristopherSMS(str(listDates[indexNeeded]), listTitle[indexNeeded], listStarting[indexNeeded], listEnding[indexNeeded], listDescription[indexNeeded]) shouldSendMessage = False getStuckInLoop = True #A timer is used here make the application light on the hardware time.sleep(55) #This while loop is necessarry to prevent messages from being sent multiple times when only one is needed while (getStuckInLoop): currentTime = str(datetime.datetime.now()) currentTime = currentTime[11:16] #print("stuck in loop") #print("the time", currentTime) #print ("the reminder time ", listReminderTimes[indexNeeded]) if (currentTime != listReminderTimes[indexNeeded]): getStuckInLoop = False #A timer is used here make the application light on the hardware time.sleep(30) quickstart.main()
def signup(request): if request.method == "POST": form = UserForm(request.POST) if form.is_valid(): user, Profile = form.save() user.save() user.profile.save() arr = quickstart.main() print(arr) for obj in arr: newTimeSlot = TimeSlot(profile=user.profile, datetime=p.parse(obj)) newTimeSlot.save() login(request, user) return render(request, "home.html") else: return render(request, "signup.html", { 'form': form, }) else: form = UserForm() return render(request, "signup.html", { 'form': form, })
def alerter(listReminderTimes, listDates, listStarting, listTitle, listDescription, listEnding, numElements): #currentTime gets current time and stores it as a string currentTime = str(datetime.datetime.now()) #The currentTime string is now parsed for compairson currentDate = currentTime[0:10] currentTime = currentTime[11:16] getStuckInLoop = False shouldSendMessage = False indexNeeded = 0 #This loop compares the current time to the reminder times of each event grabbed for Google calendar #If there is a match shouldSendMessage is made to True for ix in range(0, len(listReminderTimes)): print("current time ", currentTime, "reminder time ", listReminderTimes[ix], "List Starting", str(listDates[ix])) if(currentTime == listReminderTimes[ix] and str(currentDate)==str(listDates[ix])): indexNeeded = ix shouldSendMessage = True global counterOfMessages counterOfMessages = counterOfMessages + 1 orderedPair = str(listReminderTimes[ix][0:2]) + "," + str(counterOfMessages) + "\n" outputFile.write(orderedPair) #print( "the hour", listReminderTimes[ix][0:2]) #This if statment is necessary when shouldSendMessage becomes true because it the sends text message to the user if(shouldSendMessage): messageSender.sendChristopherSMS(str(listDates[indexNeeded]), listTitle[indexNeeded], listStarting[indexNeeded], listEnding[indexNeeded], listDescription[indexNeeded]) shouldSendMessage = False getStuckInLoop = True #A timer is used here make the application light on the hardware time.sleep(55) #This while loop is necessarry to prevent messages from being sent multiple times when only one is needed while(getStuckInLoop): currentTime = str(datetime.datetime.now()) currentTime = currentTime[11:16] #print("stuck in loop") #print("the time", currentTime) #print ("the reminder time ", listReminderTimes[indexNeeded]) if(currentTime != listReminderTimes[indexNeeded]): getStuckInLoop = False #A timer is used here make the application light on the hardware time.sleep(30) quickstart.main()
def reserve(request): if request.method == 'POST': form = ReservationForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.user = request.user post.save() start_datetime = post.start_datetime.isoformat() end_datetime = post.end_datetime.isoformat() full_name = ' '.join([post.user.first_name, post.user.last_name]) quickstart.main(post.motive, full_name, post.user.first_name, start_datetime, end_datetime) return redirect('reservations') else: form = ReservationForm() return render(request, 'reservation/reserve.html', {'form': form,})
def index(): elias = User.get_recent_user_from_id("2") #load the homepage if request.method == 'POST': print(request.form) if 'Dosed' in request.form: elias.just_dosed() #reset days to 0 and store in database elif 'Meds' in request.form: try: elias.reup(int(request.form['Meds'])) except: pass elif 'Schedule' in request.form: quickstart.main() return render_template('home.html', days_since_inj=elias.last_dose_from_db(), dosage_left=elias.get_remaining_inj_from_db())
def insert_articles_to_database(articles_list): database_connection = sqlite3.connect("articles.db") cursor = database_connection.cursor() for article in articles_list: cursor.execute("SELECT Title from Articles WHERE Title=?", (article["title"], )) result = cursor.fetchone() if not result: cursor.execute("INSERT INTO Articles VALUES (?,?)", (article["title"], article["url"])) current_time = datetime.datetime.now() current_time = current_time.strftime("%b %d %Y %H:%M") logging.info( f"Article has been added to database at {current_time}") article["url"] = shorten_link(article["url"]) for recipent in constants.get('recipients', ''): main(article, recipent) time.sleep(120) # send_mail(article) database_connection.commit()
def refreshListOfEvents(): """ get/refresh event list from google calendar every 30 sec """ while (True): global connected connected = connect() if (connected): try: quickstart.main() # refresh events file global data data = readFile() # update data (event list) time.sleep(30) except: print( "Unable to Refresh events some error occured while getting events from google" ) time.sleep(10) else: time.sleep(10) print("Check your internet connection")
def __init__(self): super(SmartFrame, self).__init__() self.time_event_exist = sys.argv[1] self.weather_event_exist = sys.argv[2] self.event_exist = sys.argv[3] self.annouce_header_color = graphics.Color(255, 0, 0) self.annouce_descpt_color = graphics.Color(100, 200, 255) self.weather_str = "" if self.weather_event_exist: self.get_weather() self.annc_q = [] if self.event_exist: self.annc_q = quickstart.main()
def tapahtumat(bot, update): global last_events, events if time.time() - last_events > 600: events = quickstart.main() last_events = time.time() text = "" for x, y in events.items(): text = text + "\n*" + x + "*\n" for i in y: if len(i) == 1: text = text + i[0] + "\n" else: text = text + "{} [{}]({})\n".format( ".".join(i[0].split("-")[::-1]), i[1], i[2]) #text += "{} {}\n".format(".".join(i[0].split("-")[::-1]), i[1]) bot.send_message(update.effective_chat.id, text, parse_mode="MARKDOWN")
def __init__(self, parent): self.events = gCal.main() if not self.events: return Frame.__init__(self, parent) # startTime="2016-01-12T17:19:59.902675" self.configure(bg=FRAME_BG, pady=20, padx=20) self.place(rely=1, relx=0, y=1, x=0, anchor="sw") toplabel = Label(self, bg=LABEL_BG, fg=FONT_COLOR, text="Upcoming", font=MY_SMALL_FONT) toplabel.grid(row=0, column=0, sticky="w", pady=15) self.row = 1 for event in self.events: eventtime = event['start'].get('dateTime', event['start'].get('date')) eutime = eventtime[8:10] + "." + eventtime[5:7] + "." # +eventtime[2:4] label = Label(self, bg=LABEL_BG, fg=FONT_COLOR, font=MY_SMALL_FONT, text=eutime) label.grid(row=self.row, column=0, sticky="w") label = Label(self, bg=LABEL_BG, fg=FONT_COLOR, text=event['summary'], font=MY_SMALL_FONT) label.grid(row=self.row, column=1, sticky="w", padx=15) self.row += 1
def tanaan(bot, update, command): global last_events, events if time.time() - last_events > 600: events = quickstart.main() last_events = time.time() text = "<b>TÄNÄÄN:</b>\n" tanaan = datetime.datetime.today().isoformat( )[:10] # 'Z' indicates UTC time for x, y in events.items(): for i in y: if i[0] == tanaan: text += "<a href=\"{}\">{}</a>\n".format(i[2], i[1]) if not command and text == "<b>TÄNÄÄN:</b>\n": return elif text == "<b>TÄNÄÄN:</b>\n": text = "<b>TÄNÄÄN</b> ei ole tapahtumia" bot.send_message(update.effective_chat.id, text, parse_mode="HTML") else: bot.send_message(update.effective_chat.id, text, parse_mode="HTML")
def main(): try: epd = epd7in5b.EPD() epd.init() #print("Clear...") epd.Clear(0xFF) print("Done Clearing") # Drawing on the Vertical image HBlackimage = Image.new('1', (epd7in5b.EPD_HEIGHT, epd7in5b.EPD_WIDTH), 255) # 298*126 HRedimage = Image.new('1', (epd7in5b.EPD_HEIGHT, epd7in5b.EPD_WIDTH), 255) # 298*126 # Vertical drawblack = ImageDraw.Draw(HBlackimage) drawred = ImageDraw.Draw(HRedimage) font_title = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 24) font_message = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 22) font_date = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 18) font_meeting = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 17) font_time_slot = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 16) font_time_small = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 14) drawred.text((68, 4), 'Main Conference Room', font=font_title, fill=0) drawblack.line((70, 29, 314, 29), fill=0) # Bottom Border for Title drawred.line((3, 60, 380, 60), fill=0) drawred.line((3, 61, 380, 61), fill=0) drawblack.line((2, 62, 381, 62), fill=0) drawred.line((0, 63, 384, 63), fill=0) drawred.line((0, 64, 384, 64), fill=0) # Top Border for Title drawred.line((0, 0, 384, 0), fill=0) drawred.line((0, 1, 384, 1), fill=0) drawblack.line((2, 2, 381, 2), fill=0) drawred.line((3, 3, 380, 3), fill=0) drawred.line((3, 4, 380, 4), fill=0) # Right Border for Title drawred.line((379, 5, 379, 59), fill=0) drawred.line((380, 5, 380, 59), fill=0) drawblack.line((381, 2, 381, 62), fill=0) drawred.line((382, 2, 382, 62), fill=0) drawred.line((383, 2, 383, 64), fill=0) # Left Border for Title drawred.line((0, 2, 0, 64), fill=0) drawred.line((1, 2, 1, 63), fill=0) drawblack.line((2, 2, 2, 62), fill=0) drawred.line((3, 3, 3, 59), fill=0) drawred.line((4, 3, 4, 59), fill=0) drawblack.line((383, 65, 383, 640), fill=0) drawblack.line((382, 65, 382, 640), fill=0) drawblack.line((0, 65, 0, 640), fill=0) drawblack.line((1, 65, 1, 640), fill=0) ###Time Slot Lines & Text### normal_tick_x2 = 5 thirty_tick_x2 = 9 time_text_x = 10 # 9am Ticks & Text y_nine = 64 drawblack.line((0, (y_nine + 10), normal_tick_x2, (y_nine + 10))) drawblack.line((0, (y_nine + 21), normal_tick_x2, (y_nine + 21))) drawblack.line((0, (y_nine + 32), thirty_tick_x2, (y_nine + 32))) drawblack.line((0, (y_nine + 43), normal_tick_x2, (y_nine + 43))) drawblack.line((0, (y_nine + 54), normal_tick_x2, (y_nine + 54))) drawblack.text((time_text_x, (y_nine + 1)), '9am', font=font_time_slot, fill=0) # 10am Line y_ten = 128 drawblack.line((0, y_ten, 384, y_ten), fill=0) # 10am Ticks & Text drawblack.line((0, (y_ten + 10), normal_tick_x2, (y_ten + 10))) drawblack.line((0, (y_ten + 21), normal_tick_x2, (y_ten + 21))) drawblack.line((0, (y_ten + 32), thirty_tick_x2, (y_ten + 32))) drawblack.line((0, (y_ten + 43), normal_tick_x2, (y_ten + 43))) drawblack.line((0, (y_ten + 54), normal_tick_x2, (y_ten + 54))) drawblack.text((time_text_x, (y_ten + 1)), '10am', font=font_time_slot, fill=0) # 11am Line y_eleven = 192 drawblack.line((0, y_eleven, 384, y_eleven), fill=0) # 11am Ticks & Text drawblack.line((0, (y_eleven + 10), normal_tick_x2, (y_eleven + 10))) drawblack.line((0, (y_eleven + 21), normal_tick_x2, (y_eleven + 21))) drawblack.line((0, (y_eleven + 32), thirty_tick_x2, (y_eleven + 32))) drawblack.line((0, (y_eleven + 43), normal_tick_x2, (y_eleven + 43))) drawblack.line((0, (y_eleven + 54), normal_tick_x2, (y_eleven + 54))) drawblack.text((time_text_x, (y_eleven + 1)), '11am', font=font_time_slot, fill=0) # 12pm Line y_twelve = 256 drawblack.line((0, y_twelve, 384, y_twelve), fill=0) # 12pm Ticks & Text drawblack.line((0, (y_twelve + 10), normal_tick_x2, (y_twelve + 10))) drawblack.line((0, (y_twelve + 20), normal_tick_x2, (y_twelve + 20))) drawblack.line((0, (y_twelve + 31), thirty_tick_x2, (y_twelve + 31))) drawblack.line((0, (y_twelve + 42), normal_tick_x2, (y_twelve + 42))) drawblack.line((0, (y_twelve + 53), normal_tick_x2, (y_twelve + 53))) drawblack.text((time_text_x, (y_twelve + 1)), '12pm', font=font_time_slot, fill=0) # 1pm Line y_one = 319 drawblack.line((0, y_one, 384, y_one), fill=0) # 1pm Ticks & Text drawblack.line((0, (y_one + 10), normal_tick_x2, (y_one + 10))) drawblack.line((0, (y_one + 21), normal_tick_x2, (y_one + 21))) drawblack.line((0, (y_one + 32), thirty_tick_x2, (y_one + 32))) drawblack.line((0, (y_one + 43), normal_tick_x2, (y_one + 43))) drawblack.line((0, (y_one + 54), normal_tick_x2, (y_one + 54))) drawblack.text((time_text_x, (y_one + 1)), '1pm', font=font_time_slot, fill=0) # 2pm Line y_two = 383 drawblack.line((0, y_two, 384, y_two), fill=0) # 2pm Ticks & Text drawblack.line((0, (y_two + 10), normal_tick_x2, (y_two + 10))) drawblack.line((0, (y_two + 21), normal_tick_x2, (y_two + 21))) drawblack.line((0, (y_two + 32), thirty_tick_x2, (y_two + 32))) drawblack.line((0, (y_two + 43), normal_tick_x2, (y_two + 43))) drawblack.line((0, (y_two + 54), normal_tick_x2, (y_two + 54))) drawblack.text((time_text_x, (y_two + 1)), '2pm', font=font_time_slot, fill=0) # 3pm Line y_three = 447 drawblack.line((0, y_three, 384, y_three), fill=0) # 3pm Ticks & Textblack drawblack.line((0, (y_three + 10), normal_tick_x2, (y_three + 10))) drawblack.line((0, (y_three + 21), normal_tick_x2, (y_three + 21))) drawblack.line((0, (y_three + 32), thirty_tick_x2, (y_three + 32))) drawblack.line((0, (y_three + 43), normal_tick_x2, (y_three + 43))) drawblack.line((0, (y_three + 54), normal_tick_x2, (y_three + 54))) drawblack.text((time_text_x, (y_three + 1)), '3pm', font=font_time_slot, fill=0) # 4pm Line y_four = 511 drawblack.line((0, y_four, 384, y_four), fill=0) # 4pm Ticks & Text drawblack.line((0, (y_four + 10), normal_tick_x2, (y_four + 10))) drawblack.line((0, (y_four + 21), normal_tick_x2, (y_four + 21))) drawblack.line((0, (y_four + 32), thirty_tick_x2, (y_four + 32))) drawblack.line((0, (y_four + 43), normal_tick_x2, (y_four + 43))) drawblack.line((0, (y_four + 54), normal_tick_x2, (y_four + 54))) drawblack.text((time_text_x, (y_four + 1)), '4pm', font=font_time_slot, fill=0) # 5pm Line y_five = 575 drawblack.line((0, y_five, 384, y_five), fill=0) # 5pm Ticks & Text drawblack.line((0, (y_five + 10), normal_tick_x2, (y_five + 10))) drawblack.line((0, (y_five + 21), normal_tick_x2, (y_five + 21))) drawblack.line((0, (y_five + 32), thirty_tick_x2, (y_five + 32))) drawblack.line((0, (y_five + 43), normal_tick_x2, (y_five + 43))) drawblack.line((0, (y_five + 54), normal_tick_x2, (y_five + 54))) drawblack.text((time_text_x, (y_five + 1)), '5pm', font=font_time_slot, fill=0) #6pm Text drawblack.text((time_text_x, 623), '6pm', font=font_time_slot, fill=0) update_check = [] date_reg = '' date_x_reg = 0 refresh = True startup = True loop = True # should always be true while loop: t = strftime("%Y-%m-%d %H:%M:%S", gmtime()) print(t) month, date_x = monthName(int(t[5:7])) day = dayFix(t[8:10], t[11:13]) date = month + ' ' + day + ', ' + t[0:4] if date != date_reg and date_reg != '': epd, drawblack, drawred, HBlackimage, HRedimage = new_day_redraw( ) # Draws back over old date in white to make it disappear drawred.text((date_x_reg, 32), date_reg, font=font_title, fill=255) drawred.text((date_x, 32), date, font=font_title, fill=0) #Date date_reg = date date_x_reg = date_x ## CALENDAR DATA PROCESSING ### events_temp = quickstart.main() events_official_start = { } # Final dict to store event data --> key: meeting name, value: time events_official_end = {} for event_tup in events_temp: if int(event_tup[1][8:10]) == int(day): start_time = event_tup[1][11:16] end_time = event_tup[2][11:16] # Makes time into an int without ':' as the value corresponding to its key # for sorting purposes. Leading zero's are eliminated as well. events_official_start[event_tup[0]] = int( start_time.replace(':', '')) events_official_end[event_tup[0]] = int( end_time.replace(':', '')) # events_sorted will be a list of tuples sorted by second element in each tuple (time) events_sorted_start = sorted(events_official_start.items(), key=operator.itemgetter(1)) events_sorted_end = sorted(events_official_end.items(), key=operator.itemgetter(1)) meetings = [] # List of meetings in order start_times = [ ] # List of times corresponding to their associated meetings in order for tup in events_sorted_start: meetings.append(tup[0]) time_str = str(tup[1]) start_time = time_str[0:2] + ':' + time_str[ 2:] # Assumes current hour is before 10am hour = int(time_str[0:2]) if len( time_str ) == 3: # Fixes current time variable if its 10am or after start_time = time_str[0] + ':' + time_str[1:] hour = int(time_str[0]) xm = 'am' # Assumes its before 12pm due to military time if hour > 11: xm = 'pm' # Catches if its 12pm or later if hour > 12: # Checks to see if convert from military to normal time is needed hr = hour - 12 start_time = str(hr) + ':' + time_str[2:] start_times.append(start_time + ' ' + xm) end_times = [] for tup in events_sorted_end: time_str = str(tup[1]) end_time = time_str[0:2] + ':' + time_str[2:] hour = int(time_str[0:2]) if len(time_str) == 3: end_time = time_str[0] + ':' + time_str[1:] hour = int(time_str[0]) xm = 'am' if hour > 11: xm = 'pm' if hour > 12: hr = hour - 12 end_time = str(hr) + ':' + time_str[2:] end_times.append(end_time + ' ' + xm) print(start_times) print(end_times) print(meetings) print("Meetings length: " + str(len(meetings))) print("UpdateCheck length: " + str(len(update_check))) if len(meetings) == len(update_check): for i in range(len(meetings)): if meetings[i] != update_check[i]: refresh = True break refresh = False else: refresh = True if refresh: for i in range(len(start_times)): t1 = start_times[i] t2 = end_times[i] if t1[1] == ':': h1 = int(t1[0]) m1 = int(t1[2:4]) start_time_y = time_y_coord(h1, m1) else: h1 = int(t1[0:2]) m1 = int(t1[3:5]) start_time_y = time_y_coord(h1, m1) if t2[1] == ':': h2 = int(t2[0]) m2 = int(t2[2:4]) end_time_y = time_y_coord(h2, m2) else: h2 = int(t2[0:2]) m2 = int(t2[3:5]) end_time_y = time_y_coord(h2, m2) meeting_y = ((start_time_y + end_time_y) // 2) - 7 erase_y = None if h1 != 12: if (h2 - h1) == 1: er_y = { 10: 128, 11: 192, 12: 256, 1: 319, 2: 383, 3: 447, 4: 511, 5: 575 } erase_y = er_y.get(h2, None) elif (h2 - h1) == 2: er_y = { 10: 128, 11: 128, 12: 192, 1: 256, 2: 319, 3: 383, 4: 447, 5: 511, 6: 575 } erase_y = er_y.get(h2, None) if erase_y is not None: drawblack.line((50, erase_y, 381, erase_y), fill=255) else: if h2 == 1: drawblack.line((50, y_one, 381, y_one), fill=255) elif h2 == 2: drawblack.line((50, y_two, 381, y_two), fill=255) ### Start Time Lines ### # 9am if start_time_y < 81 and start_time_y > 64: drawred.line((1, start_time_y, 9, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 9, start_time_y + 1), fill=0) drawred.line((41, start_time_y, 382, start_time_y), fill=0) drawred.line( (41, start_time_y + 1, 382, start_time_y + 1), fill=0) # 10am elif start_time_y < 145 and start_time_y > 128: drawred.line((1, start_time_y, 10, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 10, start_time_y + 1), fill=0) drawred.line((50, start_time_y, 382, start_time_y), fill=0) drawred.line( (50, start_time_y + 1, 382, start_time_y + 1), fill=0) # 11am elif start_time_y < 209 and start_time_y > 192: drawred.line((1, start_time_y, 10, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 10, start_time_y + 1), fill=0) drawred.line((50, start_time_y, 382, start_time_y), fill=0) drawred.line( (50, start_time_y + 1, 382, start_time_y + 1), fill=0) # 12pm elif start_time_y < 275 and start_time_y > 256: drawred.line((1, start_time_y, 10, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 10, start_time_y + 1), fill=0) drawred.line((50, start_time_y, 382, start_time_y), fill=0) drawred.line( (50, start_time_y + 1, 382, start_time_y + 1), fill=0) # 1pm elif start_time_y < 338 and start_time_y > 319: drawred.line((1, start_time_y, 10, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 10, start_time_y + 1), fill=0) drawred.line((41, start_time_y, 382, start_time_y), fill=0) drawred.line( (41, start_time_y + 1, 382, start_time_y + 1), fill=0) # 2pm elif start_time_y < 402 and start_time_y > 383: drawred.line((1, start_time_y, 9, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 9, start_time_y + 1), fill=0) drawred.line((41, start_time_y, 382, start_time_y), fill=0) drawred.line( (41, start_time_y + 1, 382, start_time_y + 1), fill=0) # 3pm elif start_time_y < 466 and start_time_y > 447: drawred.line((1, start_time_y, 9, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 9, start_time_y + 1), fill=0) drawred.line((41, start_time_y, 382, start_time_y), fill=0) drawred.line( (41, start_time_y + 1, 382, start_time_y + 1), fill=0) # 4pm elif start_time_y < 530 and start_time_y > 511: drawred.line((1, start_time_y, 8, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 8, start_time_y + 1), fill=0) drawred.line((41, start_time_y, 382, start_time_y), fill=0) drawred.line( (41, start_time_y + 1, 382, start_time_y + 1), fill=0) # 5pm elif start_time_y < 594 and start_time_y > 575: drawred.line((1, start_time_y, 9, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 9, start_time_y + 1), fill=0) drawred.line((41, start_time_y, 382, start_time_y), fill=0) drawred.line( (41, start_time_y + 1, 382, start_time_y + 1), fill=0) # 6pm elif start_time_y > 624: drawred.line((1, start_time_y, 9, start_time_y), fill=0) drawred.line( (1, start_time_y + 1, 9, start_time_y + 1), fill=0) drawred.line((41, start_time_y, 382, start_time_y), fill=0) drawred.line( (41, start_time_y + 1, 382, start_time_y + 1), fill=0) else: drawred.line((1, start_time_y, 382, start_time_y), fill=0) drawred.line( (1, (start_time_y + 1), 382, (start_time_y + 1)), fill=0) ### End Time Lines ### # 9am if end_time_y < 81 and end_time_y > 64: drawred.line((1, end_time_y, 9, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 9, end_time_y - 1), fill=0) drawred.line((41, end_time_y, 382, end_time_y), fill=0) drawred.line((41, end_time_y - 1, 382, end_time_y - 1), fill=0) # 10am elif end_time_y < 145 and end_time_y > 128: drawred.line((1, end_time_y, 10, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 10, end_time_y - 1), fill=0) drawred.line((50, end_time_y, 382, end_time_y), fill=0) drawred.line((50, end_time_y - 1, 382, end_time_y - 1), fill=0) # 11am elif end_time_y < 209 and end_time_y > 192: drawred.line((1, end_time_y, 10, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 10, end_time_y - 1), fill=0) drawred.line((50, end_time_y, 382, end_time_y), fill=0) drawred.line((50, end_time_y - 1, 382, end_time_y - 1), fill=0) # 12pm elif end_time_y < 275 and end_time_y > 256: drawred.line((1, end_time_y, 10, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 10, end_time_y - 1), fill=0) drawred.line((50, end_time_y, 382, end_time_y), fill=0) drawred.line((50, end_time_y - 1, 382, end_time_y - 1), fill=0) # 1pm elif end_time_y < 338 and end_time_y > 319: drawred.line((1, end_time_y, 10, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 10, end_time_y - 1), fill=0) drawred.line((41, end_time_y, 382, end_time_y), fill=0) drawred.line((41, end_time_y - 1, 382, end_time_y - 1), fill=0) # 2pm elif end_time_y < 402 and end_time_y > 383: drawred.line((1, end_time_y, 9, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 9, end_time_y - 1), fill=0) drawred.line((41, end_time_y, 382, end_time_y), fill=0) drawred.line((41, end_time_y - 1, 382, end_time_y - 1), fill=0) # 3pm elif end_time_y < 466 and end_time_y > 447: drawred.line((1, end_time_y, 9, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 9, end_time_y - 1), fill=0) drawred.line((41, end_time_y, 382, end_time_y), fill=0) drawred.line((41, end_time_y - 1, 382, end_time_y - 1), fill=0) # 4pm elif end_time_y < 530 and end_time_y > 511: drawred.line((1, end_time_y, 8, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 8, end_time_y - 1), fill=0) drawred.line((41, end_time_y, 382, end_time_y), fill=0) drawred.line((41, end_time_y - 1, 382, end_time_y - 1), fill=0) # 5pm elif end_time_y < 594 and end_time_y > 575: drawred.line((1, end_time_y, 9, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 9, end_time_y - 1), fill=0) drawred.line((41, end_time_y, 382, end_time_y), fill=0) drawred.line((41, end_time_y - 1, 382, end_time_y - 1), fill=0) # 6pm elif end_time_y > 624: drawred.line((1, end_time_y, 9, end_time_y), fill=0) drawred.line((1, end_time_y - 1, 9, end_time_y - 1), fill=0) drawred.line((41, end_time_y, 382, end_time_y), fill=0) drawred.line((41, end_time_y - 1, 382, end_time_y - 1), fill=0) else: drawred.line((1, end_time_y, 382, end_time_y), fill=0) drawred.line( (1, (end_time_y - 1), 382, (end_time_y - 1)), fill=0) # Left and right side borders for meetings drawred.line((0, start_time_y, 0, end_time_y), fill=0) drawred.line((1, start_time_y, 1, end_time_y), fill=0) drawred.line((2, start_time_y, 2, end_time_y), fill=0) drawred.line((383, start_time_y, 383, end_time_y), fill=0) drawred.line((382, start_time_y, 382, end_time_y), fill=0) drawred.line((381, start_time_y, 381, end_time_y), fill=0) if len(meetings[i]) <= 33: if h1 > 9 or h2 > 9: drawred.text((302, meeting_y), t1[:-3] + '-' + t2[:-3], font=font_time_small, fill=0) else: drawred.text((315, meeting_y), t1[:-3] + '-' + t2[:-3], font=font_time_small, fill=0) # Meeting Titles drawred.text((55, meeting_y), meetings[i], font=font_time_slot, fill=0) update_check = meetings epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) startup = False else: time.sleep(30) if startup: epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) startup = False except Exception as e: print('exception ' + str(e)) main()
def test_quickstart_wo_snapshot(capsys, project_id): quickstart.main(project_id) out, _ = capsys.readouterr() assert "WA" in out
def get_unread_messages(): messages = list_msgs_with_labels(quickstart.main()[1], 'me', 'UNREAD') message_ids = [message['id'] for message in messages] return message_ids
def test_quickstart_with_snapshot(capsys, project_id): quickstart.main(project_id, now_millis() - 5000) out, _ = capsys.readouterr() assert "WA" in out
mytext = line playtime2 = genratePlayTime(mytext) if playtime2 < playtime and playtime2 > datetime.datetime.now( ): playtime = playtime2 eventName = mytext[mytext.find('#') + 1:mytext.rfind('#')] profName = mytext[mytext.find('$') + 1:mytext.rfind('$')] location = mytext[mytext.find('@') + 1:mytext.rfind('@')] textToSpeech = genrateMessage(mytext, profName, location, eventName) else: continue if (checked): playSound(textToSpeech) if __name__ == "__main__": connected = connect() if (connected): quickstart.main() else: print("No internet connection available") data = [] threadRefresh = threading.Thread(target=refreshListOfEvents, daemon=True) threadRefresh.start() main()
from docx import Document from docx.shared import Pt from pprint import pprint import quickstart import datetime from datetime import datetime # gets data from the sheet data = quickstart.main()['values'] # custom variables for your document title_of_template_document = 'INSERT TITLE OF TEMPLATE DOCUMENT' row_identifier = 'INSERT IDENTIFIER IF YOU WANT TO USE ONLY CERTAIN ROWS' search_text = '__________________' count_of_items_to_replace = 6 # main runner for entry in data: if entry[2] == row_identifier: document = Document(title_of_template_document) # gets the specific data you need replacement_text_array = [entry[0], entry[1], entry[6], entry[3], entry[7], entry[2]] for i in range(count_of_items_to_replace): old_text = document.paragraphs[i+1].text new_text = old_text.replace(search_text, replacement_text_array[i]) document.paragraphs[i+1].text = new_text document.save('Document Title ' + replacement_text_array[0] + '.docx')
def mostrar_files_google_drive(): if __name__ == '__main__': quickstart.main()
#CREAR TABLA EN BASE DE DATOS cursor.execute( "CREATE TABLE tabla_archivos (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id), archivo VARCHAR(100),fecha_creacion VARCHAR(10) )" ) #ELIMINAR TABLA EN BASE DE DATOS #cursor.execute("DROP TABLE tabla_archivos") #MUESTRO ARCHIVOS DE GOOGLE DRIVE ##LISTA DE NOMBRES DE ARCHIVOS EN DRIVE file_names = [] ##LISTA DE DATETIME DE ARCHIVOS EN DRIVE file_createdTime = [] #LISTA CON TODOS LOS ARCHIVOS QUE VIENE DE LA FUNCION QUICKSTART files = quickstart.main() ##LLENO LAS LISTAS PREVIAMENTE CREADAS, CON LOS DATOS PROVENIENTES DE QUICKSTART for file in files: file_names.append('{0}'.format(file['name'])) for file in files: file_createdTime.append('{0}'.format(file['createdTime'])) #RECORTO LA FECHA i = -1 for file in file_createdTime: i = i + 1 file_createdTime[i] = file_createdTime[i][0:10] #ORDENO AMBAS LISTAS SEGUN FECHA def ordenar(x):
import csv import quickstart values = quickstart.main() #print(values) with open('names.csv', 'w') as csvfile: fieldnames = values[0] #print(fieldnames) writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() for x in range(1, len(values)): #print(values[x][0]) writer.writerow({ 'Timestamp': values[x][0], 'Email Address': values[x][1], 'Name': values[x][2], 'Date for Today\'s class': values[x][3], 'Did you attend the class?': values[x][4], 'Did you complete the assignments given.': values[x][5], 'Comments on the assigment given': values[x][6], 'Hackerrank Algorithm Score': values[x][7], 'Hackerrank Python Score':
def job(): # traverse all meeting room email account every 18 seconds # quickstart.main('suzhouhe.dat') # quickstart.main('dashijie.dat') quickstart.main('suzhouhe.dat')
from quickstart import main service = main() # Call the Gmail API results = service.users().labels().list(userId='me').execute() labels = results.get('labels', []) # if not labels: # print('No labels found.') # else: # print('Labels:') # for label in labels: # print(label['name']) # # if __name__ == '__main__': # main()
import json, os, requests from pprint import pprint import quickstart test_id = '' rflan_id = '' data = quickstart.main("main", '') # try: # data = data.decode('utf-8') # data = json.loads(data) # except (ValueError, AttributeError): # print("Data is not valid JSON") pprint(data) exit(0) with open(os.path.join(".", "config.json"), 'r') as f: config = json.load(f) base_url = "https://api.typeform.com" req = requests.post("{}/forms".format(base_url), data=data)
import quickstart import drive_download import sermon_overlay import drive_upload import drive_delete import time while True: try: item, service = quickstart.main() valid = True except: valid = False if valid: drive_download.download(item, service) valid = sermon_overlay.main() #succeed = True if valid: drive_upload.main() drive_delete.main(item, service) print("\n**********Completed Overlay**********") time.sleep(15)
def command(): command = input("Enter your command") if command == "view": quickstart.main() else: print("wrong entry")
qs.file_in_folder(service,name_video,id_folder,outsider_path) msg.attach(mail.file_send(name_video,outsider_path)) camera.close() text = msg.as_string() mail.send_email(server_mail,email_user,email_sender,password_sender,text) def create_folder_drive(service,mimeType,namefolder): flag, id_folder = qs.query_files(service,mimeType) if flag: print('Folder exists') else: id_folder = qs.create_folder(service,namefolder) return id_folder try: service = qs.main() id_folder = create_folder_drive(service,mimeType,name_folder) msg = mail.header(email_user,email_sender,subject,body) while True: pir.wait_for_motion() print('Motion detected') GPIO.output(PIN_LED,GPIO.HIGH) photo_camera(service,id_folder) pir.wait_for_no_motion() print('Wait for motion') GPIO.output(PIN_LED,GPIO.LOW) finally: print('This is the finally') pir.close()
""" try: message = service.users().messages().get(userId=user_id, id=msg_id, format='raw').execute() print('Message snippet: {}'.format(message['snippet'])) msg_str = base64.urlsafe_b64decode(message['raw'].encode('ASCII')) mime_msg = email.message_from_string(msg_str) return mime_msg except errors.HttpError as error: print('An error occurred: {}'.format(error)) def build_service(credentials): """Build a Gmail Service Object Args: credentials: OAuth 2.0 Credentials Returns: Gmail service object """ http = httplib2.Http() http = credentials.authorize(http) return build('gmail', 'v1', http=http) get_message(quickstart.main()[1], 'me', '160e3c6cf92364ba')