blob: 63ae16b7f33437a26e2088bf9b5970fadaca3ca4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/env python
import time
import logging
import requests
from jobs import JobFinder
class JobManager:
def __init__(self, config):
jobsFinder = JobFinder(config)
self.jobs = jobsFinder.get_jobs()
self.config = config
def list_jobs(self):
return self.jobs
def execute_jobs(self, cronmode):
logging.info("Executing jobs...")
success = True
for thisJob in self.jobs:
thisJob.setConfig(self.config)
if thisJob.shouldExecute(cronmode):
logging.info("Executing " + thisJob.getName())
if not thisJob.execute():
success = False
return success
def mark_jobs_ran(self):
logging.debug("Marking jobs as run successfully.")
try:
requests.post("http://localhost:5001/", data="True")
except:
pass
#Nothing we can do except hope our peers save us
def mark_jobs_ran_with_error(self):
logging.warning("Marking jobs as run unsuccessfully.")
try:
requests.post("http://localhost:5001/", data="False")
except:
pass
#Nothing we can do except hope our peers save us
|