def floatSecondsToDatetimeTime(floatSeconds): """ convert float seconds(time delta) to datetime.time example: 27.83879017829895 -> datetime.time(0, 0, 27, 838790) Note: the max hour can NOT excedd 24 hors, otherwise will error: ValueError: hour must be in 0..23 """ secondsInt = int(floatSeconds) decimalsFloat = floatSeconds - secondsInt millisecondsFloat = decimalsFloat * 1000 millisecondsInt = int(millisecondsFloat) microsecondsDecimal = millisecondsFloat - millisecondsInt microsecondsInt = int(microsecondsDecimal * 1000) minutes, seconds = divmod(secondsInt, 60) hours, minutes = divmod(minutes, 60) # datetimeTimeValue = datetime.time( datetimeTimeValue = datetimeTime(hour=hours, minute=minutes, second=seconds, microsecond=(millisecondsInt * 1000) + microsecondsInt) return datetimeTimeValue
for pin in pumpsPins: allPumps.append(Pump(pin['pinBoard'])) """ for ch in soilPins: allSoil.append(Mcp3008(ch['chPin'])) """ sensorReadingDoneHour = 0 lastSoilSensorValuePercent = 0 minSoilPercent = 60 maxSoilPercent = 70 middleSoilPercent = (minSoilPercent + maxSoilPercent) / 2 lightStart = datetimeTime(hour=8, minute=0, second=0) lingtEnd = datetimeTime(hour=21, minute=0, second=0) dht_device = None readSensorValuesAgain = False def runPumpCycle(): print("Pumps starting:") for pump in allPumps: pump.runPump(2) def turnLampOn(): print("turnLampOn") lamp.on()
from selenium import webdriver import time from datetime import datetime, timedelta, time as datetimeTime import random accounts = [ # Not to be published ] SEVEN_AM = datetimeTime(7,0,0) ELEVEN_PM = datetimeTime(23,0,0) def attemptToVote(account): num = random.randint(0,100) if(num < 133): try: options = webdriver.ChromeOptions() options.add_argument('--headless') website = webdriver.Chrome("/Users/connoringlis/Downloads/ChromeDriver/chromedriver", options=options) time.sleep(4) website.get("https://embed-572075.secondstreetapp.com/embed/80cea25e-f0f5-4856-a7e6-b9fee20d21c0/gallery/159284152/") time.sleep(4) website.execute_script("window.localStorage.setItem('SS_572075_accessToken','{}')".format(account["accessToken"])) time.sleep(4) website.get("https://embed-572075.secondstreetapp.com/embed/80cea25e-f0f5-4856-a7e6-b9fee20d21c0/gallery/159284152/") except: print("Could not connect to website") website.quit() return try: time.sleep(10)
def get_tweet_start_time(self): # date-time border glued to start of day return datetime.combine(datetime.now(), datetimeTime( 0, 0, 0)) - timedelta(days=self.days_back)