schd 0.0.5__py3-none-any.whl → 0.0.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- schd/__init__.py +1 -1
- schd/cmds/daemon.py +2 -2
- schd/cmds/jobs.py +19 -0
- schd/cmds/run.py +6 -7
- schd/cmds/schd.py +3 -1
- schd/scheduler.py +15 -3
- {schd-0.0.5.dist-info → schd-0.0.7.dist-info}/METADATA +1 -1
- schd-0.0.7.dist-info/RECORD +14 -0
- schd-0.0.5.dist-info/RECORD +0 -13
- {schd-0.0.5.dist-info → schd-0.0.7.dist-info}/LICENSE +0 -0
- {schd-0.0.5.dist-info → schd-0.0.7.dist-info}/WHEEL +0 -0
- {schd-0.0.5.dist-info → schd-0.0.7.dist-info}/entry_points.txt +0 -0
- {schd-0.0.5.dist-info → schd-0.0.7.dist-info}/top_level.txt +0 -0
schd/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.0.
|
1
|
+
__version__ = '0.0.7'
|
schd/cmds/daemon.py
CHANGED
@@ -7,11 +7,11 @@ from schd import __version__ as schd_version
|
|
7
7
|
|
8
8
|
class DaemonCommand(CommandBase):
|
9
9
|
def add_arguments(self, parser):
|
10
|
-
parser.add_argument('--config')
|
10
|
+
parser.add_argument('--config', '-c')
|
11
11
|
parser.add_argument('--logfile')
|
12
12
|
|
13
13
|
def run(self, args):
|
14
|
-
config_file = args.config
|
14
|
+
config_file = args.config
|
15
15
|
print(f'starting schd, {schd_version}, config_file={config_file}')
|
16
16
|
|
17
17
|
if args.logfile:
|
schd/cmds/jobs.py
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
"""
|
2
|
+
list jobs
|
3
|
+
"""
|
4
|
+
|
5
|
+
from schd.scheduler import read_config
|
6
|
+
from .base import CommandBase
|
7
|
+
|
8
|
+
|
9
|
+
class JobsCommand(CommandBase):
|
10
|
+
def add_arguments(self, parser):
|
11
|
+
parser.add_argument('--config', '-c', default=None, help='config file')
|
12
|
+
|
13
|
+
def run(self, args):
|
14
|
+
config = read_config(config_file=args.config)
|
15
|
+
for job_name, job_config in config['jobs'].items():
|
16
|
+
job_class_name = job_config.pop('class')
|
17
|
+
job_cron = job_config.pop('cron')
|
18
|
+
# print(f'{job_name} : {job_class_name} {job_cron}')
|
19
|
+
print(job_name)
|
schd/cmds/run.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import yaml
|
2
2
|
from schd.cmds.base import CommandBase
|
3
|
-
from schd.scheduler import build_job
|
3
|
+
from schd.scheduler import build_job, read_config
|
4
4
|
|
5
5
|
|
6
|
-
def run_job(
|
7
|
-
|
8
|
-
config = yaml.load(f, Loader=yaml.FullLoader)
|
6
|
+
def run_job(config_file, job_name):
|
7
|
+
config = read_config(config_file)
|
9
8
|
|
10
9
|
job_config = config['jobs'][job_name]
|
11
10
|
|
@@ -18,9 +17,9 @@ def run_job(config_filepath, job_name):
|
|
18
17
|
class RunCommand(CommandBase):
|
19
18
|
def add_arguments(self, parser):
|
20
19
|
parser.add_argument('job')
|
21
|
-
parser.add_argument('--config')
|
20
|
+
parser.add_argument('--config', '-c')
|
22
21
|
|
23
22
|
def run(self, args):
|
24
23
|
job_name = args.job
|
25
|
-
|
26
|
-
run_job(
|
24
|
+
config_file = args.config
|
25
|
+
run_job(config_file, job_name)
|
schd/cmds/schd.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import argparse
|
2
2
|
import sys
|
3
|
+
from schd.cmds.jobs import JobsCommand
|
3
4
|
from schd.scheduler import main as scheduler_main
|
4
5
|
from .daemon import DaemonCommand
|
5
6
|
from .run import RunCommand
|
@@ -8,13 +9,14 @@ from schd import __version__ as schd_version
|
|
8
9
|
commands = {
|
9
10
|
'daemon': DaemonCommand(),
|
10
11
|
'run': RunCommand(),
|
12
|
+
'jobs': JobsCommand(),
|
11
13
|
}
|
12
14
|
|
13
15
|
def main():
|
14
16
|
sys.path.append('.')
|
15
17
|
parser = argparse.ArgumentParser('schd')
|
16
18
|
parser.add_argument('--version', action='store_true', default=False)
|
17
|
-
sub_command_parsers = parser.add_subparsers(dest='cmd'
|
19
|
+
sub_command_parsers = parser.add_subparsers(dest='cmd')
|
18
20
|
|
19
21
|
for cmd, cmd_obj in commands.items():
|
20
22
|
sub_command_parser = sub_command_parsers.add_parser(cmd)
|
schd/scheduler.py
CHANGED
@@ -48,11 +48,23 @@ class CommandJob:
|
|
48
48
|
self.logger.info('process output %s', p.stdout)
|
49
49
|
|
50
50
|
|
51
|
-
def
|
52
|
-
|
51
|
+
def read_config(config_file=None):
|
52
|
+
if config_file is None and 'SCHD_CONFIG' in os.environ:
|
53
|
+
config_file = os.environ['SCHD_CONFIG']
|
54
|
+
|
55
|
+
if config_file is None:
|
56
|
+
config_file = 'conf/schd.yaml'
|
57
|
+
|
53
58
|
with open(config_file, 'r', encoding='utf8') as f:
|
54
59
|
config = yaml.load(f, Loader=yaml.FullLoader)
|
55
60
|
|
61
|
+
return config
|
62
|
+
|
63
|
+
|
64
|
+
def run_daemon(config_file=None):
|
65
|
+
config = read_config(config_file=config_file)
|
66
|
+
sched = BlockingScheduler(executors={'default': ThreadPoolExecutor(10)})
|
67
|
+
|
56
68
|
for job_name, job_config in config['jobs'].items():
|
57
69
|
job_class_name = job_config.pop('class')
|
58
70
|
job_cron = job_config.pop('cron')
|
@@ -68,7 +80,7 @@ def main():
|
|
68
80
|
parser.add_argument('--logfile')
|
69
81
|
parser.add_argument('--config', '-c')
|
70
82
|
args = parser.parse_args()
|
71
|
-
config_file = args.config
|
83
|
+
config_file = args.config
|
72
84
|
|
73
85
|
print(f'starting schd, {schd_version}, config_file={config_file}')
|
74
86
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
schd/__init__.py,sha256=o2tGYREXqDG1xawirGQcKQH9jzwhG8BDzpSJ7CU7jJw,23
|
2
|
+
schd/scheduler.py,sha256=bdyherr29aag4VC1c_CQX76I3s3uK9CbywMYaTdM_HA,3178
|
3
|
+
schd/cmds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
schd/cmds/base.py,sha256=ZnNcJozQFLbpYyNp8dhHzm3BzFQa0hm6KyCC6URfueY,122
|
5
|
+
schd/cmds/daemon.py,sha256=Nze0xR0YwfOP2myFgL2kfT6qubtdfEjWWegtYtoHgD0,851
|
6
|
+
schd/cmds/jobs.py,sha256=843M6rcMjqmm8yevHF4QsJxc0fw8LQfSX7OEA_OH0Dg,590
|
7
|
+
schd/cmds/run.py,sha256=sJxXtUdnV1SW523E9L6e2u_2nUEHtWBqQ91P9lI1new,675
|
8
|
+
schd/cmds/schd.py,sha256=vOlfQCQT81KhLMvlP3tlymEWpxmqlBOa5vnJoeFXVlw,996
|
9
|
+
schd-0.0.7.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
10
|
+
schd-0.0.7.dist-info/METADATA,sha256=_Q4HQ_C9Y3DfuICYJN8jLEqwyVKn9_TsEJ8sUGNZpS4,238
|
11
|
+
schd-0.0.7.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
12
|
+
schd-0.0.7.dist-info/entry_points.txt,sha256=iVyQSrYOYw0BclgHg9SUeNg9hDg_jeDuUxhvKIcKeSY,46
|
13
|
+
schd-0.0.7.dist-info/top_level.txt,sha256=Vojim8xSOsYyQHrZBNhx7n0F7WqbEJ2SeBFAvEnrJ_U,5
|
14
|
+
schd-0.0.7.dist-info/RECORD,,
|
schd-0.0.5.dist-info/RECORD
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
schd/__init__.py,sha256=oedSZad_JDN4BR_mI8rvEHJyWG4WRSq4bXQcl3dfcYk,23
|
2
|
-
schd/scheduler.py,sha256=tocH0r5w-1TRnlu3UwOaKSKIkuViDsr-I3z6F551VIQ,2898
|
3
|
-
schd/cmds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
schd/cmds/base.py,sha256=ZnNcJozQFLbpYyNp8dhHzm3BzFQa0hm6KyCC6URfueY,122
|
5
|
-
schd/cmds/daemon.py,sha256=5qLwzJwmWhZ6IzY-5mgatft4gKaohoJUCdGodW3Klcc,865
|
6
|
-
schd/cmds/run.py,sha256=gjk2Q74rFmaR2jBNQMZA-oSllbhc4-vXWd-JC49roc4,744
|
7
|
-
schd/cmds/schd.py,sha256=VPw-wkMNRKL-M983Y6PrzFWQZTHWhq1ZweBqTZfi1L0,944
|
8
|
-
schd-0.0.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
9
|
-
schd-0.0.5.dist-info/METADATA,sha256=nXleCw14k0gUSlsITLlpo6DOcCZiQmzgdr4SX5evdq8,238
|
10
|
-
schd-0.0.5.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
11
|
-
schd-0.0.5.dist-info/entry_points.txt,sha256=iVyQSrYOYw0BclgHg9SUeNg9hDg_jeDuUxhvKIcKeSY,46
|
12
|
-
schd-0.0.5.dist-info/top_level.txt,sha256=Vojim8xSOsYyQHrZBNhx7n0F7WqbEJ2SeBFAvEnrJ_U,5
|
13
|
-
schd-0.0.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|