def _run_job(job_id=None, print_json=False): import json import sys from jobs import load_jobs from pprint import pprint enabled_jobs = _enabled_jobs() jobs = load_jobs() if job_id is None or len(job_id) == 0: job_ids = ' '.join(enabled_jobs) job_id = input('Name of the job to run [%s]: ' % (job_ids, )).lower() job_config = _config().get(job_id) if job_config is None: print('No config found for job: %s' % (job_id, )) sys.exit(1) cls = jobs.get(job_config.get('job_impl', job_id)) if cls is None: print('No such job: %s' % (job_id, )) sys.exit(1) job = cls(job_config) data = job.get() if print_json: print(json.dumps(data, indent=2)) else: pprint(data)
def _schedule_jobs(): offset = 0 jobs = load_jobs() for job_id, job_config in _config()['JOBS'].items(): job_impl = job_config.get('job_impl', job_id) if not job_config.get('enabled'): app.logger.info('Skipping disabled job: %s', job_id) continue if job_impl not in jobs: app.logger.info(('Skipping job with ID %s (no such ' 'implementation: %s)'), job_id, job_impl) continue job = jobs[job_impl](job_config) if app.debug: start_date = datetime.now() + timedelta(seconds=1) else: offset += randint(4, 10) start_date = datetime.now() + timedelta(seconds=offset) job.start_date = start_date app.logger.info('Scheduling job with ID %s (implementation: %s): %s', job_id, job_impl, job) sched.add_job(_run_job, 'interval', name=job_id, next_run_time=job.start_date, coalesce=True, seconds=job.interval, kwargs={ 'job_id': job_id, 'job': job }) if not sched.running: sched.start()
def _run_job(name=None, print_json=False): import json import sys from jobs import load_jobs from pprint import pprint jobs = load_jobs() if name is None or len(name) == 0: names = ' '.join(jobs.keys()) name = input('Name of the job to run [%s]: ' % (names,)).lower() cls = jobs.get(name) if cls is None: print('No such job: %s' % (name,)) sys.exit(1) job_conf = _config()['JOBS'].get(name) if job_conf is None: print('No config found for job: %s' % (name,)) sys.exit(1) job = cls(job_conf) data = job.get() if print_json: print(json.dumps(data, indent=2)) else: pprint(data)
def _run_job(job_id=None, print_json=False): import json import sys from jobs import load_jobs from pprint import pprint enabled_jobs = _enabled_jobs() jobs = load_jobs() if job_id is None or len(job_id) == 0: job_ids = ' '.join(enabled_jobs) job_id = input('Name of the job to run [%s]: ' % (job_ids,)).lower() job_config = _config().get(job_id) if job_config is None: print('No config found for job: %s' % (job_id,)) sys.exit(1) cls = jobs.get(job_config.get('job_impl', job_id)) if cls is None: print('No such job: %s' % (job_id,)) sys.exit(1) job = cls(job_config) data = job.get() if print_json: print(json.dumps(data, indent=2)) else: pprint(data)
def _schedule_jobs(): offset = 0 jobs = load_jobs() for job_id, job_config in _config()['JOBS'].items(): job_impl = job_config.get('job_impl', job_id) if not job_config.get('enabled'): app.logger.info('Skipping disabled job: %s', job_id) continue if job_impl not in jobs: app.logger.info(('Skipping job with ID %s (no such ' 'implementation: %s)'), job_id, job_impl) continue job = jobs[job_impl](job_config) if app.debug: start_date = datetime.now() + timedelta(seconds=1) else: offset += randint(4, 10) start_date = datetime.now() + timedelta(seconds=offset) job.start_date = start_date app.logger.info('Scheduling job with ID %s (implementation: %s): %s', job_id, job_impl, job) sched.add_job(_run_job, 'interval', name=job_id, next_run_time=job.start_date, coalesce=True, seconds=job.interval, kwargs={'job_id': job_id, 'job': job}) if not sched.running: sched.start()
def _run_job(name=None, print_json=False): import json import sys from flask import Flask from jobs import load_jobs from pprint import pprint _app = Flask(__name__) _app.config.from_envvar("JARVIS_SETTINGS") conf = _app.config["JOBS"] jobs = load_jobs() if name is None or len(name) == 0: names = " ".join(jobs.keys()) name = input("Name of the job to run [%s]: " % (names,)).lower() cls = jobs.get(name) if cls is None: print("No such job: %s" % (name,)) sys.exit(1) job_conf = conf.get(name) if job_conf is None: print("No config found for job: %s" % (name,)) sys.exit(1) job = cls(job_conf) data = job.get() if print_json: print(json.dumps(data, indent=2)) else: pprint(data)
def _configure_jobs(): conf = app.config['JOBS'] offset = 0 for name, cls in load_jobs().items(): if not _is_enabled(name, conf): app.logger.info('Skipping disabled job: %s', name) continue job = cls(conf[name]) if app.debug: start_date = datetime.now() + timedelta(seconds=1) else: offset += randint(4, 10) start_date = datetime.now() + timedelta(seconds=offset) job.start_date = start_date app.logger.info('Scheduling job: %s', job) sched.add_interval_job(_run_job, name=name, seconds=job.interval, start_date=job.start_date, kwargs={ 'widget': name, 'job': job }) if not sched.running: sched.start()
def _run_job(name=None): import json import sys from flask import Flask from jobs import load_jobs from pprint import pprint app = Flask(__name__) app.config.from_envvar('JARVIS_SETTINGS') conf = app.config['JOBS'] jobs = load_jobs() if name is None: names = ' '.join(jobs.keys()) name = raw_input('Name of the job to run [%s]: ' % (names,)).lower() print_json = name.endswith('.json') if print_json: name = name.rstrip('.json') cls = jobs.get(name) if cls is None: print('No such job: %s' % (name,)) sys.exit(1) job = cls(conf[name]) data = job.get() if print_json: print(json.dumps(data, indent=2)) else: pprint(data)
def _run_job(name=None, print_json=False): import json import sys from flask import Flask from jobs import load_jobs from pprint import pprint _app = Flask(__name__) _app.config.from_envvar('JARVIS_SETTINGS') conf = _app.config['JOBS'] jobs = load_jobs() if name is None or len(name) == 0: names = ' '.join(jobs.keys()) name = input('Name of the job to run [%s]: ' % (names, )).lower() cls = jobs.get(name) if cls is None: print('No such job: %s' % (name, )) sys.exit(1) job_conf = conf.get(name) if job_conf is None: print('No config found for job: %s' % (name, )) sys.exit(1) job = cls(job_conf) data = job.get() if print_json: print(json.dumps(data, indent=2)) else: pprint(data)
def _schedule_jobs(): offset = 0 jobs = load_jobs() for job_id, job_config in _config()["JOBS"].items(): job_impl = job_config.get("job_impl", job_id) if not job_config.get("enabled"): app.logger.info("Skipping disabled job: %s", job_id) continue if job_impl not in jobs: app.logger.info( ("Skipping job with ID %s (no such " "implementation: %s)"), job_id, job_impl, ) continue job = jobs[job_impl](job_config) if app.debug: start_date = datetime.now() + timedelta(seconds=1) else: offset += randint(4, 10) start_date = datetime.now() + timedelta(seconds=offset) job.start_date = start_date app.logger.info("Scheduling job with ID %s (implementation: %s): %s", job_id, job_impl, job) sched.add_job( _run_job, "interval", name=job_id, next_run_time=job.start_date, coalesce=True, seconds=job.interval, kwargs={ "job_id": job_id, "job": job }, ) if not sched.running: sched.start()
def _configure_jobs(): conf = app.config["JOBS"] offset = 0 for name, cls in load_jobs().items(): if not _is_enabled(name, conf): app.logger.info("Skipping disabled job: %s", name) continue job = cls(conf[name]) if app.debug: start_date = datetime.now() + timedelta(seconds=1) else: offset += randint(4, 10) start_date = datetime.now() + timedelta(seconds=offset) job.start_date = start_date app.logger.info("Scheduling job: %s", job) sched.add_interval_job( _run_job, name=name, seconds=job.interval, start_date=job.start_date, kwargs={"widget": name, "job": job} ) if not sched.running: sched.start()
def _configure_jobs(): conf = app.config['JOBS'] offset = 0 for name, cls in load_jobs().items(): if not _is_enabled(name, conf): logger.info('Skipping disabled job: %s', name) continue job = cls(conf[name]) if app.debug: start_date = datetime.now() + timedelta(seconds=1) else: offset += randint(4, 10) start_date = datetime.now() + timedelta(seconds=offset) logger.info('Configuring job: %s [start_date=%s, seconds=%s]', name, start_date, job.interval) sched.add_interval_job(_run_job, name=name, seconds=job.interval, start_date=start_date, kwargs={'widget': name, 'job': job}) if not sched.running: sched.start()
import jobs import driver import export import settings import timesheet jobs.load_jobs('d:\\jobs2.xls') timesheets = [ timesheet.Timesheet(driver) for driver in driver.Driver.all_drivers() ] export.export('d:\\output2.xlsx', timesheets)