def go(self): if countdown.is_closed(): return set_color(window, *self.rgb) countdown.countdown( window, self.mins, count_session=self.count_session, and_then=self.and_then)
def get_tweet(TwitAPI, user_id_list): i = 0 for user_id in user_id_list: try: follow_tweet = TwitAPI.user_timeline(id=user_id) #for tweet in limit_handled(tweepy.Cursor(TwitAPI.user_timeline(screen_name=screen_name)).items()): #tweepy.process_page(tweet) for tweet in follow_tweet: # print tweet # print tweet.user.name # print tweet.user.screen_name # print tweet.text # print tweet.created_at # print tweet.id i = i + 1 print i tweet_info = { 'user_id': tweet.user.screen_name, 'tweet_id': tweet.id, 'time': tweet.created_at, 'sentiment': '0', 'text': "".join(tweet.text.split('\'')) } print tweet_info connect2sql.insert_twittertext(tweet_info) except tweepy.RateLimitError: print "sleep now" countdown.countdown(15 * 60) except tweepy.TweepError as e: print("Failed to run the command on that user, Skipping...") print e.reason
def sign_up(classes_in_cart): payloads = {} for workout in classes_in_cart: payloads[workout[1]] = { 'schedule_id': workout[2], 'class_id': workout[0], 'venue_id': workout[6], 'mode': 'confirm', 'user_id': 37181, 'passport_venue_attended': 0, 'passportType': 'CLASSPASS', 'passportUsersId': 16661, } today = datetime.combine(date.today(), time(16, 22, 00)) subject = "Classpass Signups Open" countdown(today, "ClassPass Signups Open") print('Classes are open! Signing up for classes now!') for class_name, class_payload in payloads.iteritems(): print('Signing up for class: {0}'.format(class_name)) _ = requests.post( signup_URL, data=class_payload, cookies=COOKIES, )
def sign_up(self): payloads = {} URL = "https://classpass.com/a/PassportReserveDialog" for workout in self.classes_in_cart: payloads[workout[3]] = { 'schedule_id': workout[0], 'class_id': workout[2], 'venue_id': workout[1], 'mode': 'confirm', 'user_id': 37181, 'passport_venue_attended': 0, 'passportType': 'CLASSPASS', 'passportUsersId': 16661, } today = datetime.combine(date.today(), time(12, 00, 30)) subject = "Classpass Signups Open" countdown(today, "ClassPass Signups Open") print('Classes are open! Signing up for classes now!') for class_name, class_payload in payloads.iteritems(): print('Signing up for class: {0}'.format(class_name)) _ = requests.post( URL, data=class_payload, cookies=COOKIES, ) sys.exit()
def main(classes): class_dict = import_classes_from_csv() payloads = generate_payloads(classes, class_dict) today = datetime.combine(date.today(), time(12, 00, 30)) subject = "Classpass Signups Open" countdown(today, subject) print('Classes are open! Signing up for classes now!') signup_for_class(payloads)
def limit_handled(cursor): while True: try: yield cursor.next() except tweepy.RateLimitError: print "sleep now" countdown.countdown(15 * 60) except tweepy.TweepError: print tweepy.TweepError
def main(): from argparse import ArgumentParser parser = ArgumentParser(description=( "Class pass automatic class signer-upper" )) today = datetime.combine(date.today(), time(12, 00, 01)) subject = "Classpass Signups Open" countdown(today, subject) print('Classes are open! Signing up for classes now!') signup_for_class()
def test_countdown(self): num = 25 result = countdown(num) self.assertEqual(result, [ 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ])
def test_all_in_minute_three(self): self.assertEquals(countdown('3:00'), 'R') self.assertEquals(countdown('3:01'), 'G') self.assertEquals(countdown('3:02'), 'R') self.assertEquals(countdown('3:03'), 'G') self.assertEquals(countdown('3:04'), 'R') for second in range(5, 60): self.assertEquals(countdown('3:' + two_digits(second)), 'G')
def learn(self): try: while True: self.__print_last_attempt() print("The password is: {}".format( colored(self.contents, "green"))) print("Your last attempt was: {}".format( colored(self.last_attempt, "red"))) try: countdown(1) except KeyboardInterrupt: pass clear() prompt = "Give in another try: " if self.correct == self.__size else "Polish it: " self.last_attempt = str(input(prompt)) clear() except KeyboardInterrupt: clear() print( colored("Saving this password to renew in the next session...", "yellow")) self.save()
def handle_message(event): if event.message.text == "おーいサボテン": result = replymsg.replymsg() line_bot_api.reply_message(event.reply_token, TextSendMessage(text=result)) elif event.message.text == "クソ野郎ちゃんは?": result = facilities.callkusoyarou2() txtmsg = replymsg.kusoyarou_saboten() line_bot_api.reply_message( event.reply_token, TextSendMessage(text=txtmsg, quick_reply=QuickReply(result))) elif event.message.text == "おーいクソ野郎ちゃん": result = kusoyarou.replymsg() line_bot_api.reply_message(event.reply_token, result) elif event.message.text == "そろそろ出かけようかな": result = facilities.facilities() line_bot_api.reply_message( event.reply_token, TextSendMessage(text="OK!どこに行く?", quick_reply=QuickReply(result))) elif event.message.text == "なんかしたい": result = facilities.nanikashitai() line_bot_api.reply_message( event.reply_token, TextSendMessage(text="OK!何しらべる?", quick_reply=QuickReply(result))) elif event.message.text == "今日はなんの日だっけ?": result1 = adalo.callapi() result2 = adalo.getmsg() line_bot_api.reply_message(event.reply_token, [result1, result2]) elif event.message.text == "そういえば令和市が終わるまであと何日?": line_bot_api.reply_message(event.reply_token, TextSendMessage("えっ?")) #使ってない elif event.message.text == "そういえば令和市が終わるまであと何日": result1 = countdown.countdown() line_bot_api.reply_message(event.reply_token, result1) elif event.message.text == "ホームページとかどこだっけ?": result = snsmenu.sns() line_bot_api.reply_message(event.reply_token, result) else: result = talkapi.talkapi(event.message.text) line_bot_api.reply_message(event.reply_token, result)
def CP_send(sched_id, venue_id, class_id, class_name, COOKIES): class_payload = { 'schedule_id': sched_id, 'class_id': class_id, 'venue_id': venue_id, 'mode': 'confirm', 'user_id': 37181, 'passport_venue_attended': 0, 'passportType': 'CLASSPASS', 'passportUsersId': 16661, } today = datetime.combine(date.today(), time(12, 00, 05)) subject = "ClassPass Signups Open" countdown(today, subject) print('Classes are open! Signing up for classes now!') print('Signing up for class: {0}'.format(class_name)) _ = requests.post( URL, data=class_payload, cookies=COOKIES, ) print('Request sent!')
def run(self,iterations): # TO DO: can we use countdown with "with"? or even better, somehow embed it in the for loop? C = countdown.countdown(iterations,100) for iter in range(iterations): C.status() # make a proposal for next sample proposed = self.proposer(self.current) # apply the stepping criterion self.current = self.stepper(self.current,proposed) if self.current is proposed: self.accepted += 1 # store the new sample self.samples.append(self.current.parlist(self.store)) self.N += 1 C.end()
def hello(): """Return a friendly HTTP greeting.""" results = () while not results or results[0].value != 24: (vals, target) = countdown.generate( 4, 24, num_large=0, replacement=True) results = tuple(countdown.countdown( vals, target, all_orders=True, all_subsets=False, use_pow=False)) return render_template( 'main.html', vals=' '.join(str(v) for v in vals), num=len(results), results='\n'.join(str(r) for r in results))
def test_all_in_minute_four(self): self.assertEquals(countdown('4:00'), 'R') self.assertEquals(countdown('4:01'), 'G') self.assertEquals(countdown('4:02'), 'R') self.assertEquals(countdown('4:03'), 'G') self.assertEquals(countdown('4:04'), 'R') self.assertEquals(countdown('4:05'), 'G') self.assertEquals(countdown('4:06'), 'R') for second in range(7, 30): self.assertEquals(countdown('4:' + two_digits(second)), 'G') self.assertEquals(countdown('4:30'), 'R') for second in range(31, 40): self.assertEquals(countdown('4:' + two_digits(second)), 'G') self.assertEquals(countdown('4:40'), 'R') for second in range(41, 50): self.assertEquals(countdown('4:' + two_digits(second)), 'G') self.assertEquals(countdown('4:50'), 'R') for second in range(50, 60): if second % 2 == 0: state = 'R' else: state = 'G' self.assertEquals(countdown('4:' + two_digits(second)), state)
raise ExcesoDeParametros else: if not(os.path.exists(sys.argv[1])): raise IOError else: archivo = open(sys.argv[1],'r') counter = 0 salida = open('%s_realizadas' % sys.argv[1],'a') salida.write("Labores realizadas a las %s el día %s:\n" % (time.strftime("%H:%M:%S"),time.strftime("%d-%m-%Y"))) for linea in archivo.readlines(): if not linea: break if (counter % 4 == 0) and (counter != 0): # Cada 4 pomodoros, hacer una pausa larga, si no, se hace pausa corta print "Haciendo pausa larga..." countdown.countdown(1200) # Pausa larga de 20 minutos elif counter != 0: print "Haciendo pausa corta..." countdown.countdown(300) # Pausa corta de 5 minutos tomython.pomodoro_inicio(linea) countdown.countdown(1500) # 25 minutos para desarrollar actividades tomython.pomodoro_termino(linea) salida.write(linea+" [x]\n") counter = counter + 1 archivo.close() salida.close() os.remove(sys.argv[1]) archivo_vacio = open(sys.argv[1],'w') archivo_vacio.close() except SinParametro, a:
def run(): cout_time = countdown(mins=minuitess.get(), secs=secondss.get())
# Simple pygame program from countdown import countdown from welcome import welcome from play import startTyping from ending import ending import pygame import time pygame.init() x = 1000 y = 700 screen = pygame.display.set_mode([x, y]) white = (255, 255, 255) grey = (220, 220, 220) black = (0, 0, 0) titleFont = pygame.font.Font('freesansbold.ttf', 36) title = titleFont.render("Type the following:", True, black, grey) titleRect = title.get_rect() titleRect.center = (x // 2, y // 8) welcome(black, grey, x, y, screen) countdown(black, grey, x, y, screen) check = True while check: wpm, totalNum, mistakes = startTyping(screen) check = ending(black, grey, x, y, screen, totalNum, mistakes, wpm)
gm.merge(gm.merge(grid_dict[m[0]], grid_dict[m[1]]), col)), gm.merge(grid_dict[s[0]], grid_dict[s[1]])) print(hms_grid_obj.grid_without_lines()) t = threading.Thread(target=display) t.start() #print(f"\n[*] Points: {len(hms_grid_obj.scat_plot)}") sleep(1) clear() # check end_at = (h, m) if int(var[0]) <= end_at[0]: v = int(var[0]) - int(now[0]) if v > hour: hour += 1 playsound('dash.wav') else: v = int(var[0]) - int(now[0]) if v < hour: hour += 1 playsound('dash.wav') if int(var[0]) == end_at[0] and int( var[1]) == end_at[1] - 1 and int(var[2]) >= 49: break countdown() playsound('sos.wav') sleep(1.5) clear()
#! /usr/bin/env python3 # -*- coding: utf-8; -*- '''A module testing concurrency and parallelism using some simple countdowns.''' __author__ = 'Russel Winder' __date__ = '2009-11-27' __version__ = '1.0' __copyright__ = 'Copyright © 2009 Russel Winder' __licence__ = 'GNU Public Licence (GPL) v3' import multiprocessing import time import countdown if __name__ == '__main__': startTime = time.time() for i in range(8): countdown.countdown(i, 5) print('Elapse time = {}'.format(time.time() - startTime))
def run_script(self, num, *args): t = countdown.countdown(*args) fp = open('countdown%s.log' % num, 'w') fp.write(t + '\n') fp.close()
NAMEFONT = ("arial", 40, False, (255, 255, 0)) # These positions represent the top / center position of the days/hrs/mins/sec based upon 1920x1080 screen TIMER_LINE = 600 LEGEND_LINE = 880 TIMER_X = [420, 750, 1120, 1490] TIMER_Y = [TIMER_LINE, TIMER_LINE, TIMER_LINE, TIMER_LINE] LEGEND_X = [420, 750, 1120, 1490] LEGEND_Y = [LEGEND_LINE, LEGEND_LINE, LEGEND_LINE, LEGEND_LINE] countdown = countdown( pys, \ targettime = TARGET_TIME, \ targetname = TARGET_NAME, \ timerfont = TIMERFONT, \ legendfont = LEGENDFONT, \ namefont = NAMEFONT, \ timerx = TIMER_X, \ timery = TIMER_Y, \ legendx = LEGEND_X, \ legendy = LEGEND_Y, \ cd_JSON = 'http://issabove.pythonanywhere.com/static/crew1.txt', \ displayname = False ) pre = "crew1/" countdown.videos.append(pre + "crew1.mp4") countdown.fullscreenvideo = True while True: #datetime.datetime.utcnow() < countdown.target_time : pys.screen.fill((0, 0, 0)) pys.screen.blit(banners[current_banner].surface, (0, 0))
def cd(): return countdown()
def start_bot(): # Opening main page while True: try: driver = createBrowser() os.system('cls' if os.name == 'nt' else 'clear') print("Ouverture de la page ...") driver.get('https://freebitco.in/') acp_api_send_request(driver, 'setOptions', {'options': { 'antiCaptchaApiKey': acapi }}) break except: print('Erreur, ré-ouverture...') driver.quit() sleep(5) continue handles_before = driver.window_handles # Accept cookies while True: try: WebDriverWait(driver, 60).until( EC.presence_of_element_located( (By.CLASS_NAME, 'cc_btn_accept_all'))) print('Fermeture du popup des cookies') driver.execute_script( """document.querySelector("a.cc_btn.cc_btn_accept_all").click()""" ) break except: print('Erreur cookies') break # Close notifications popup while True: try: WebDriverWait(driver, 15).until( EC.presence_of_element_located( (By.CLASS_NAME, 'pushpad_deny_button'))) print('Fermeture du popup notifications') driver.execute_script( """document.querySelector("div.pushpad_deny_button").click()""" ) break except: print('Erreur popup notifications') break while True: try: driver.execute_script( """document.querySelector("li.login_menu_button").click();""") print('Ouverture de la page de connexion') break except: print("Erreur lors de l'ouverture page de connexion") pass sleep(1) # Fill login form while True: try: print('Saisie de l\'utilisateur') input_username = driver.find_element_by_name('btc_address') input_username.send_keys(username) sleep(1) print('Saisie du mot de passe') input_password = driver.find_element_by_id('login_form_password') input_password.send_keys(password) sleep(1) print('Envoi du formulaire de connexion') login_btn = driver.find_element_by_id('login_button') login_btn.click() break except: print("Erreur lors du formulaire de connexion") break # Wait page to end loading while True: try: page_loaded = WebDriverWait(driver, 60).until( EC.presence_of_element_located( (By.ID, 'free_play_form_button'))) break except: print( "Le chargement de la page a mis plus de 1 minute, peut être un problème lié au site." ) pass # Scroll and click on recaptcha while True: try: driver.execute_script( """window.scrollTo(0, document.body.scrollHeight);""") WebDriverWait(driver, 10).until( EC.frame_to_be_available_and_switch_to_it(( By.XPATH, "/html/body/div[2]/div/div/div[8]/div[2]/div/div[2]/div[2]/form/div/div/div[1]/iframe" ))) WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.XPATH, "//span[@id='recaptcha-anchor']"))).click() break except: print('Erreur lors du clicque sur le recaptcha') break sleep(1) while True: try: load_recaptcha = WebDriverWait(driver, 300).until( EC.invisibility_of_element_located( (By.CLASS_NAME, 'recaptcha-checkbox-spinner'))) driver.switch_to.default_content() challenge = WebDriverWait(driver, 30).until( EC.presence_of_element_located((By.XPATH, '/html/body/div'))) if challenge.is_displayed(): print('Lancement de la résolution du captcha') sleep(1) driver.switch_to.default_content() ActionChains(driver).send_keys(Keys.ESCAPE).perform() element = WebDriverWait(driver, 300).until( EC.presence_of_element_located( (By.CLASS_NAME, 'solved_flag'))) else: driver.switch_to.default_content() element = WebDriverWait(driver, 300).until( EC.presence_of_element_located( (By.CLASS_NAME, 'solved_flag'))) # No Anti-Captcha Use driver.switch_to.default_content() break except: print( "Le captcha a mis plus de 5 minutes à être résolu, peut être un problème lié au site." ) sleep(2) driver.quit() sleep(5) start_bot() print("Captcha résolu !") sleep(1) while True: try: roll_btn = WebDriverWait(driver, 60).until( EC.presence_of_element_located( (By.ID, 'free_play_form_button'))) roll_btn.click() print("Fin du roll !") break except: print("Impossible de trouver le bouton de roll") sleep(2) driver.quit() sleep(5) start_bot() sleep(1) driver.quit() print("Il est temps d'attendre 1h00") print('Temps restant :') countdown(mins=60, secs=00) sleep(2)
def test_minute_five_and_so_on(self): for minute in range(5, 10): for second in range(60): self.assertEquals(countdown('%02d:%02d' % (minute, second)), 'R')
def test_all_in_minute_two(self): self.assertEquals(countdown('2:00'), 'R') self.assertEquals(countdown('2:01'), 'G') self.assertEquals(countdown('2:02'), 'R') for second in range(3, 60): self.assertEquals(countdown('2:' + two_digits(second)), 'G')
def test_all_in_minute_zero(self): self.assertEquals(countdown('0:00'), 'G') for second in range(1, 60): self.assertEquals(countdown('0:' + two_digits(second)), 'G')
def waktumundur(): menit = 0 detik = 5 countdown(menit, detik)
NAMEFONT = ("arial", 40, False, (255, 255, 0)) # These positions represent the top / center position of the days/hrs/mins/sec based upon 1920x1080 screen TIMER_LINE = 610 LEGEND_LINE = 890 TIMER_X = [420, 750, 1120, 1490] TIMER_Y = [TIMER_LINE, TIMER_LINE, TIMER_LINE, TIMER_LINE] LEGEND_X = [420, 750, 1120, 1490] LEGEND_Y = [LEGEND_LINE, LEGEND_LINE, LEGEND_LINE, LEGEND_LINE] countdown = countdown( pys, \ targettime = TARGET_TIME, \ targetname = TARGET_NAME, \ timerfont = TIMERFONT, \ legendfont = LEGENDFONT, \ namefont = NAMEFONT, \ timerx = TIMER_X, \ timery = TIMER_Y, \ legendx = LEGEND_X, \ legendy = LEGEND_Y, \ displayname = False ) countdown.fullscreenvideo = True countdown.videos.append("VID-20200627-WA0038.mp4") countdown.videos.append("Sarah Al Amiri Jouney.mp4") countdown.videos.append("Hazza Interview with YAO.mp4") countdown.videos.append("01HQ-small.mp4") while True: pys.screen.fill((0, 0, 0))
def test_countdown(self): """Note that all results are positive""" self.assertEqual(countdown.countdown("16:00:00", "6:00"), "14:00:00") self.assertEqual(countdown.countdown("6:00:00", "16:00"), "10:00:00")
# Book Buddy # Author: R. # Reading timer for a random selection of books. # 12-1-2020 # Requirments # https://gitea.com/chopin42/countdown > pip install countdown-timer # https://github.com/jithurjacob/Windows-10-Toast-Notifications > pip install win10toast import random from countdown import countdown from sys import platform from win10toast import ToastNotifier toaster = ToastNotifier() a = [] with open("topics.txt", "r") as f: a = f.readlines() print("Let's read a good book, how about?:",random.choice(a)), input("Press Enter to Start timer") countdown(30), if platform == "win32": toaster.show_toast("Finished!", "Well done, have a Good Day!", threaded=True, icon_path=None, duration=3) # 4 seconds #else: # print("Finished!, Well done, have a Good Day!")