MCPcopy
hub / github.com/InstaPy/InstaPy / controller

Function controller

instapy/quota_supervisor.py:45–90  ·  view source on GitHub ↗

Control and supervise

(job)

Source from the content-addressed store, hash-verified

43
44
45def controller(job):
46 """Control and supervise"""
47 if not records:
48 load_records()
49
50 sleep_after = configuration["sleep_after"]
51 sleepyhead = configuration["sleepyhead"]
52 notify = configuration["notify"]
53 peaks = configuration["peaks"]
54
55 if configuration["stochasticity"]["enabled"] is True:
56 stochasticity(peaks)
57
58 # inspect
59 supervise, interval, target = inspector(job, peaks)
60
61 if supervise:
62 if (
63 any(
64 e in [job, job + ("_h" if interval == "hourly" else "_d")]
65 for e in sleep_after
66 )
67 and target != "lc_extra"
68 ):
69 nap = remaining_time(sleepyhead, interval)
70 send_message(job, "sleep", interval, nap)
71
72 toast_notification(notify, "sleep", job, interval)
73 sleep_actual(nap)
74 toast_notification(notify, "wakeup", job, interval)
75
76 else:
77 if job == "server_calls":
78 send_message(job, "exit", interval, None)
79 toast_notification(notify, "exit", job, interval)
80
81 logger.warning(
82 "You're about to leave the session. " "InstaPy will exit soon!"
83 )
84 exit()
85
86 else:
87 send_message(job, "jump", interval, None)
88 return "jump"
89
90 return "available"
91
92
93def inspector(job, peaks):

Callers 1

quota_supervisorFunction · 0.85

Calls 7

load_recordsFunction · 0.85
stochasticityFunction · 0.85
inspectorFunction · 0.85
remaining_timeFunction · 0.85
send_messageFunction · 0.85
toast_notificationFunction · 0.85
sleep_actualFunction · 0.85

Tested by

no test coverage detected