The jobs collection is responsible for tracking the progress of the various scripts. This class is responsible for recording the status of jobs within the jobs collection.
| 15 | |
| 16 | |
| 17 | class JobsManager(object): |
| 18 | """ |
| 19 | The jobs collection is responsible for tracking the progress of the various scripts. |
| 20 | This class is responsible for recording the status of jobs within the jobs collection. |
| 21 | """ |
| 22 | |
| 23 | # Job states |
| 24 | ################## |
| 25 | |
| 26 | # Never been run |
| 27 | NOT_RUN = "NOT_RUN" |
| 28 | |
| 29 | # In progress |
| 30 | RUNNING = "RUNNING" |
| 31 | |
| 32 | # Ready for next phase |
| 33 | READY = "READY" |
| 34 | |
| 35 | # An error has occurred |
| 36 | ERROR = "ERROR" |
| 37 | |
| 38 | # The job is complete |
| 39 | COMPLETE = "COMPLETE" |
| 40 | |
| 41 | # The job is no longer used |
| 42 | RETIRED = "RETIRED" |
| 43 | |
| 44 | # Settings |
| 45 | ################### |
| 46 | |
| 47 | # Print debug output |
| 48 | _logger = None |
| 49 | |
| 50 | # JobsCollection |
| 51 | _jobs_collection = None |
| 52 | |
| 53 | # Mongo_Connector |
| 54 | _mongo_connector = None |
| 55 | |
| 56 | # Job Name |
| 57 | _job_name = "" |
| 58 | |
| 59 | def _log(self): |
| 60 | """ |
| 61 | Get the log |
| 62 | """ |
| 63 | return logging.getLogger(__name__) |
| 64 | |
| 65 | def __init__(self, mongo_connector, job_name, log_level=None): |
| 66 | self._logger = self._log() |
| 67 | if log_level is not None: |
| 68 | self._logger.setLevel(log_level) |
| 69 | |
| 70 | self._mongo_connector = mongo_connector |
| 71 | self._jobs_collection = mongo_connector.get_jobs_connection() |
| 72 | self._job_name = job_name |
| 73 | |
| 74 | def __check_job_exists(self, job_name): |
nothing calls this directly
no outgoing calls
no test coverage detected