script_task.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. from tasks.Restart.config_scheduler import Scheduler
  5. from tasks.Restart.login import LoginHandler
  6. from tasks.Restart.assets import RestartAssets
  7. from tasks.base_task import BaseTask
  8. from module.logger import logger
  9. from module.exception import TaskEnd, RequestHumanTakeover
  10. class ScriptTask(LoginHandler):
  11. def run(self) -> None:
  12. """
  13. 主要就是登录的模块
  14. :return:
  15. """
  16. self.app_restart()
  17. raise TaskEnd('ScriptTask end')
  18. def app_stop(self):
  19. logger.hr('App stop')
  20. self.device.app_stop()
  21. def app_start(self):
  22. logger.hr('App start')
  23. self.device.app_start()
  24. self.app_handle_login()
  25. # self.ensure_no_unfinished_campaign()
  26. def app_restart(self):
  27. logger.hr('App restart')
  28. self.device.app_stop()
  29. self.device.app_start()
  30. self.app_handle_login()
  31. # self.config.task_delay(server_update=True)
  32. self.set_next_run(task='Restart', success=True, finish=True, server=True)
  33. if __name__ == '__main__':
  34. from module.config.config import Config
  35. from module.device.device import Device
  36. config = Config('oas1')
  37. device = Device(config)
  38. task = ScriptTask(config, device)
  39. task.harvest()