Supervise activity flow through action engines and take measures
(job, update=False)
| 15 | |
| 16 | |
| 17 | def quota_supervisor(job, update=False): |
| 18 | """Supervise activity flow through action engines and take measures""" |
| 19 | # --ACTION----------ENGINE--------------FILE--------------OPTION--- # |
| 20 | # Like `like_image` [like_util.py] jump|sleep # |
| 21 | # Comment `comment_image` [comment_util.py] jump|sleep # |
| 22 | # Follow `follow_user` [unfollow_util.py] jump|sleep # |
| 23 | # Unfollow `unfollow_user` [unfollow_util.py] jump|sleep # |
| 24 | # *Server call `update_activity` [util.py] exit|sleep # |
| 25 | # ----------------------------------------------------------------- # |
| 26 | |
| 27 | global configuration |
| 28 | configuration = Settings.QS_config |
| 29 | |
| 30 | if configuration and configuration["state"] is True: |
| 31 | # in-file global variables for the QS family |
| 32 | global records, logger, this_minute, this_hour, today |
| 33 | |
| 34 | records = Storage.record_activity |
| 35 | logger = Settings.logger |
| 36 | this_minute, this_hour, today = get_time(["this_minute", "this_hour", "today"]) |
| 37 | if update: # update the action's record in global storage |
| 38 | update_record(job) |
| 39 | |
| 40 | else: # inspect and control the action's availability |
| 41 | quota_state = controller(job) |
| 42 | return quota_state |
| 43 | |
| 44 | |
| 45 | def controller(job): |
no test coverage detected