MCPcopy Index your code
hub / github.com/InstaPy/InstaPy / remaining_time

Function remaining_time

instapy/quota_supervisor.py:204–223  ·  view source on GitHub ↗

Calculate wake up time and return accurate or close-range random sleep seconds

(sleepyhead, interval)

Source from the content-addressed store, hash-verified

202
203
204def remaining_time(sleepyhead, interval):
205 """Calculate wake up time and return accurate or close-range random
206 sleep seconds"""
207 extra_sleep_percent = 140 # actually 114 also is not that bad amount
208
209 if interval == "hourly":
210 remaining_seconds = (61 - int(this_minute)) * 60
211
212 elif interval == "daily":
213 tomorrow = date.today() + timedelta(1)
214 midnight = datetime.combine(tomorrow, time())
215 now = datetime.now()
216 remaining_seconds = (midnight - now).seconds
217
218 if sleepyhead is True:
219 remaining_seconds = random.randint(
220 remaining_seconds, int(remaining_seconds * extra_sleep_percent / 100)
221 )
222
223 return remaining_seconds
224
225
226def send_message(job, action, interval, nap):

Callers 1

controllerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected