Beispiel #1
0
def HRRN(procs, pTime): #Highest Response Ratio Next

    readyQ = list()
    sched = list() #printing output list
    timeU = 0

    while (len(readyQ) > 0) or (len(procs) > timeU):

        if(timeU < len(procs)): #reads input into queue every time unit until out of processes to sim real time input
            readyQ.append(procs[timeU])

        if(len(readyQ) > 0):

            highRR = max( (((proc[2]-proc[1])+proc[1])/proc[1] ) for proc in readyQ) #find process with HRR

            for i in readyQ:
                if( (((i[2]-i[1])+i[1])/i[1]) == highRR): #finds that process in queue

                    sched.append(i[0])
                    temp = (i[0], i[1], i[2]-1)
                    readyQ.remove(i) #\
                                      #>removes current process from queue and adds it back if it has time remaining
                    if(temp[2] > 0): #/
                        readyQ.append(temp)

                    break

        timeU +=1
        pause.until(pTime + (timeU*1.03)) #for synchronizing printing
        print('HHRN:     ' + str(sched))
Beispiel #2
0
	def run(self):
		"""  
		clac clac clac
		"""	
		while True:

			self.extract_data()
			
			# fetch credit stuff
			self.fetch_credit()

			# fetch ru menu stuff
			#self.food_stuff()

			# Start talking with everybody
				# Todo

			# at time t : solve
				# Todo

			# Send result to everybody
				# Todo

			#TODO : pause until demain
			now =  datetime.date.today()
			pause.until(datetime.datetime(now.year, now.month, now.day+1, 10, 30))
Beispiel #3
0
def STR(procs, pTime): #Shortest Time Remaining

    readyQ = list()
    sched = list() #printing output list
    timeU = 0

    while (len(readyQ) > 0) or (len(procs) > timeU):

        if(timeU < len(procs)): #reads input into queue every time unit until out of processes to sim real time input
            readyQ.append(procs[timeU])

        if(len(readyQ) > 0):

            lowTR = min(proc[2] for proc in readyQ) #find process with least time remaining

            for i in readyQ:
                if(i[2] == lowTR): #finds that process in queue

                    sched.append(i[0])
                    temp = (i[0], i[1], i[2]-1)
                    readyQ.remove(i) #\
                                      #>removes current process from queue and adds it back if it has time remaining
                    if(temp[2] > 0): #/
                        readyQ.append(temp)

                    break #breaks free of loop after arbitrary first find

        timeU +=1
        pause.until(pTime + (timeU*1.02)) #for synchronizing printing
        print('STR:      ' + str(sched))
Beispiel #4
0
def FCFS(procs, pTime):# First Come First Serve

    readyQ = list()
    sched = list() #printing output list
    procNum = 0
    timeU = 0
    running = True
    curProcTime = procs[0][1]

    while (procNum < len(procs)-1):

        if(timeU < len(procs)): #reads input into queue every time unit until out of processes to sim real time input
            readyQ.append(procs[timeU])

        if(not running): #if the last process in the queue has ended- start the next one
            if(procNum < len(readyQ)-1):
                curProcTime = readyQ[procNum+1][1]
            procNum +=1
            running = True

        curProcTime -=1

        if(curProcTime == 0): #checks to see if the last process is done 'running'
            running = False

        if(procNum < len(readyQ)): #adds to list of processes to be printed
            sched.append(readyQ[procNum][0])

        timeU +=1
        pause.until(pTime + timeU) #for synchronizing printing
        print('\nTime Unit ' + str(timeU) + '\n')
        print('INPUTS:   ' + str(readyQ))
        print('FCFS:     ' + str(sched))
def wait_for_friends_list_reset(oauth):
	(reset,limit,remaining) = get_resetinfo_friends_list(oauth)
	current_time = int(time.time())
	reset_time = int(reset)

	if(reset_time > current_time):
		print 'current time = ',current_time,'reset_time = ',reset_time
		pause.until(reset_time) # wait upto that time plus 1 minute

	return
Beispiel #6
0
def wait(nextping):
    '''Sleep till the next ping.

    If available, we will use the pause library to get better precision,
    otherwise we'll wait just a few seconds in case the machine is suspended.
    '''
    if pause:
        pause.until(nextping)
    else:
        time.sleep(util.clip(nextping - time.time(), 0, 2))
Beispiel #7
0
def start_audit(**kwargs):
    now = datetime.datetime.now()
    schedule = kwargs['schedule']
    cron = croniter.croniter(schedule, now)
    next_iteration = cron.get_next(datetime.datetime)
    while True:
        LOG.warning('Next call at %s', next_iteration)
        pause.until(next_iteration)
        run_audit(**kwargs)
        next_iteration = cron.get_next(datetime.datetime)
Beispiel #8
0
    def test_timestamp(self):
        """ test_timestamp
        Test 6 seconds, with a unix timestamp
        """
        toTime = time.time() + 6
        start = time.time()
        pause.until(toTime)

        # True if it came within 0.1 of a second
        end = time.time()
        diff = int(end - start)
        self.assertEqual(diff, 6)
Beispiel #9
0
    def test_datetime(self):
        """ test_datetime
        Test 7 seconds, with a datetime object
        """
        startDate = datetime.now()
        toDate = startDate + timedelta(seconds=7)

        pause.until(toDate)
        now = datetime.now()

        # True if at least 7 seconds has passed
        diff = now - startDate
        self.assertEqual(diff.seconds, 7)
Beispiel #10
0
 def start_serializer(self):
     schedule = self.serializer_schedule
     now = datetime.datetime.now()
     cron = croniter.croniter(schedule, now)
     next_iteration = cron.get_next(datetime.datetime)
     while self._state == states.ENABLED:
         LOG.info('It is %s, next serializer at %s', now, next_iteration)
         pause.until(next_iteration)
         now = datetime.datetime.now()
         next_iteration = cron.get_next(datetime.datetime)
         if self._state == states.ENABLED:
             try:
                 self.run_serializer(next_iteration, now)
             except exceptions.SerializerException:
                 LOG.exception("Could not run serializer")
Beispiel #11
0
    def test_past(self):
        """ test_past
        Test a time that has already passed
        """

        # Using seconds()
        start = time.time()
        pause.seconds(-5)
        end = time.time()
        self.assertEqual(int(end - start), 0)

        # Using until()
        start = time.time()
        pause.until(time.time() - 10)
        end = time.time()
        self.assertEqual(int(end - start), 0)
Beispiel #12
0
def main():
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                        datefmt='%m-%d %H:%M')
    logger = logging.getLogger('main')
    logger.info('starting up')

    ebooks = EbooksText(Config)

    if not validate_run_times(Config):
        logger.error('invalid run times specified')
        sys.exit(1)

    while True:
        ebooks.update()
        peer = TwitterPeer(Config)
        conv = Conversation(ebooks, peer)

        next_run = next_run_time(Config)
        logger.info('sleeping until {0}'.format(next_run))
        pause.until(next_run)
        conv.talk()
Beispiel #13
0
def RR(procs, pTime): #Round Robin

    readyQ = list()
    sched = list() #printing output list
    timeQ = 0 #time quantum starts at zero and inc by 1

    while (len(readyQ) > 0) or (len(procs) > timeQ):

        if(timeQ < len(procs)): #reads input into queue every time unit until out of processes to sim real time input
            readyQ.insert(0, procs[timeQ])

        if(len(readyQ) > 0): #adds next process in queue to the print list if queue is not empty

            sched.append(readyQ[0][0])
            temp = (readyQ[0][0], readyQ[0][1], readyQ[0][2]-1)
            readyQ.pop(0)     #\
                               #>removes current process from queue and adds it to the end if burst time not= 0
            if(temp[2] != 0): #/
                readyQ.append(temp)

        timeQ +=1
        pause.until(pTime + (timeQ*1.01)) #for synchronizing printing
        print('RR:       ' + str(sched))
Beispiel #14
0
 def setup_audit(self, execution_time, audit_list):
     try:
         pause.until(execution_time)
         # Only proceed if engine is running, i.e in enabled state.
         if self._state != states.ENABLED:
             LOG.info("%s is disabled, so not running audits at %s",
                      self.name, execution_time)
             return
         LOG.info("Time: %s, Starting %s", execution_time, audit_list)
         audit_futures = []
         for audit in audit_list:
             audit_name = audit['name']
             audit_cfg = self._backend_driver.audit_cfg_from_name(
                 audit_name)
             future = self.executor.submit(self.run_audit,
                                           audit_name=audit_name,
                                           **audit_cfg)
             audit_futures.append(future)
         if audit_futures:
             self.futures.extend(audit_futures)
     except Exception:
         LOG.exception("Could not run all audits in %s at %s",
                       audit_list, execution_time)
def real_time_electricity_simulator(sensor, curve, period, send_span):
    """Real time electricity tick sensor simulator.
    This simulator will mimic a real tick sensor.
    Output from this sensor will be a sinus wave.
    sensor - instance of an ElectricityTickSensor
    mean - mean value for the sinus wave (time between ticks in seconds)
    span - peak to peak distance (seconds)
    period - time span in seconds for full sinus wave
    send_span - time span in seconds between send to web service
    """

    print "Starting simulator"
    print "------------------------------"
    print "Type: Electricity Tick Sensor"
    print "Max: %f sec" % max(curve)
    print "Min: %f sec" % min(curve)
    print "Period: %i sec" % period
    print "Send Interval: %i" % send_span
    print "-----------------------------"
    print

    t = time()
    last_send= t
    while True:
        i = get_sin_index(t, period, len(curve))
        power = curve[i]
        diff = sensor.convert_to_time(power)
        t += diff
        pause.until(t)
        print "tick time: " + str(diff)
        print "Current load: " + str(power)
        sensor.add_value(power)

        if time() - last_send >= send_span:
            send_test_data(sensor)
            last_send = time()
Beispiel #16
0
def start_capture(PHASE=NAUTICAL):
	# Make a note in the log that we're starting a new run:
	logdiv("=")
	logmsg("Starting new image run at: " + str_local(datetime.now()))	

	# Declare global variables
	global WAIT_BETWEEN, EXPOSURE_TIME, GAIN, GAMMA, LATITUDE, LONGITUDE, CAMERA, USE_PUSHOVER

	# Define a few key variables
	[ START_TIME, END_TIME ] = sunpos.twilight_time(PHASE, LATITUDE, LONGITUDE, datetime.utcnow())		# When to start and finish taking images
	
	while START_TIME is None:									# If sun is always up, fallback one twilight phase
		logmsg("Selected twilight phase does not occur for this location / date.  Falling back to earlier twilight.")
		PHASE = PHASE - 1
		if PHASE < 0:
			logdiv('*')
			logmsg('ERROR: sun always above horizon - cannot set start time.  Exiting')
			logdiv('*')
			raise RuntimeError('Error: sun always above horizon - cannot set start time.')
		[ START_TIME, END_TIME ] = sunpos.twilight_time(PHASE, LATITUDE, LONGITUDE, datetime.utcnow())
	
	duration = END_TIME - START_TIME
	duration_hours = duration.seconds // 3600
	duration_minutes = duration.seconds // 60 % 60

	# WAIT_BETWEEN = 0.1											# Seconds to wait between images
	# EXPOSURE_TIME = 30											# Exposure time in seconds
	# GAIN = 200													# Camera gain setting
	# GAMMA = 50													# Image gamma

	TONIGHT = START_TIME.strftime("%Y%m%d")						# Tonight's date
	NIGHTDIR = BASEDIR + TONIGHT + "/"							# Base directory for images 
	if not os.path.exists(NIGHTDIR):							# Make sure the directory exists, otherwise create it
		os.makedirs(NIGHTDIR)
	LOGFILE = NIGHTDIR + "capture_log_" + TONIGHT + ".log"		# Set up the logging for tonight

	logmsg("Capturing images to folder: " + NIGHTDIR)
	
	# Initialize the camera:
	if CAMERA is None:
		CAMERA = skycam.initialize()
	skycam.set_controls(GAIN, GAMMA)

	# Wait until start of twilight and then start capturing images:
	logdiv("-",LOGFILE)
	logmsg("Exposure = " + str(EXPOSURE_TIME) + " | Gain = " + str(GAIN) + " | Gamma = " + str(GAMMA), LOGFILE)
	logmsg("Current time is     :  " + str_local(datetime.now()), LOGFILE)
	logmsg("Waiting until       :  " + str_local(START_TIME), LOGFILE)
	logmsg("Imaging will end at :  " + str_local(END_TIME), LOGFILE)
	logmsg("Total Duration is   :  " + str(duration_hours) + " hours " + str(duration_minutes) + " minutes", LOGFILE)
	logdiv("-",LOGFILE)

	if USE_PUSHOVER:
		title = "Ready For Next Sequence"
		message = "SkyCam is online and will begin capture at " + START_TIME.strftime("%H:%M %d-%b-%Y")
		sendPushoverAlert(title, message)

	pause.until(START_TIME)						
	
	if USE_PUSHOVER:
		title = "Starting Image Acquisition"
		message = "SkyCam is capturing images.\n\nImage capture will finish at " + END_TIME.strftime("%H:%M %d-%b-%Y")
		sendPushoverAlert(title, message)
	
	while datetime.now() < END_TIME:
		now = datetime.now()
		filename = name_local(now) + FILE_EXT
		skycam.capture(long(EXPOSURE_TIME * 1e6), NIGHTDIR + filename) 
		logmsg("Captured image: " + filename, LOGFILE)
		pause.seconds(WAIT_BETWEEN)

	logmsg("Finished capturing images", LOGFILE)
	logdiv("-",LOGFILE)
	LOGFILE = None

	data = OrderedDict( [
		   	( "start", START_TIME ),
			( "finish", END_TIME ),
			( "exposure", EXPOSURE_TIME),
			( "gain", GAIN ),
			( "gamma", GAMMA ),
			( "interval", WAIT_BETWEEN ),
			( "latitude", LATITUDE ),
			( "longitude", LONGITUDE ),
			( "create_timelapse", CREATE_TIMELAPSE),
			( "create_startrails", CREATE_STARTRAILS),
			( "upload_server", REMOTE_SERVER),
			( "upload_path", REMOTE_PATH),
			( "remote_command", REMOTE_COMMAND),
			( "clean_up_folders", CLEAN_UP),
			( "days_to_keep", DAYS_TO_KEEP)  ],)
	store_data(data, "capture_settings.json", NIGHTDIR)

	return NIGHTDIR
Beispiel #17
0
def main():
	global LOCALTZ, BASEDIR, LATITUDE, LONGITUDE, EXPOSURE_TIME, GAIN, GAMMA, WAIT_BETWEEN, PHASE, FILE_EXT
	global CREATE_TIMELAPSE, TIMELAPSE_FPS,CREATE_STARTRAILS, REMOTE_SERVER, REMOTE_PATH, REMOTE_COMMAND, USE_PUSHOVER
	global CLEAN_UP, DAYS_TO_KEEP

	load_settings()

	while True:
		NIGHTDIR = start_capture()
		[target_dir, padding] = sort_files(NIGHTDIR)
		night_path = os.path.basename(os.path.normpath(NIGHTDIR))
		
		# If no remote server is set, then generate the timelapse on local machine and leave it here
		if REMOTE_SERVER is None and CREATE_TIMELAPSE:				
			timelapse = generate_timelapse(target_dir, TIMELAPSE_FPS)

		# If remote server is set and we have no remote command, upload all files after generating timelapse (if we want one)
		elif REMOTE_COMMAND is None:								
			if CREATE_TIMELAPSE: timelapse = generate_timelapse(target_dir, TIMELAPSE_FPS)
			os.system("rsync -aq " + NIGHTDIR + "/* " + REMOTE_SERVER + ":" + REMOTE_PATH + "/" + night_path)

		# If remote server is set and we have a remote command, upload to server and generate timelapse on remote machine (if we want one)	
		else:														
			os.system("rsync -aq " + NIGHTDIR + "/* " + REMOTE_SERVER + ":" + REMOTE_PATH + "/" + night_path)
			command = "ssh " + REMOTE_SERVER + " '" + REMOTE_COMMAND + " " + REMOTE_PATH + "/" + night_path +"' " + TIMELAPSE_FPS
			if CREATE_TIMELAPSE: os.system(command)
		

		# Generate Star Trail image if desired and sync to remote server:
		file_pattern = ""
		if CREATE_STARTRAILS:
			for i in range(padding):
				file_pattern = file_pattern + "[0-9]"
			file_pattern = file_pattern + ".jpg"
			star_trails_file = "star_trails_" + night_path + ".jpg"

			star_trails(NIGHTDIR, star_trails_file, "jpg", file_pattern)
			if not REMOTE_SERVER is None:
				os.system("rsync -aq " + NIGHTDIR + "/" + star_trails_file + " " + REMOTE_SERVER + ":" + REMOTE_PATH + "/" + night_path)

		if USE_PUSHOVER:
			title = "SkyCam Sequence Complete"
			message = "Image capture is complete for " + night_path + " at " + datetime.now().strftime("%H:%M %d-%b-%Y")
			if REMOTE_SERVER: message = message + "\nFiles have been uploaded to:" + REMOTE_SERVER + ":" + REMOTE_PATH + "/" + night_path
			sendPushoverAlert(title, message)


		# Purge subfolders older than specified numbers of days:
		if CLEAN_UP:
			logdiv("=")
			logmsg("Purging folders older than " + str(DAYS_TO_KEEP) + " days.")
			purgeFolders(BASEDIR, DAYS_TO_KEEP)


		# Pause for a while before starting another loop.
		# Workaround for issue with sunrise / sunset calculation in sunpos that causes repeated loops if calculation is run before sunrise
		next_sunset = LOCALTZ.localize(sunpos.next_sunset(LATITUDE, LONGITUDE))
		logdiv("-")
		logmsg("Run complete. Next sunset is at: " + str_local(next_sunset))
		logmsg("Next run will set up at: " + str_local(next_sunset - timedelta(minutes=30)))
		logdiv("-")
		pause.until(next_sunset - timedelta(minutes=30))
Beispiel #18
0
        if val_type is str:
            curr_page = 1
            while True:
                filename = string_clean(today + '_' + cat + '_' + sub_cat_1 +
                                        '_' + sub_cat_1_links + '.html')
                link_unfiltered = url_base + sub_cat_1_links
                params_len = len(parse_qs(urlparse(link_unfiltered).query))
                url = ''
                if params_len > 0:
                    url = link_unfiltered + '&page='
                else:
                    url = link_unfiltered + '?page='
                url = url + str(curr_page)
                if grab_products(url,
                                 filename,
                                 cat=cat,
                                 subcat1=sub_cat_1,
                                 subcat2=''):
                    break
                curr_page = curr_page + 1

os.chdir(html_path)
zipcommand = "tar -cvzf " + project_name + today + ".tar.gz *" + today + "* --remove-files"
os.system(zipcommand)
print(project_name, "done", today)
#when downloading starts e.g. 1 am
hour_start = 5
pause.until(
    int(int(time.time()) / 60 / 60 / 24) * 60 * 60 * 24 + 60 * 60 *
    (24 + hour_start) + random.randint(1, 60) * 60)
    except NoSuchElementException:
        return False
    return True


if __name__ == "__main__":
    if(day_name != 'Saturday' and day_name != 'Sunday'):
        driver = browser()
        wait = webdriver.support.ui.WebDriverWait(driver, 5)
        driver.execute_script("document.body.style.zoom='50%'")
        startTime = list(map(int, startTime.split()))
        endTime = list(map(int, endTime.split()))
        extended_pause = list(map(int, extended_pause.split()))
        print(
            f"Waiting until Meet start time [{startTime[-3]:02}:{startTime[-2]:02}:{startTime[-1]:02}]...")
        pause.until(datetime(*startTime))
        login() #! it will login to google meet.
        try:
            meet_redirect() #! it will redirect to google meet site.
            while(check_exists_by_css("[aria-label='Chat with everyone']") != True):
                meet_redirect()
            send_roll() #! it will click on chat btn
            print("You Have Joined class at " + datetime.now().time().strftime("%H:%M:%S"))
            driver.execute_script("document.body.style.zoom='80%'")
            for i in range(1000):
                if(datetime.now().strftime("%H:%M:%S") < '09:55:00'): #! Dont change it if we are same (u know what i mean) otherwise you can change it accordingly
                    send_roll_direct() #! it will send message to chat.
                    sleep(180)
                else:
                    break
            print(
Beispiel #20
0
def wait_till_time(time=GO_TIME):
    print("Waiting until go time...")
    pause.until(time)
Beispiel #21
0
    tii = find_class()[1]
    t = tii.split(':')
    tim = t[0] + ':' + str(int(t[1]) + 20)
    timee = str(datetime.datetime.now().time()).split(':')
    ti = timee[0] + ':' + timee[1]
    print(ti)
    print(tim)


timee = str(datetime.datetime.now().time()).split(':')
ti = timee[0] + ':' + timee[1]
b = datetime.datetime.now()
a = datetime.datetime.strptime('08:35', '%H:%M')

if ti < '08:30':
    pause.until(datetime.datetime(b.year, b.month, b.day, a.hour, a.minute))

while True:
    clss = find_class()[0]
    tim = find_class()[1]
    q = datetime.datetime.now()
    timee = str(q.time()).split(':')
    ti = timee[0] + ':' + timee[1]
    a = datetime.datetime.strptime(tim, '%H:%M')
    b = datetime.datetime(q.year, q.month, q.day, a.hour, a.minute)

    if ti < tim:
        if clss in xtra:
            print("gommeet")
            gomet(goomeet[clss])
        else:
Beispiel #22
0
# Get actual date information and times for tomorrow's sunrise
dTom = datetime.date.today() #+ datetime.timedelta(days=1)
sun = location.sun(local=True, date=dTom)

# May want to subtract some time, get the before the actual sunrise
dt = sun['sunrise'] - datetime.timedelta(minutes=30)
print(sun['sunrise'])
print(dt)

#Temporary test to make sure everything works
# dt = datetime.datetime.now() + datetime.timedelta(seconds=10)
# print(dt)

# Get files in folder to get next filename
x = int(os.popen('ls "/home/pi/Pictures/pycam/" | wc -l').read())

print(x)
until(dt)
os.system('sudo killall gvfs-gphoto2-volume-monitor')
for i in range(80):
    if i < 9 and i > 0:
        time.sleep(180)
    elif i == 9:
        time.sleep(150)
    elif i > 9:
        time.sleep(10)
    print(datetime.datetime.now())
    os.system('sudo gphoto2 --capture-image-and-download --filename "/home/pi/Pictures/pycam/pic' + str(i + x) + '.jpg"')

Beispiel #23
0
    intf,
    # match the first OUT endpoint
    custom_match = \
    lambda e: \
        usb.util.endpoint_direction(e.bEndpointAddress) == \
        usb.util.ENDPOINT_OUT)

im = Image.open(sys.argv[1])
while True:
    for frame in range(0, im.n_frames):
        im.seek(frame)
        time = datetime.datetime.now()
        sleep_until = datetime.datetime.now() + datetime.timedelta(
            0, 0, 0, im.info['duration'])
        im_s = im.convert("RGB")

        data = struct.pack("<HHHH", 0, 0, im.width, im.height)
        dev.ctrl_transfer(usb.util.CTRL_RECIPIENT_INTERFACE
                          | usb.util.CTRL_TYPE_VENDOR | usb.util.CTRL_OUT,
                          1,
                          data_or_wLength=data)

        data = []
        for r, g, b in im_s.getdata():
            color = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
            data.extend(struct.pack(">H", color))

        ep.write(data)
        print(datetime.datetime.now() - time)
        pause.until(sleep_until)
Beispiel #24
0
def get_google_request(words, project, domain, start_status, start_index,
                       start):
    results = []
    api_keys = get_txt_data('api_keys')
    api_keys = [x for x in api_keys if x != '']

    # location = "Ukraine"
    siteSearchFilter = "i"
    cse_key = "008008521178205893081:w7ksepj1jro"
    # cse_key = "017576662512468239146:omuauf_lfve"
    pbar = tqdm(total=len(api_keys), desc="Google Web Requests")

    req_keywords, or_kywrds = words
    required_keyword = [
        "\"" + '\" \"'.join(req_keywords) + "\"", " ".join(req_keywords)
    ]
    or_keyword = ["\"" + '\" \"'.join(or_kywrds) + "\"", " ".join(or_kywrds)]
    # required_keywords = urllib.parse.quote(required_keywords, safe='')
    # or_keywords = urllib.parse.quote(or_keywords, safe='')

    # Google API limit is 100
    limit = 101
    today = datetime.datetime.now()  #today's date

    for date_sort in ["date:a", "date"]:
        for required_keywords, or_keywords in zip(required_keyword,
                                                  or_keyword):
            while True:
                if start == -1:
                    break

                # Standard google format
                # "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"

                # Documentation can be found here - https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list
                payload = {
                    'key': api_keys[0],
                    # 'key': "AIzaSyAaX5akizYDYsvAHK4gvDbIOQXdFKWHPp0",
                    'q': None,
                    'num': None,
                    'start': start_index,
                    'lr': None,
                    'safe': None,
                    'cx': cse_key,
                    'sort': date_sort,
                    'filter': None,
                    'gl': None,
                    'cr': None,  #countryUA - Ukraine #countryAU - Australia
                    'googlehost': None,
                    'c2coff': None,
                    'hq': None,
                    'hl': None,
                    'siteSearch': domain,
                    'siteSearchFilter': siteSearchFilter,
                    'exactTerms': required_keywords,
                    'excludeTerms': None,
                    'linkSite': None,
                    'orTerms': or_keywords,
                    'relatedSite': None,
                    'dateRestrict': "m[3]",  #'m[8]'
                    'lowRange': None,
                    'highRange': None,
                    'searchType': None,
                    'fileType': None,
                    'rights': None,
                    'imgSize': None,
                    'imgType': None,
                    'imgColorType': None,
                    'imgDominantColor': None,
                    'alt': None,
                    'occt': 'body'  #ass occured in body and not anywhere else
                }

                # page_url = f"https://www.googleapis.com/customsearch/v1?key={api_keys[0]}&start={start_index}&cx={cse_key}&siteSearch={domain}&siteSearchFilter={siteSearchFilter}&exactTerms={required_keywords}&orTerms={or_keywords}&as_occt=body&dateRestrict=m[8]"

                # Dont send request if start_status is "NOT_FOUND"
                if start_status == 'NOT_FOUND' or start <= limit - 1:
                    response = requests.get(
                        'https://www.googleapis.com/customsearch/v1',
                        params=payload)
                    if response.status_code == 200:
                        response = json.loads(response.text)
                        if 'items' in response:
                            results += response['items']

                            if 'nextPage' in response['queries']:
                                # Limiting to top 'limit' results
                                next_index = response['queries']['nextPage'][
                                    0]['startIndex']
                                if next_index == limit + 1 or next_index == limit:
                                    break
                                else:
                                    start_index += 10
                            else:
                                break
                        else:
                            # Update csv with -1 because no data found for keyword
                            start_index = -1
                            last_page_data = f'{domain},{today.strftime("%Y-%m-%d %H:%M")},{start_index},{project},{words}\n'
                            last_page(last_page_data)
                            break

                    elif response.status_code == 429:
                        # Quota is out
                        if api_keys:
                            api_keys.remove(api_keys[0])
                            pbar.update(1)
                            if not api_keys:
                                # last_page_data = f'{domain},{today.strftime("%Y-%m-%d %H:%M")},{start},{project},{words}\n'
                                # last_page(last_page_data)

                                # Pause till the next day
                                next_day = today + datetime.timedelta(days=1)
                                year, month, day = next_day.strftime(
                                    "%Y-%m-%d").split('-')
                                pause.until(
                                    datetime.datetime(int(year), int(month),
                                                      int(day)))
                                api_keys = get_txt_data('api_keys')
                                # break
                    elif 'error' in json.loads(response.text):
                        break
                else:
                    break

        # Keeping track of the extracted keywords and start index
        # if start_index != -1 or start != -1:
        #     last_page_data = f'{domain},{today.strftime("%Y-%m-%d %H:%M")},{start_index},{project},{words}\n'
        #     last_page(last_page_data)

        # domains.remove(domain)

            return results, start_index
Beispiel #25
0
    tweet = twitter.update_status(status=random.choice(tweetCopy),
                                  media_ids=[response['media_id']])
    twitter.update_status(status=('@' + tweet['user']['screen_name'] +
                                  ' SOURCE VIDEO: ' + videoChoice),
                          in_reply_to_status_id=tweet['id'])


while True:
    date = datetime.now()
    print('Current time is ' + time_str(date))
    date = round_to_next_hour(date)
    print('Next run is at ' + time_str(date))
    dt = datetime(date.year, date.month, date.day, date.hour, date.minute,
                  date.second, 0).timestamp()
    pause.until(dt)
    fails = 0
    while fails < 3:
        try:
            run()
            break
        except Exception as e:
            fails += 1
            print("Failed!")
            traceback.print_tb(e.__traceback__)
            pass
        finally:
            active = psutil.Process(os.getpid())
            print("Theres " + str(len(active.children())) + " child processes")
            for child in active.children():
                child.kill()
        Chrome.find_element_by_xpath(self, '//*[@id="profile-link-div"]/div/a').click() 
        login_modal = Chrome.find_element_by_id(self, 'rgp00-embedded-modal-frame')
        self.switch_to.frame(login_modal)
        Chrome.find_element_by_id(self, 'inputEmail').send_keys(cc_login['login']) 
        Chrome.find_element_by_id(self, 'inputPassword').send_keys(cc_login['password'])
        Chrome.find_element_by_xpath(self, '/html/body/div[1]/div/div/form/div[1]/label/input').click()
        Chrome.find_element_by_xpath(self, '/html/body/div[1]/div/div/form/a[2]').click() # Click login
        Chrome.find_element_by_xpath(self, '/html/body/div[1]/div/div/div[1]/a').click() # Click done and exit

# Page 1
driver1 = gymchrome(gym_to_book) # Initialize browser sessions
time.sleep(2) # Wait 2 seconds before all other actions
dt = datetime.now()
y, m, d = dt.year, dt.month, dt.day
if not running_test: # If running test, don't want to pause
    pause.until(datetime(y, m, d, 12, 0)) # Pause until booking is open
start = time.time() # Start timer
driver1.refresh() # Refresh at certain time
day_to_book = dt + timedelta(days=days_later) # Find date for 3 (or other amount) days later
month_dict = {v: k for k,v in enumerate(calendar.month_name)}
ui_month = driver1.find_element_by_class_name('ui-datepicker-month').text
if day_to_book.month - m == 1 and month_dict[ui_month] != day_to_book.month: # If need be, click cross month
    driver1.find_element_by_partial_link_text('Next').click() 
driver1.find_element_by_partial_link_text(str(day_to_book.day)).click() 
driver1.find_element_by_xpath('//*[@id="theform"]/div[6]/div/fieldset[2]/table/tbody/tr[1]/td[1]/a[2]').click()
if 'val' in persons_to_book:
    driver1.find_element_by_xpath('//*[@id="theform"]/div[6]/div/fieldset[2]/table/tbody/tr[1]/td[1]/a[2]').click()
if 'kyle' in persons_to_book:
    driver1.find_element_by_xpath('//*[@id="theform"]/div[6]/div/fieldset[2]/table/tbody/tr[2]/td[1]/a[2]').click()

# weekday_dict = {
def main():
    params = usage()

    USER_NAME = params.userName
    PWD = params.passWord
    TIME_TO_BID_SECS = int(params.timeToBid)
    ITEM_URL = params.itemUrl
    MAX_BID = params.maxBid

    driver = None

    try:
        driver = webdriver.Firefox()

        #Find item url to get end time in ms
        driver.get(ITEM_URL)
        time.sleep(3)
        endTimeAttr = driver.find_element_by_class_name("timeMs")
        endTimeMs = endTimeAttr.get_attribute("timems")

        if params.verbose:
            print("End time in ms: " + str(endTimeMs))

        bidTime = int(endTimeMs) - TIME_TO_BID_SECS * 1000

        if params.verbose:
            print("Bid time: " + str(bidTime))

        #Convert to datetime understandable time from bidTime
        bidTime = bidTime / 1000
        ts = datetime.datetime.fromtimestamp(bidTime).strftime(
            '%Y-%m-%d %H:%M:%S')
        print("Sleeping until bid time: " + str(ts))
        driver.quit()
        dt = datetime.datetime.fromtimestamp(bidTime)
        pause.until(dt)

        #Wake up and start the bid
        driver = webdriver.Firefox()
        driver.get('https://signin.ebay.com/ws/eBayISAPI.dll')

        time.sleep(3)
        elements = driver.find_elements_by_id("userid")
        print("Elements", elements)
        elements[0].send_keys(USER_NAME)
        #elements[3].send_keys(PWD)

        time.sleep(3)
        button = driver.find_element_by_id("signin-continue-btn")
        button.click()

        time.sleep(3)
        elements = driver.find_elements_by_id("pass")
        print("Elements", elements)
        elements[0].send_keys(PWD)
        #elements[3].send_keys(PWD)

        time.sleep(3)
        button = driver.find_element_by_id("sgnBt")
        button.click()

        time.sleep(2)
        driver.get(ITEM_URL)

        time.sleep(3)
        elements = driver.find_element_by_id("MaxBidId")
        elements.send_keys(MAX_BID)
        elements = driver.find_element_by_id("bidBtn_btn")
        elements.click()

        time.sleep(3)
        io = driver.find_element_by_id("confirm_button")
        io.click()

        time.sleep(20)
    except Exception as e:
        print("Error caught: " + str(e))
    finally:
        driver.quit()
Beispiel #28
0
def execution_main(secs):
    global app
    global engine
    tracing_cnt = 0
    req_id = 0
    sec_positions = dict()
    today = datetime.datetime.today()
    print(f"today={today}")
    latest_data_date = get_latest_datadate(engine)
    #latest_data_date = 20210401
    print(f"latest_data_date={latest_data_date}")
    # get the security list with the dynamic buy power threshold for each security based on normalized ATR
    if os.path.isfile(SECURITIES_NATR_FILE):
        buy_thd_list = read_sec_list(SECURITIES_NATR_FILE)
        print(f"secs_buy_thd= {buy_thd_list}")
    else:
        # refer calculate_model1_buy_thd from db_util.py
        buy_thd_list = calculate_model1_buy_thd(engine,
                                                secs,
                                                latest_data_date,
                                                interval=14)
    # select the stock list fit for three plus one model , order by turnover amount descending
    if os.path.isfile(SECURITIES_LIST_FILE):
        selected_secs_with_turnover = read_sec_list(SECURITIES_LIST_FILE)
        print(f"selected_secs_with_turnover= {selected_secs_with_turnover}")
    else:
        # refer get_sec_list_fit_three_plus_one_model from db_util.py
        selected_secs_with_turnover = get_sec_list_fit_three_plus_one_model(
            engine, secs, latest_data_date, 10)
    for sec_with_turnover in selected_secs_with_turnover:
        if tracing_cnt < MAX_TRACING:
            new_contract = Contract()
            new_contract.symbol = sec_with_turnover['security_name']
            new_contract.secType = 'STK'
            new_contract.exchange = 'SMART'
            new_contract.currency = 'USD'
            if sec_with_turnover['security_name'] in PRY_XCH:
                new_contract.primaryExchange = PRY_XCH[
                    sec_with_turnover['security_name']]
            req_id += 1
            for sec_buy_thd in buy_thd_list:
                if sec_buy_thd['security_name'] == sec_with_turnover[
                        'security_name']:
                    buy_thd = sec_buy_thd['buy_thd']
            # refer class Model1Stock from model1.py
            sec_positions[req_id] = Model1Stock(new_contract, buy_thd)
            tracing_cnt += 1
    print(f"Registering {tracing_cnt} securities ... ")

    app = IBapi(sec_positions, TOTAL_BUY_POWER)
    app.connect(IBIP, PORT, 555)

    # Start the socket in a thread
    api_thread = threading.Thread(target=run_loop, daemon=True)
    api_thread.start()
    print("Starting thread...")
    time.sleep(1)  # Sleep interval to allow time for connection to server
    print("Retrieving buying power...")
    app.reqAccountUpdates(True, ACCOUNT)
    # Set market data type
    # 1 for real time data
    # 3 for delay data
    app.reqMarketDataType(3)
    time.sleep(1)
    # refer refresh_vwap_bars from robot_cj7.py
    app.refresh_vwap_bars()
    for each in sec_positions:
        print(
            f"initializing security with buy_thd: {round(100 * sec_positions[each].buy_thd, 2)}% "
            f"for {sec_positions[each].contract.symbol}... ")
        app.reqMktData(each, sec_positions[each].contract, '', False, False,
                       [])
        time.sleep(0.1)
    cancel_buy_datetime = datetime.datetime.combine(
        today, datetime.time(15 + TIME_ZONE_ADJ, 00, 00))
    clear_position_datetime = datetime.datetime.combine(
        today, datetime.time(15 + TIME_ZONE_ADJ, 59, 30))
    now = datetime.datetime.now()
    while now + datetime.timedelta(0, 60) < clear_position_datetime:
        next_minute = now + datetime.timedelta(0, 60)
        pause.until(next_minute)
        now = datetime.datetime.now()
        if now > cancel_buy_datetime:
            # Retrieving currently active orders
            app.ret_api_orders()
        # refresh vwap bar for every minute
        app.refresh_vwap_bars()
    app.clear_position()
    # end_of_day_analysis(today_int, end_of_day_stats)
    time.sleep(30)  # give some time for the system to fill the orders
    app.disconnect()
Beispiel #29
0
def magic():
    global wilma_url

    clearScreen()
    custom_url = input(
        f"Käytetään wilma-osoitetta \"{wilma_url}\".\nPaina Enter jos tämä kelpaa. Jos ei kelpaa, kirjoita oma: "
    )
    if custom_url.strip() != "":
        wilma_url = custom_url

    clearScreen()
    print(colored("Sinun on kirjauduttava Wilmaan!", "yellow"))
    username = input("Käyttäjätunnuksesi: ").strip()
    password = getpass(prompt="Salasanasi: ")
    clearScreen()

    with requests.Session() as r:

        spinner = Spinner("Kirjaudutaan... ")

        g = r.get(wilma_url)
        spinner.next()
        soup = bs(g.text, "html.parser")
        spinner.next()
        token = soup.select_one("input[name=SESSIONID]").get("value")
        spinner.next()

        data = {
            "Login": username,
            "Password": password,
            "SESSIONID": token,
        }
        p = r.post(f"{wilma_url}/login", data=data)
        if "loginfailed" in p.url:
            print(colored("\nKirjautuminen epäonnistui", "red"))
            exit()
        spinner.next()
        spinner.finish()

        print(colored("Kirjautuminen onnistui!\n", "green"))

        try:
            spinner = Spinner("Hankitaan API-tokeni... ")

            g = r.get(wilma_url)
            spinner.next()
            soup = bs(g.text, "html.parser")
            spinner.next()
            token = soup.select_one("input[name=formkey]").get("value")
            spinner.next()
            spinner.finish()

            print(colored("Tokeni löytyi!\n", "green"))
        except:
            print(colored("Tokenin haku mokas.", "red"))
            exit()

        g = r.get(f"{wilma_url}/selection/view")
        soup = bs(g.text, "html.parser")
        parent = soup.select_one("#own-schools")
        years = []
        for index, child in enumerate(parent.find_all("h4")):
            years.append({
                "title":
                child.text.strip(),
                "periods": [
                    link["href"]
                    for link in parent.find_all("ul")[index].find_all("a")
                ]
            })

        selection_menu = SelectionMenu(
            [year["title"] for year in years],
            "Lukuvuosi",
            "Valitse oikea lukuvuosi, josta löytyy haluamasi kurssit.",
            show_exit_option=False)
        selection_menu.show()

        periods = years[selection_menu.selected_option]["periods"]

        master = tk.Tk()
        master.resizable(False, False)
        master.title('Haluamasi kurssit')
        master.eval('tk::PlaceWindow . center')

        def getInput():
            globals()["courses_input"] = textarea.get("1.0", "end-1c")
            master.after(1, master.destroy())

        title = tk.Label(
            master,
            text=
            "Liitä tähän kaikki haluamasi kurssit.\nVoit erottaa ne miten tahansa (pilkut, rivivälit, jne.)"
        )
        title.grid(row=0, column=0)

        textarea = tk.Text(master, height=30, width=38)
        textarea.grid(row=1, column=0)

        btn = tk.Button(master,
                        text="Done.",
                        justify="center",
                        command=getInput)
        btn.grid(row=2, column=0)
        master.mainloop()

        course_regex = r"([A-z0-9öÖäÄåÅ]+[\.0-9]+)"
        courses = [
            course.group(0)
            for course in re.finditer(course_regex,
                                      globals()["courses_input"], re.MULTILINE)
        ]
        courses = [{
            "name": course,
            "id": "",
            "selected": False
        } for course in courses]

        print(colored(f"{len(courses)} kurssin nimeä tunnistettu", "green"))

        bar = ShadyBar("Etsitään kurssit",
                       max=(len(courses) * len(periods)),
                       suffix="%(percent)d%%")

        for period in periods:
            g = r.get(f"{wilma_url}/selection/{period}")
            soup = bs(g.text, "html.parser")

            for course in courses:
                try:
                    id = soup.find("a", string=course["name"])["href"]
                    course["id"] = id
                except:
                    pass
                finally:
                    bar.next()

        failed = list(filter(lambda course: course["id"] == "", courses))
        success = list(filter(lambda course: course["id"] != "", courses))

        bar.finish()

        if len(failed) != 0:
            print(colored("Nämä kurssit eivät löytyneet:", "red"))
            for fail in failed:
                print(fail["name"])

            cont = input(
                "\nJatketaanko silti?\nPaina Enter jatkakseen ja jotain muuta lopetakseen: "
            )
            if cont != "":
                print(colored("\nOhjelma suljetaan.", "red"))
                exit()

        else:
            print(
                colored(f"Kaikki {len(success)} kurssia löydetty!\n", "green"))

        thetime = input(
            "\nMihin aikaan kurssivalinnat alkavat?\nJos haluat, että kurssit valitaan heti, paina Enter.\nMuuten, kirjoita muodossa \"16.00\": "
        )
        if thetime.strip() != "":
            (hours, minutes) = [
                int(t) for t in thetime.strip().replace(".", ":").split(":")
            ]
            fire = datetime.datetime.now().replace(hour=hours,
                                                   minute=minutes,
                                                   second=1)
            print(colored(f"Nyt odotetaan {thetime} asti...\n", "green"))
            pause.until(fire)
        else:
            print(colored("Aloitetaan heti!\n", "green"))
            time.sleep(0.5)

        clearScreen()

        start = time.time()

        bar = ShadyBar("Valitaan kurssit", max=(len(success)))

        with ThreadPoolExecutor(max_workers=30) as ex:
            futures = [
                ex.submit(
                    select, r, {
                        "message": "pick-group",
                        "target": course["id"],
                        "formkey": token,
                    }) for course in success
            ]

            for fut in as_completed(futures):
                fut.result()
                bar.next()

        bar.finish()

        print(
            colored(
                "Kaikki kurssit valittu {0:0.1f} sekunnissa.".format(
                    time.time() - start), "green"))
Beispiel #30
0
def run(driver,
        shoe_type,
        username,
        password,
        url,
        shoe_size,
        login_time=None,
        release_time=None,
        page_load_timeout=None,
        screenshot_path=None,
        html_path=None,
        select_payment=False,
        purchase=False,
        num_retries=None,
        dont_quit=False):
    driver.maximize_window()
    driver.set_page_load_timeout(page_load_timeout)

    if login_time:
        LOGGER.info("Waiting until login time: " + login_time)
        pause.until(date_parser.parse(login_time))

    try:
        login(driver=driver, username=username, password=password)
    except Exception as e:
        LOGGER.exception("Failed to login: "******"Waiting until release time: " + release_time)
        pause.until(date_parser.parse(release_time))

    num_retries_attempted = 0
    while True:
        try:
            try:
                LOGGER.info("Requesting page: " + url)
                driver.get(url)
            except TimeoutException:
                LOGGER.info("Page load timed out but continuing anyway")

            try:
                select_shoe_size(driver=driver,
                                 shoe_size=shoe_size,
                                 shoe_type=shoe_type)
            except Exception as e:
                # Try refreshing page since you can't click Buy button without selecting size
                LOGGER.exception("Failed to select shoe size: " + str(e))
                continue

            try:
                click_buy_button(driver=driver)
            except Exception as e:
                LOGGER.exception("Failed to click buy button: " + str(e))
                six.reraise(Exception, e, sys.exc_info()[2])

            if select_payment:
                try:
                    select_payment_option(driver=driver)
                except Exception as e:
                    LOGGER.exception("Failed to select payment option: " +
                                     str(e))
                    six.reraise(Exception, e, sys.exc_info()[2])

                try:
                    click_save_button(driver=driver)
                except Exception as e:
                    LOGGER.exception("Failed to click save button: " + str(e))
                    six.reraise(Exception, e, sys.exc_info()[2])

            if purchase:
                try:
                    click_submit_button(driver=driver)
                except Exception as e:
                    LOGGER.exception("Failed to click submit button: " +
                                     str(e))
                    six.reraise(Exception, e, sys.exc_info()[2])

            LOGGER.info("Purchased shoe")
            break
        except Exception:
            if num_retries and num_retries_attempted < num_retries:
                num_retries_attempted += 1
                continue
            else:
                break

    if screenshot_path:
        LOGGER.info("Saving screenshot")
        driver.save_screenshot(screenshot_path)

    if html_path:
        LOGGER.info("Saving HTML source")
        with open(html_path, "w") as f:
            f.write(driver.page_source)

    if dont_quit:
        LOGGER.info("Preventing driver quit...")
        input("Press Enter to quit...")

    driver.quit()
Beispiel #31
0
def register_latest(target_time):

    options = webdriver.ChromeOptions()
    options.add_argument(
        "user-data-dir=/Users/clemens/Library/"
        "Application Support/Google/Chrome/selenium"
    )

    browser = webdriver.Chrome(chrome_options=options)
    success = None
    while success is None:
        try:
            browser.implicitly_wait(5)  # seconds
            browser.get("https://recregister.nd.edu/")
            success = True
        except:
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(5)  # seconds
            element = browser.find_element_by_id("loginLink")
            element.click()
            success = True
        except:
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(3)
            login2 = browser.find_element_by_xpath(
                "/html/body/div[5]/div[5]/div/div/div/div[2]"
                "/div[2]/div[2]/div/button"
            )
            login2.click()
            success = True
        except:
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(4)
            browser.find_element_by_id("okta-signin-username").send_keys("")
            browser.find_element_by_id("okta-signin-password").send_keys("")
            login2 = browser.find_element_by_xpath(
                '//*[@id="okta-signin-submit"]'
            )
            login2.click()
            success = True
        except:
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(3)
            far1 = browser.find_element_by_xpath(
                "/html/body/div[5]/div[2]/div[2]/div[1]/div[1]/a/span[1]/img"
            )
            far1.click()
            success = True
        except:
            pass

    # wait till new time slot release time
    pause.until(
        datetime.datetime(
            datetime.datetime.now().year,
            datetime.datetime.now().month,
            datetime.datetime.now().day,
            target_time[0],
            target_time[1],
            target_time[2],
        )
    )

    success = None
    while success is None:
        try:
            far2 = browser.find_element_by_xpath(
                "/html/body/div[5]/div[1]/div[2]/div[2]/div/div[2]/div/div/div"
                "/div[4]/div/div[1]/img"
            )
            far2.click()
            success = True
        except:
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(3)
            reg = browser.find_elements_by_class_name("btn-primary")
            for i, element in enumerate(reg):
                if element.get_attribute("innerHTML") == "Register":
                    continue
                else:
                    break
            reg[i - 1].click()
            success = True
        except:
            browser.implicitly_wait(3)
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(3)
            far3 = browser.find_element_by_xpath(
                "/html/body/div[5]/div[1]/div[2]/div[2]/a"
            )
            far3.click()
            success = True
        except:
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(3)
            far4 = browser.find_element_by_xpath(
                "/html/body/div[5]/div[1]/div[2]/form[2]/div[2]/button[2]"
            )
            far4.click()
            success = True
        except:
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(3)
            far5 = browser.find_element_by_xpath(
                "/html/body/div[5]/div[1]/div[2]/div[3]/div/form/button"
            )
            far5.click()
            success = True
        except:
            pass

    success = None
    while success is None:
        try:
            browser.implicitly_wait(3)
            far5 = browser.find_element_by_xpath(
                "/html/body/div[5]/div[1]/div[2]/div[5]/div/div/div[2]/div/"
                "div[2]/button"
            )
            far5.click()
            success = True
        except:
            pass

    browser.close()
Beispiel #32
0
def main():
	# Set variables
	ff_website = 'https://clients.mindbodyonline.com/LoginLaunch?studioid=741470' 
	yj_login = #
	yj_pwd = #

	# Gym List 
	mbfc = 'MBFC' 
	tanjong = '100AM (Tanjong Pag...' 
	bugis = 'Bugis Junction' 
	captow = 'Capital Tower' 
	mktst = 'MarketStreet' 
	orq = 'One Raffles Quay' 
	paragon = 'Paragon' 
	metro = 'Metropolis' 

	

	# Check which day are we running this script 
	# dow = Monday is 0, Sunday is 6
	dow = datetime.today().weekday()

	# Open webpages and login
	if (dow == 0 or dow == 1):
		driver1, driver2 = webdriver.Chrome(), webdriver.Chrome() 
		open_page_and_login(driver1, ff_website, mbfc, yj_login, yj_pwd) 
		open_page_and_login(driver2, ff_website, mbfc, yj_login, yj_pwd) 
	elif dow == 3:
		driver1, driver2, driver3 = webdriver.Chrome(), webdriver.Chrome(), webdriver.Chrome() 
		open_page_and_login(driver1, ff_website, paragon, yj_login, yj_pwd) 
		open_page_and_login(driver2, ff_website, metro, yj_login, yj_pwd) 
		open_page_and_login(driver3, ff_website, metro, yj_login, yj_pwd) 
	# On other days don't run
	else: 
		return 

	# Only run the following codes AT 8AM PRECISELY 
	dt = datetime.now() 
	y, m, d = dt.year, dt.month, dt.day 
	pause.until(datetime(y, m, d, 8)) 

	# Refreshes
	driver1.refresh() 
	# Refresh additional browsers if needed
	if (dow == 0 or dow == 1 or dow == 3): 
		driver2.refresh() 
		if dow == 3:
			driver3.refresh() 

	# Book relevant classes
	# Monday (Wednesday Classes)
	if dow == 0:
		driver1.find_element_by_name('but820').click() 
		driver2.find_element_by_name('but2700').click() 
	# Tuesday (Thursday Classes)
	if dow == 1:
		driver1.find_element_by_name('but902').click() 
		driver2.find_element_by_name('but906').click() 
	# 
	if dow == 3:
		driver1.find_element_by_name('but7197').click() 
		driver2.find_element_by_name('but2705').click() 
		driver3.find_element_by_name('but1467').click() 

	# Click on book button
	driver1.find_element_by_xpath("//input[@value='Make a single reservation']").click() 
	# Click on additional book buttons
	if (dow == 0 or dow == 1 or dow == 3): 
		driver2.find_element_by_xpath("//input[@value='Make a single reservation']").click() 
		if dow == 3:
			driver3.find_element_by_xpath("//input[@value='Make a single reservation']").click() 

	# Close browsers
	time.sleep(2)
	driver1.close()
	# Close additional browsers 
	if (dow == 0 or dow == 1 or dow == 3): 
		driver2.close() 
		if dow == 3:
			driver3.close() 

	# OLD Signup for classes you're interested in
	# driver.find_element_by_xpath("//*[contains(@onclick, 'GRIT STRENGTH at 6:50 pm  on Thursday')]").click()
	# driver2.find_element_by_xpath("//*[contains(@onclick, 'Circuit at 7:25 pm  on Thursday')]").click()

	# OLD Login After Choosing Class
	# driver.find_element_by_id('su1UserName').send_keys(yj_login)
	# driver2.find_element_by_id('su1UserName').send_keys(yj_login)
	# driver.find_element_by_id('su1Password').send_keys(yj_pwd)
	# driver2.find_element_by_id('su1Password').send_keys(yj_pwd)
	# driver.find_element_by_id('btnSu1Login').click()
	# driver2.find_element_by_id('btnSu1Login').click()

	return 
Beispiel #33
0
    fontblk = ImageFont.truetype(os.path.join(picdir, 'DS-DIGIT.TTF'), 50)

    epd.init(epd.FULL_UPDATE)

    displayblock = False
    while (True):
        now = datetime.datetime.now()

        if ((args.nightmode == "yes")
                and is_time_between(datetime.time(0, 0), datetime.time(7, 0))):

            time_image = Image.new('1', (epd.height, epd.width), 255)
            time_draw = ImageDraw.Draw(time_image)
            time_draw.text((10, 45), "Night mode", font=font20, fill=0)
            epd.display(epd.getbuffer(time_image))
            pause.until(
                datetime.datetime(now.year, now.month, now.day, 7, 0, 0))
        else:
            time_image = Image.new('1', (epd.height, epd.width), 255)
            time_draw = ImageDraw.Draw(time_image)

            # obtenemos precio
            if ((args.display == "PRICE") or (args.display == "PRCBLK")):
                price = get_price()

            # obtenemos bloque
            if ((args.display == "BLOCK") or (args.display == "PRCBLK")):
                block = get_block()
                fee = get_fees()

            if (args.display == "QUOTES"):
                image = Image.open(
Beispiel #34
0
# Catch up on any old pings.
cmd = os.path.join(settings.path, "launch.py")
if subprocess.call(cmd) != 0:
    print("SYSERR:", cmd, file=sys.stderr)

tdelta = datetime.timedelta(seconds=time.time() - lastping)
print("TagTime is watching you! Last ping would've been", tdelta, "ago.", file=sys.stderr)

start = time.time()
i = 1

while True:
    # sleep till next ping but check again in at most a few seconds in
    # case computer was off (should be event-based and check upon wake).
    # Use the pause library to get better precision
    pause.until(nextping)
    # time.sleep(util.clip(nextping - time.time(), 0, 2))
    now = time.time()

    if nextping <= now:
        if settings.catchup or nextping > now - settings.retrothresh:
            util.playsound()

        # invokes popup for this ping plus additional popups if there were more
        #   pings while answering this one:
        cmd = [os.path.join(settings.path, "launch.py"), "quiet", "&"]
        util.callcmd(cmd)
        s = "{i: 4}: PING! gap {gap} avg {avg} tot {tot}".format(
            i=i,
            gap=datetime.timedelta(seconds=nextping - lastping),
            avg=datetime.timedelta(seconds=(0.0 + time.time() - start) / i),
Beispiel #35
0
Site = conf["site"]

ic("🤖 : Start my job")
ic("open the browser")
webbrowser.get("chrome").open_new_tab(Site.url())

ic("Click the browser")
pyautogui.click(position.APPLY_BTN)
sleep(Wait.load_page)

ic("Scroll down")
for i in range(13):
    pyautogui.scroll(-10)

ic("Pause for click time")
pause.until(click_time(hour=2, minute=18, second=10))

total_clicks = 0
ic("Click {} time(s)".format(total_clicks))
pyautogui.click(clicks=total_clicks)
sleep(Wait.finish_clicks)

ic("move mouse cursor to the next button")
pyautogui.moveTo(position.CONFIRM_BTN)
sleep(Wait.mouse_move)

ic("click the confirm button")
pyautogui.click(clicks=total_clicks)

ic("Wait for click")
sleep(1)
 def _run(self):
     while True:
         pausetime = self.sincurve[PowerSensorSimulator._getTick() %
                                   self.repeat_time_ms]
         pause.until(time.time() + pausetime)
         self.blink_detected()
Beispiel #37
0
def run(driver,
        username,
        password,
        product_id,
        sku_id,
        shoe_size,
        login_time=None,
        release_time=None,
        page_load_timeout=None,
        screenshot_path=None,
        purchase=False,
        num_retries=None):
    driver.maximize_window()
    driver.set_page_load_timeout(page_load_timeout)

    if login_time:
        LOGGER.info("Waiting until login time: " + login_time)
        pause.until(date_parser.parse(login_time))

    try:
        login(driver=driver, username=username, password=password)
    except Exception as e:
        LOGGER.exception("Failed to login: "******"Waiting until release time: " + release_time)
        pause.until(date_parser.parse(release_time))

    num_retries_attempted = 0
    while True:
        try:
            try:
                LOGGER.info("Adding item to cart")
                add_item_to_cart(driver=driver,
                                 product_id=product_id,
                                 sku_id=sku_id,
                                 size=shoe_size)
            except Exception as e:
                LOGGER.exception("Failed to add item to cart " + str(e))
                six.reraise(Exception, e, sys.exc_info()[2])

            try:
                LOGGER.info("Requesting page: " + NIKE_CHECKOUT_URL)
                driver.get(NIKE_CHECKOUT_URL)
            except TimeoutException:
                LOGGER.info("Page load timed out but continuing anyway")

            if purchase:
                try:
                    click_place_order_button(driver=driver)
                except Exception as e:
                    LOGGER.exception("Failed to click place order button: " +
                                     str(e))
                    six.reraise(Exception, e, sys.exc_info()[2])

            LOGGER.info("Purchased shoe")
            break
        except Exception:
            if num_retries and num_retries_attempted < num_retries:
                num_retries_attempted += 1
                continue
            else:
                break

    if screenshot_path:
        LOGGER.info("Saving screenshot")
        driver.save_screenshot(screenshot_path)

    driver.quit()
Beispiel #38
0
from sys import argv
import pause
import datetime

# query for flight info
confirmation_code = input("Confirmation Code: ")
first_name = input("First Name: ")
last_name = input("Last Name: ")
flight_date = datetime.datetime.strptime(
    input("Flight Date/Time\n(dd/mm/yy 24hr:min): "), "%m/%d/%y %H:%M")
check_in_date = flight_date - datetime.timedelta(days=1)
print(check_in_date)
print("Check in will begin at", check_in_date)

# wait until 1 minute before
pause.until(check_in_date - datetime.timedelta(minutes=1))

# browser setup
if len(argv) > 1:
    # configure custom chromedriver path with command line arg
    chromedriver = argv[1]
else:
    chromedriver = "chromedriver"

driver = webdriver.Chrome(chromedriver)
url = "https://www.southwest.com/air/check-in/"

# navigate to the check in page
driver.get(url)

# fill in user info
Beispiel #39
0
def ssgd_with_horovod(job, mode, start_dt):

    rank = hvd.rank()
    gpu_id = -1
    if job.cuda:
        ngpus=1
        gpu_id = job.device_ids[rank]
        torch.cuda.set_device(gpu_id)
    else:
        ngpus=-1

    if rank != 0:
        pretrain = None

    trainer = DLTrainer(rank, dist=False, batch_size=job.batch_size, is_weak_scaling=True, ngpus=ngpus, data_dir=job.data_dir, dataset=job.dataset, dnn=job.dnn, lr=job.lr, nworkers=job.nworkers, prefix='allreduce')

    if mode == 'simulate':
        synt_model = torch.rand(4, job.model_size * (2**20) / 4 / 4)

    init_epoch = torch.ones(1) * trainer.get_train_epoch()
    init_iter = torch.ones(1) * trainer.get_train_iter()
    trainer.set_train_epoch(int(hvd.broadcast(init_epoch, root_rank=0)[0]))
    trainer.set_train_iter(int(hvd.broadcast(init_iter, root_rank=0)[0]))

    optimizer = hvd.DistributedOptimizer(trainer.optimizer, named_parameters=trainer.net.named_parameters())
    hvd.broadcast_parameters(trainer.net.state_dict(), root_rank=0)
    trainer.update_optimizer(optimizer)
    #iters_per_epoch = trainer.get_num_of_training_samples() // (nworkers * batch_size * nsteps_update)

    times = []

    #display = 20 if iters_per_epoch > 20 else iters_per_epoch-1
    display = 1
    nsteps_update = job.nsteps_update

    # to integrate in LSTM code
    hidden = None
    dnn = job.dnn
    if dnn == 'lstm':
        hidden = trainer.net.init_hidden()

    logger.info("(Server %s, Job %d, Rank %d, GPU %d) Wait until start time: %s." % (settings.hostname, job.job_id, rank, gpu_id, start_dt))
    pause.until(start_dt)

    start_slot = time.time()
    for i in range(job.iters):

        s = time.time()
        optimizer.zero_grad()
        optimizer.local = False
        # forward 
        time.sleep(job.get_forward_schedule(rank, i) * 0.001)
        fw_start_slot=int((time.time() - start_slot) * 1000)
        if mode == 'simulate':
            time.sleep((job.fw_time) * 0.001)
        else:
            #optimizer.local = True
            if dnn == 'lstm':
                #print(hidden)
                #print(" =========== j : %d ===========", j)
                _, hidden = trainer.train_forward(1, hidden=hidden)
            else:
                trainer.train_forward(1)
                #trainer.train(1)
        fw_end_slot=int((time.time() - start_slot) * 1000)
        logger.info("(Server %s, Job %d, Rank %d, GPU %d) Forward task %d started at slot=%d, ended at slot=%d, duration=%d." % (settings.hostname, job.job_id, rank, gpu_id, i, fw_start_slot, fw_end_slot, fw_end_slot-fw_start_slot))

        # backward
        time.sleep(job.get_backward_schedule(rank, i) * 0.001)
        bw_start_slot=int((time.time() - start_slot) * 1000)
        if mode == 'simulate':
            time.sleep((job.bw_time) * 0.001)
        else:
            trainer.train_backward(1) 
            #trainer.train(1) 
            pass
        bw_end_slot=int((time.time() - start_slot) * 1000)
        logger.info("(Server %s, Job %d, Rank %d, GPU %d) Backward task %d started at slot=%d, ended at slot=%d, duration=%d." % (settings.hostname, job.job_id, rank, gpu_id, i, bw_start_slot, bw_end_slot, bw_end_slot-bw_start_slot))

        # communication
        time.sleep(job.get_communication_schedule(rank, i) * 0.001)
        comm_start_slot=int((time.time() - start_slot) * 1000)
        if mode == 'simulate':
            hvd.allreduce(synt_model)
            pass
        else:
            trainer.update_model()
        comm_end_slot=int((time.time() - start_slot) * 1000)
        logger.info("(Server %s, Job %d, Rank %d, GPU %d) Comm task %d started at slot=%d, ended at slot=%d, duration=%d." % (settings.hostname, job.job_id, rank, gpu_id, i, comm_start_slot, comm_end_slot, comm_end_slot-comm_start_slot))

        times.append(time.time()-s)
        #if i % display == 0 and i > 0: 
        #    time_per_iter = np.mean(times)
        #    logger.info('Time per iteration including communication: %f. Speed: %f images/s', time_per_iter, job.batch_size * nsteps_update / time_per_iter)
        #    times = []

    end_slot = time.time()
    logger.info("(Server %s, Job %d, Rank %d, GPU %d) Job ended. Total time is % s." % (settings.hostname, job.job_id, rank, gpu_id, int((end_slot - start_slot)*1000)))
Beispiel #40
0
 def set_up(self):
     pause.until((self.product.launch_time - datetime.timedelta(minutes=5)))
Beispiel #41
0
def replay(starttime,endtime):
    replay_starttime=datetime.datetime.now()
    print (replay_starttime,"replay start: ",starttime)

    # error checking
    if not (starttime.year == endtime.year and
            starttime.month == endtime.month and
            starttime.day == endtime.day):
        print ("ERROR!  invalid replay range ",starttime,"->",endtime, " (must be same day)")
        exit()
    if starttime >= endtime:
        print ("ERROR!  invalid replay range ",starttime,"->",endtime, " (invalid times)")
        exit()

    # file the correct file
    file = '/var/local/submitty/logs/autograding/{:d}{:02d}{:02d}.txt'.format(starttime.year,starttime.month,starttime.day)
    with open(file,'r') as lines:
        for line in lines:
            things = line.split('|')
            original_time = dateutils.read_submitty_date(things[0])
            # skip items outside of this time range
            if (original_time < starttime or
                original_time > endtime):
                continue
            # skip batch items
            if (things[2].strip() == "BATCH"):
                continue
            # only process the "wait" time (when we started grading the item)
            iswait=things[5].strip()[0:5]
            if (iswait != "wait:"):
                continue
            waittime=float(things[5].split()[1])
            # grab the job name
            my_job = things[4].strip()
            if my_job == "":
                continue
            what = my_job.split('/')
            # for now, only interested in Data Structures and Computer Science 1
            if not (what[1]=="csci1200" or what[1]=="csci1100"):
                continue
            # calculate when this job should be relaunched
            time_multipler=1.0
            pause_time=replay_starttime+(time_multiplier*(original_time-starttime))
            pause.until(pause_time)
            queue_time = dateutils.write_submitty_date()
            print(datetime.datetime.now(),"      REPLAY: ",original_time," ",my_job)
            # FIXME : This will need to be adjust for team assignments
            # and assignments with special required capabilities!
            item = {"semester": what[0],
                    "course": what[1],
                    "gradeable": what[3],
                    "user": what[4],
                    "team": "",
                    "who": what[4],
                    "is_team": False,
                    "version": what[5],
                    "required_capabilities": "default",
                    "queue_time": queue_time,
                    "regrade": True,
                    "max_possible_grading_time" : -1 }
            file_name = "__".join([item['semester'], item['course'], item['gradeable'], item['who'], item['version']])
            file_name = os.path.join(SUBMITTY_DATA_DIR, "to_be_graded_queue", file_name)
            with open(file_name, "w") as open_file:
                json.dump(item, open_file, sort_keys=True, indent=4)
                os.system("chmod o+rw {}".format(file_name))  
    print (datetime.datetime.now(),"replay end: ",endtime)
Beispiel #42
0
    def countdown(self):
        print('counting down')

        pause.until((self.product.launch_time - datetime.timedelta(seconds=6)))
    level=logging.INFO,
    datefmt='%m/%d/%Y %I:%M:%S %p')

logging.info("Welcome to the autoPasswordChanger my friend")

USERNAME = input("Enter your Passport Number : ")
PASSWORD = getpass.getpass("Enter your Password (hidden in input) : ")
PAUSING = input("Do you want to wait for 7:30AM ? (yes or no) ")

# Check if password changed
password_changed = False

# Waiting for the date
if (PAUSING == "yes"):
    logging.info("Waiting for 2016-02-28 7:30AM...")
    pause.until(datetime.datetime(2016, 2, 28, 7, 30))

logging.info("autoPasswordChanger for coursechoose.bjtu.edu.cn v1.0")

try:
    logging.info("PhantomJS driver initialization")
    driver = webdriver.PhantomJS()
    logging.info(
        "Setting window size to bigger size because responsivness in China is None...")
    driver.set_window_size(1000, 1000)
except Exception:
    logging.error("Something went wrong with the initialization...")

logging.info("Waiting for system initialization...")
while (not password_changed):
    try:
Beispiel #44
0
                        help="Number of hours to run for",
                        type=int)

    args = parser.parse_args()

    kcm_routes = get_agency_routes('1')
    route_ids = {
        x['shortName']: x['id']
        for x in kcm_routes if x['shortName'] in args.routes
    }
    print route_ids

    date = datetime.datetime.now()
    date_string = date.strftime("%Y%m%d-%H%M")
    wait_time = 1
    next_checkpoint = wait_time
    with open('data/oba_dat-r%s-%s.csv' % ('_'.join(args.routes), date_string),
              'w') as f:
        header = True
        while datetime.datetime.now() - date < datetime.timedelta(
                hours=args.num_hours):
            df = pd.DataFrame([
                get_trip_data(trip_id, route_num) for route_num in route_ids
                for trip_id in get_route_trips(route_ids[route_num])
            ])
            df.to_csv(f, header=header)
            header = False
            print df
            pause.until(date + datetime.timedelta(minutes=next_checkpoint))
            next_checkpoint += wait_time
Beispiel #45
0
    soup = BeautifulSoup(page, "html.parser")
    myPointsRaw = soup.find_all("span", class_="nav__points")
    myPoints = myPointsRaw[0].get_text()
    return (myPoints)


def writeHTML():
    f.write("<b>Points:" + str(myPoints) + "</b><br />")
    for i in resultList:
        f.write(i + "<br />")
    f.close


while True:
    page = getPage()
    #Minimal points price for a game:
    targetPts = 10
    links = getLinks(page, targetPts, entered)
    points = getPoints(page)
    print("You have " + points + " points!")
    if not set(entered).issuperset(set(links)):
        entered + enter(links, entered)
        if int(points) < targetPts:
            print("No points, sleeping")
            pause.until(getTime() + 10800)
        else:
            time.sleep(10)
    else:
        print("No new giveaways, waiting")
        time.sleep(300)
Beispiel #46
0
# URL = "https://www.eventbrite.co.uk/e/hackhack-tickets"
# URL = "https://www.eventbrite.co.uk/e/hack1040-tickets"
# URL = "https://www.eventbrite.co.uk/e/test-tickets"
URL = "https://www.eventbrite.co.uk/e/ic-hack-20-tickets"
# LAUNCH = datetime(2020, 1, 10, 13, 30, 0, 100000)
LAUNCH = datetime(2020, 1, 10, 13, 29, 59, 100000)

REG_X, REG_Y = 600, 750

def click_select(n):
    move(X, Y + n * DELTA_Y)
    click()

driver = webdriver.Chrome()

until(LAUNCH)
s = timeit.default_timer()
driver.get(URL  + TICKET_ID)
load = timeit.default_timer()
reg1 = driver.find_element_by_id("eventbrite-widget-modal-trigger" + TICKET_ID)
reg1.click()
sleep(2)
click_select(0)
press_and_release("down")
press_and_release("enter")
sleep(1)
move(REG_X, REG_Y)
click()
e = timeit.default_timer()
print(load - s)
print(e - load)
Beispiel #47
0
 def wait(self):
     pause.until(self.last + self.interval)
     self.last = self.last + self.interval
     return True
        driver = initBrowser()
        wait = webdriver.support.ui.WebDriverWait(driver, 7)
        action = ActionChains(driver)
        for meetIndex, (URL, rawTime) in enumerate(MEETS.items(), start=1):
            startTime = fixTimeFormat(rawTime)
            if (meetIndex <= 1):
                print(colored(
                    f"Waiting until first Meet start time [{rawTime}]...",
                    "yellow"),
                      end="")
            else:
                print(colored(
                    f"\n\nWaiting until next Meet start time [{rawTime}]...",
                    "yellow"),
                      end="")
            pause.until(datetime(*startTime))
            print(colored(" Started!", "green"))
            if (meetIndex <= 1):
                login()
            attendMeet()
            time.sleep(DURATION)
            endMeet()
        print("\n\nAll Meets completed successfully.")
        # hibernate()
        # Uncomment above to hibernate after a 10 second countdown upon completion of all Meets (Ctrl + C to abort hibernation)
        print("Press Enter to exit.")
        input()
        print("\nCleaning up and exiting...", end="")
        driver.quit()

    except KeyboardInterrupt:
if __name__ == "__main__":
    import argparse
    import pandas as pd
    import pause

    parser = argparse.ArgumentParser("Get data for a specified route for a specified amount of time")
    parser.add_argument("routes", help="Route", nargs='+', type=str)  # change this to accept list of routes -!-
    parser.add_argument("num_hours", help="Number of hours to run for", type=int)

    args = parser.parse_args()

    kcm_routes = get_agency_routes('1')
    route_ids = {x['shortName']: x['id'] for x in kcm_routes if x['shortName'] in args.routes}
    print route_ids

    date = datetime.datetime.now()
    date_string = date.strftime("%Y%m%d-%H%M")
    wait_time = 1
    next_checkpoint = wait_time
    with open('data/oba_dat-r%s-%s.csv' % ('_'.join(args.routes), date_string), 'w') as f:
        header = True
        while datetime.datetime.now() - date < datetime.timedelta(hours=args.num_hours):
            df = pd.DataFrame([get_trip_data(trip_id, route_num) for route_num in route_ids
                               for trip_id in get_route_trips(route_ids[route_num])])
            df.to_csv(f, header=header)
            header = False
            print df
            pause.until(date + datetime.timedelta(minutes=next_checkpoint))
            next_checkpoint += wait_time

import datetime, pause, pyautogui, time

pause.until(
    datetime.datetime(2019, 7, 9, 18, 3,
                      0))  #pause untill a specific time pause:3d party library

time.sleep(5)
#pyautogui.PAUSE=10

pyautogui.click(1803, 13, clicks=1, interval=0.5)
time.sleep(2)

pyautogui.click(217, 1064)
time.sleep(2)

pyautogui.click(1270, 276, clicks=2)
time.sleep(2)

pyautogui.click(217, 184, clicks=2)
time.sleep(2)

pyautogui.click(1855, 369, clicks=2)
time.sleep(2)