scriptengine 1.0.0rc3__tar.gz → 1.0.0rc4__tar.gz
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.
- {scriptengine-1.0.0rc3/src/scriptengine.egg-info → scriptengine-1.0.0rc4}/PKG-INFO +1 -1
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/pyproject.toml +2 -2
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/command.py +15 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/context.py +6 -8
- scriptengine-1.0.0rc4/src/scriptengine/tasks/core/timing.py +63 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4/src/scriptengine.egg-info}/PKG-INFO +1 -1
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine.egg-info/entry_points.txt +1 -1
- scriptengine-1.0.0rc3/src/scriptengine/tasks/core/timing.py +0 -58
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/LICENSE +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/README.md +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/setup.cfg +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/setup.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/cli/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/cli/se.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/context.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/engines/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/engines/simple_script_engine.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/exceptions.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/helpers/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/helpers/terminal_colors.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/jinja.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/jobs.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/logging.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/chdir.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/echo.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/envvars.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/exit.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/file/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/file/copy.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/file/link.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/file/make_dir.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/file/move.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/file/remove.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/find.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/include.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/task_timer.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/template.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/time.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/core/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/core/loader.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/core/task.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/yaml/__init__.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/yaml/noparse_strings.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/yaml/parser.py +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine.egg-info/SOURCES.txt +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine.egg-info/dependency_links.txt +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine.egg-info/requires.txt +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine.egg-info/top_level.txt +0 -0
- {scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/tests/test_logging.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: scriptengine
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc4
|
|
4
4
|
Summary: A lightweight and extensible framework for executing scripts written in YAML
|
|
5
5
|
Author-email: Uwe Fladrich <uwe.fladrich@protonmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/uwefladrich/scriptengine
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scriptengine"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.0rc4"
|
|
8
8
|
authors = [{ name = "Uwe Fladrich", email = "uwe.fladrich@protonmail.com" }]
|
|
9
9
|
description = "A lightweight and extensible framework for executing scripts written in YAML"
|
|
10
10
|
readme = "README.md"
|
|
@@ -39,7 +39,7 @@ se = "scriptengine.cli.se:main"
|
|
|
39
39
|
"base.chdir" = "scriptengine.tasks.base.chdir:Chdir"
|
|
40
40
|
"base.command" = "scriptengine.tasks.base.command:Command"
|
|
41
41
|
"base.context" = "scriptengine.tasks.base.context:Context"
|
|
42
|
-
"base.context.
|
|
42
|
+
"base.context.load" = "scriptengine.tasks.base.context:ContextLoad"
|
|
43
43
|
"base.copy" = "scriptengine.tasks.base.file.copy:Copy"
|
|
44
44
|
"base.echo" = "scriptengine.tasks.base.echo:Echo"
|
|
45
45
|
"base.exit" = "scriptengine.tasks.base.exit:Exit"
|
|
@@ -10,6 +10,7 @@ import os
|
|
|
10
10
|
import subprocess
|
|
11
11
|
import threading
|
|
12
12
|
from contextlib import contextmanager
|
|
13
|
+
from pathlib import Path
|
|
13
14
|
|
|
14
15
|
from scriptengine.context import Context
|
|
15
16
|
from scriptengine.exceptions import (
|
|
@@ -110,6 +111,19 @@ class Command(Task):
|
|
|
110
111
|
"stderr mode: "
|
|
111
112
|
f'{stderr_mode if stderr_mode in (True, False) else "context"}'
|
|
112
113
|
)
|
|
114
|
+
|
|
115
|
+
# Update $PWD in the environment of the command
|
|
116
|
+
# Once support for Python<=3.8 is dropped, this can be done directly in the
|
|
117
|
+
# call to subprocess.run() below:
|
|
118
|
+
# subprocess.run(
|
|
119
|
+
# ...
|
|
120
|
+
# env=os.environ | {"PWD": Path(cwd).resolve()} if cwd else {},
|
|
121
|
+
# ...
|
|
122
|
+
# )
|
|
123
|
+
cmd_env = os.environ.copy()
|
|
124
|
+
if cwd:
|
|
125
|
+
cmd_env["PWD"] = Path(cwd).resolve()
|
|
126
|
+
|
|
113
127
|
with log_pipe(stdout_mode) as stdout, log_pipe(stderr_mode) as stderr:
|
|
114
128
|
context_update = Context()
|
|
115
129
|
try:
|
|
@@ -119,6 +133,7 @@ class Command(Task):
|
|
|
119
133
|
stderr=stderr,
|
|
120
134
|
cwd=cwd,
|
|
121
135
|
check=True,
|
|
136
|
+
env=cmd_env,
|
|
122
137
|
errors="replace",
|
|
123
138
|
)
|
|
124
139
|
except subprocess.CalledProcessError as e:
|
|
@@ -27,7 +27,7 @@ class Context(Task):
|
|
|
27
27
|
return context_update
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
class
|
|
30
|
+
class ContextLoad(Task):
|
|
31
31
|
"""
|
|
32
32
|
This task updates the context, just as the Context task, but from sources
|
|
33
33
|
other than direct arguments.
|
|
@@ -38,13 +38,13 @@ class ContextFrom(Task):
|
|
|
38
38
|
- base.context:
|
|
39
39
|
upd:
|
|
40
40
|
foo: 1
|
|
41
|
-
- base.context.
|
|
41
|
+
- base.context.load:
|
|
42
42
|
dict: "{{upd}}"
|
|
43
43
|
|
|
44
44
|
If the 'file' argument is given, the argument value must be a file name and
|
|
45
45
|
the context is updated from the file context. The file format must be YAML:
|
|
46
46
|
|
|
47
|
-
- base.context.
|
|
47
|
+
- base.context.load:
|
|
48
48
|
file: update.yml
|
|
49
49
|
"""
|
|
50
50
|
|
|
@@ -58,7 +58,7 @@ class ContextFrom(Task):
|
|
|
58
58
|
raise ScriptEngineTaskError
|
|
59
59
|
|
|
60
60
|
if dict_arg:
|
|
61
|
-
self.log_info(f"
|
|
61
|
+
self.log_info(f"Load context update from dict: {dict_arg}")
|
|
62
62
|
if not isinstance(dict_arg, dict):
|
|
63
63
|
self.log_error(
|
|
64
64
|
"The 'dict' argument must be a dictionary "
|
|
@@ -68,7 +68,7 @@ class ContextFrom(Task):
|
|
|
68
68
|
context_update_d = dict_arg
|
|
69
69
|
|
|
70
70
|
elif file_arg:
|
|
71
|
-
self.log_info(f"
|
|
71
|
+
self.log_info(f"Load context update from file: {file_arg}")
|
|
72
72
|
try:
|
|
73
73
|
with open(file_arg) as f:
|
|
74
74
|
dict_from_file = yaml.load(f, Loader=yaml.SafeLoader)
|
|
@@ -78,9 +78,7 @@ class ContextFrom(Task):
|
|
|
78
78
|
except yaml.scanner.ScannerError as e:
|
|
79
79
|
self.log_error("Error reading the file as YAML, error message follows:")
|
|
80
80
|
self.log_error(f" {''.join(str(e).splitlines())}")
|
|
81
|
-
self.log_error(
|
|
82
|
-
"Note that only YAML file are supported by base.context.from"
|
|
83
|
-
)
|
|
81
|
+
self.log_error("Note: base.context.load supports only YAML files")
|
|
84
82
|
raise ScriptEngineTaskRunError
|
|
85
83
|
if not isinstance(dict_from_file, dict):
|
|
86
84
|
self.log_error(
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""ScriptEngine timing for tasks: provides timing of Task classes .run() method
|
|
2
|
+
"""
|
|
3
|
+
|
|
4
|
+
import copy
|
|
5
|
+
import functools
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
from scriptengine.context import Context
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def timed_runner(func):
|
|
12
|
+
"""Wrapper for run() functions of SE tasks. To be used as decorator as follows:
|
|
13
|
+
|
|
14
|
+
from scriptengine.task_timing import timed_runner
|
|
15
|
+
class Foo(Task):
|
|
16
|
+
# ...
|
|
17
|
+
@timed_runner
|
|
18
|
+
def run(self, context):
|
|
19
|
+
# ...
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
@functools.wraps(func)
|
|
23
|
+
def wrap_timed(self, context):
|
|
24
|
+
|
|
25
|
+
mode = context.get("se.tasks.timing.mode")
|
|
26
|
+
|
|
27
|
+
if mode in ("basic", "classes", "instances"):
|
|
28
|
+
|
|
29
|
+
# timed function call
|
|
30
|
+
start_tic = time.perf_counter()
|
|
31
|
+
context_update = func(self, context) or Context()
|
|
32
|
+
elapsed_time = time.perf_counter() - start_tic
|
|
33
|
+
|
|
34
|
+
# logging
|
|
35
|
+
if context["se.tasks.timing.logging"] == "info":
|
|
36
|
+
self.log_info(f"Elapsed time: {elapsed_time:0.4f} seconds")
|
|
37
|
+
elif context["se.tasks.timing.logging"] == "debug":
|
|
38
|
+
self.log_debug(f"Elapsed time: {elapsed_time:0.4f} seconds")
|
|
39
|
+
|
|
40
|
+
# update timers
|
|
41
|
+
if mode in ("classes", "instances"):
|
|
42
|
+
timers = copy.deepcopy(context["se.tasks.timing.timers"])
|
|
43
|
+
|
|
44
|
+
class_t = timers.setdefault("classes", {})
|
|
45
|
+
class_t.setdefault(self.__class__.__name__, 0)
|
|
46
|
+
class_t[self.__class__.__name__] += elapsed_time
|
|
47
|
+
|
|
48
|
+
if mode == "instances":
|
|
49
|
+
instance_t = timers.setdefault("instances", {})
|
|
50
|
+
instance_t.setdefault(self.id, 0)
|
|
51
|
+
instance_t[self.id] += elapsed_time
|
|
52
|
+
|
|
53
|
+
timer_update = Context()
|
|
54
|
+
timer_update["se.tasks.timing.timers"] = timers
|
|
55
|
+
|
|
56
|
+
context_update += timer_update
|
|
57
|
+
|
|
58
|
+
return context_update
|
|
59
|
+
|
|
60
|
+
# if no timing, just return the function
|
|
61
|
+
return func(self, context)
|
|
62
|
+
|
|
63
|
+
return wrap_timed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: scriptengine
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc4
|
|
4
4
|
Summary: A lightweight and extensible framework for executing scripts written in YAML
|
|
5
5
|
Author-email: Uwe Fladrich <uwe.fladrich@protonmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/uwefladrich/scriptengine
|
|
@@ -5,7 +5,7 @@ se = scriptengine.cli.se:main
|
|
|
5
5
|
base.chdir = scriptengine.tasks.base.chdir:Chdir
|
|
6
6
|
base.command = scriptengine.tasks.base.command:Command
|
|
7
7
|
base.context = scriptengine.tasks.base.context:Context
|
|
8
|
-
base.context.
|
|
8
|
+
base.context.load = scriptengine.tasks.base.context:ContextLoad
|
|
9
9
|
base.copy = scriptengine.tasks.base.file.copy:Copy
|
|
10
10
|
base.echo = scriptengine.tasks.base.echo:Echo
|
|
11
11
|
base.exit = scriptengine.tasks.base.exit:Exit
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"""ScriptEngine timing for tasks: provides timing of Task classes .run() method
|
|
2
|
-
"""
|
|
3
|
-
|
|
4
|
-
import time
|
|
5
|
-
import functools
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def timed_runner(func):
|
|
9
|
-
"""Wrapper for run() functions of SE tasks. To be used as decorator as follows:
|
|
10
|
-
|
|
11
|
-
from scriptengine.task_timing import timed_runner
|
|
12
|
-
class Foo(Task):
|
|
13
|
-
# ...
|
|
14
|
-
@timed_runner
|
|
15
|
-
def run(self, context):
|
|
16
|
-
# ...
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
@functools.wraps(func)
|
|
20
|
-
def wrap_timed(self, context):
|
|
21
|
-
|
|
22
|
-
try:
|
|
23
|
-
mode = context['se']['tasks']['timing']['mode']
|
|
24
|
-
except KeyError:
|
|
25
|
-
mode = False
|
|
26
|
-
|
|
27
|
-
if mode in ('basic', 'classes', 'instances'):
|
|
28
|
-
|
|
29
|
-
# timed function call
|
|
30
|
-
start_tic = time.perf_counter()
|
|
31
|
-
func_return_value = func(self, context)
|
|
32
|
-
elapsed_time = time.perf_counter() - start_tic
|
|
33
|
-
|
|
34
|
-
# logging
|
|
35
|
-
if context['se']['tasks']['timing']['logging'] == 'info':
|
|
36
|
-
self.log_info(f'Elapsed time: {elapsed_time:0.4f} seconds')
|
|
37
|
-
elif context['se']['tasks']['timing']['logging'] == 'debug':
|
|
38
|
-
self.log_debug(f'Elapsed time: {elapsed_time:0.4f} seconds')
|
|
39
|
-
|
|
40
|
-
# update timers
|
|
41
|
-
if mode in ('classes', 'instances'):
|
|
42
|
-
timers = context['se']['tasks']['timing']['timers']
|
|
43
|
-
|
|
44
|
-
class_t = timers.setdefault('classes', {})
|
|
45
|
-
class_t.setdefault(self.__class__.__name__, 0)
|
|
46
|
-
class_t[self.__class__.__name__] += elapsed_time
|
|
47
|
-
|
|
48
|
-
if mode == 'instances':
|
|
49
|
-
instance_t = timers.setdefault('instances', {})
|
|
50
|
-
instance_t.setdefault(self.id, 0)
|
|
51
|
-
instance_t[self.id] += elapsed_time
|
|
52
|
-
|
|
53
|
-
return func_return_value
|
|
54
|
-
|
|
55
|
-
# if no timing, just return the function
|
|
56
|
-
return func(self, context)
|
|
57
|
-
|
|
58
|
-
return wrap_timed
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/engines/simple_script_engine.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/file/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine/tasks/base/file/make_dir.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scriptengine-1.0.0rc3 → scriptengine-1.0.0rc4}/src/scriptengine.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|