blue-assistant 4.32.1__py3-none-any.whl → 4.43.1__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.
- blue_assistant/.abcli/script/run.sh +9 -3
- blue_assistant/.abcli/tests/script_run.sh +21 -5
- blue_assistant/__init__.py +2 -2
- blue_assistant/help/script.py +10 -2
- blue_assistant/script/__main__.py +21 -5
- blue_assistant/script/load.py +17 -0
- blue_assistant/script/repository/__init__.py +15 -0
- blue_assistant/script/repository/blue_amo/__init__.py +1 -0
- blue_assistant/script/repository/blue_amo/classes.py +42 -0
- blue_assistant/script/repository/generic/__init__.py +1 -0
- blue_assistant/script/repository/generic/classes.py +51 -0
- blue_assistant/script/repository/moon_datasets/__init__.py +1 -0
- blue_assistant/script/repository/moon_datasets/classes.py +16 -0
- {blue_assistant-4.32.1.dist-info → blue_assistant-4.43.1.dist-info}/METADATA +8 -6
- {blue_assistant-4.32.1.dist-info → blue_assistant-4.43.1.dist-info}/RECORD +18 -14
- blue_assistant/script/blue_amo.py +0 -18
- blue_assistant/script/functions.py +0 -40
- blue_assistant/script/generic.py +0 -41
- blue_assistant/script/kinds.py +0 -6
- {blue_assistant-4.32.1.dist-info → blue_assistant-4.43.1.dist-info}/LICENSE +0 -0
- {blue_assistant-4.32.1.dist-info → blue_assistant-4.43.1.dist-info}/WHEEL +0 -0
- {blue_assistant-4.32.1.dist-info → blue_assistant-4.43.1.dist-info}/top_level.txt +0 -0
@@ -3,18 +3,24 @@
|
|
3
3
|
function blue_assistant_script_run() {
|
4
4
|
local options=$1
|
5
5
|
local do_dryrun=$(abcli_option_int "$options" dryrun 0)
|
6
|
-
local do_download=$(abcli_option_int "$options" download
|
6
|
+
local do_download=$(abcli_option_int "$options" download 0)
|
7
7
|
local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun))
|
8
8
|
|
9
|
-
local
|
9
|
+
local script_options=$2
|
10
|
+
local script_name=$(abcli_option "$script_options" script generic)
|
11
|
+
|
12
|
+
local object_name=$(abcli_clarify_object $3 $script_name-$(abcli_string_timestamp_short))
|
10
13
|
[[ "$do_download" == 1 ]] &&
|
11
14
|
abcli_download - $object_name
|
12
15
|
|
16
|
+
abcli_log "running $script_name -> $object_name ..."
|
17
|
+
|
13
18
|
abcli_eval dryrun=$do_dryrun \
|
14
19
|
python3 -m blue_assistant.script \
|
15
20
|
run \
|
21
|
+
--script_name $script_name \
|
16
22
|
--object_name $object_name \
|
17
|
-
"${@:
|
23
|
+
"${@:4}"
|
18
24
|
[[ $? -ne 0 ]] && return 1
|
19
25
|
|
20
26
|
[[ "$do_upload" == 1 ]] &&
|
@@ -2,10 +2,26 @@
|
|
2
2
|
|
3
3
|
function test_blue_assistant_script_run() {
|
4
4
|
local options=$1
|
5
|
+
local list_of_script_name=$(python3 -m blue_assistant.script \
|
6
|
+
get_list_of \
|
7
|
+
--delim +)
|
8
|
+
list_of_script_name=$(abcli_option "$options" script $list_of_script_name)
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
local script_name
|
11
|
+
for script_name in $(echo "$list_of_script_name" | tr + " "); do
|
12
|
+
abcli_log "testing $script_name ..."
|
13
|
+
|
14
|
+
abcli_eval ,$options \
|
15
|
+
blue_assistant_script_run \
|
16
|
+
~upload,$options \
|
17
|
+
script=$script_name \
|
18
|
+
test_blue_assistant_script_run-$(abcli_string_timestamp_short) \
|
19
|
+
"${@:2}"
|
20
|
+
|
21
|
+
[[ $? -ne 0 ]] && return 1
|
22
|
+
|
23
|
+
abcli_hr
|
24
|
+
done
|
25
|
+
|
26
|
+
return 0
|
11
27
|
}
|
blue_assistant/__init__.py
CHANGED
blue_assistant/help/script.py
CHANGED
@@ -2,12 +2,16 @@ from typing import List
|
|
2
2
|
|
3
3
|
from blue_options.terminal import show_usage, xtra
|
4
4
|
|
5
|
+
from blue_assistant.script.repository import list_of_script_names
|
6
|
+
|
5
7
|
|
6
8
|
def help_run(
|
7
9
|
tokens: List[str],
|
8
10
|
mono: bool,
|
9
11
|
) -> str:
|
10
|
-
options = xtra("
|
12
|
+
options = xtra("download,dryrun,~upload", mono=mono)
|
13
|
+
|
14
|
+
script_options = "script=<script>"
|
11
15
|
|
12
16
|
args = ["--verbose 1"]
|
13
17
|
|
@@ -17,10 +21,14 @@ def help_run(
|
|
17
21
|
"script",
|
18
22
|
"run",
|
19
23
|
f"[{options}]",
|
20
|
-
"[
|
24
|
+
f"[{script_options}]",
|
25
|
+
"[-|<object-name>]",
|
21
26
|
]
|
22
27
|
+ args,
|
23
28
|
"run <object-name>.",
|
29
|
+
{
|
30
|
+
"script: {}".format(" | ".join(list_of_script_names)): [],
|
31
|
+
},
|
24
32
|
mono=mono,
|
25
33
|
)
|
26
34
|
|
@@ -4,7 +4,8 @@ from blueness import module
|
|
4
4
|
from blueness.argparse.generic import sys_exit
|
5
5
|
|
6
6
|
from blue_assistant import NAME
|
7
|
-
from blue_assistant.script.
|
7
|
+
from blue_assistant.script.load import load_script
|
8
|
+
from blue_assistant.script.repository import list_of_script_names
|
8
9
|
from blue_assistant.logger import logger
|
9
10
|
|
10
11
|
NAME = module.name(__file__, NAME)
|
@@ -13,7 +14,12 @@ parser = argparse.ArgumentParser(NAME)
|
|
13
14
|
parser.add_argument(
|
14
15
|
"task",
|
15
16
|
type=str,
|
16
|
-
help="run",
|
17
|
+
help="get_list_of | run",
|
18
|
+
)
|
19
|
+
parser.add_argument(
|
20
|
+
"--script_name",
|
21
|
+
type=str,
|
22
|
+
help=" | ".join(list_of_script_names),
|
17
23
|
)
|
18
24
|
parser.add_argument(
|
19
25
|
"--object_name",
|
@@ -25,17 +31,27 @@ parser.add_argument(
|
|
25
31
|
default=0,
|
26
32
|
help="0 | 1",
|
27
33
|
)
|
34
|
+
parser.add_argument(
|
35
|
+
"--delim",
|
36
|
+
type=str,
|
37
|
+
default="+",
|
38
|
+
)
|
28
39
|
args = parser.parse_args()
|
29
40
|
|
41
|
+
delim = " " if args.delim == "space" else args.delim
|
42
|
+
|
30
43
|
success = False
|
31
|
-
if args.task == "
|
44
|
+
if args.task == "get_list_of":
|
45
|
+
success = True
|
46
|
+
print(delim.join(list_of_script_names))
|
47
|
+
elif args.task == "run":
|
32
48
|
success, script = load_script(
|
33
|
-
|
49
|
+
script_name=args.script_name,
|
34
50
|
verbose=args.verbose == 1,
|
35
51
|
)
|
36
52
|
|
37
53
|
if success:
|
38
|
-
success = script.run()
|
54
|
+
success = script.run(object_name=args.object_name)
|
39
55
|
else:
|
40
56
|
success = None
|
41
57
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from typing import Tuple
|
2
|
+
|
3
|
+
from blue_assistant.script.repository import list_of_script_classes
|
4
|
+
from blue_assistant.script.repository.generic import GenericScript
|
5
|
+
from blue_assistant.logger import logger
|
6
|
+
|
7
|
+
|
8
|
+
def load_script(
|
9
|
+
script_name: str,
|
10
|
+
verbose: bool = False,
|
11
|
+
) -> Tuple[bool, GenericScript]:
|
12
|
+
for script_class in list_of_script_classes:
|
13
|
+
if script_class.name == script_name:
|
14
|
+
return True, script_class(verbose=verbose)
|
15
|
+
|
16
|
+
logger.error(f"{script_name}: script not found.")
|
17
|
+
return False, GenericScript(verbose=verbose)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from typing import List, Type
|
2
|
+
|
3
|
+
from blue_assistant.script.repository.generic import GenericScript
|
4
|
+
from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
|
5
|
+
from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript
|
6
|
+
|
7
|
+
list_of_script_classes: List[Type[GenericScript]] = [
|
8
|
+
GenericScript,
|
9
|
+
BlueAmoScript,
|
10
|
+
MiningOnMoonScript,
|
11
|
+
]
|
12
|
+
|
13
|
+
list_of_script_names: List[str] = [
|
14
|
+
script_class.name for script_class in list_of_script_classes
|
15
|
+
]
|
@@ -0,0 +1 @@
|
|
1
|
+
from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from tqdm import tqdm
|
3
|
+
|
4
|
+
from blue_objects import file, path
|
5
|
+
from blue_objects.metadata import post_to_object
|
6
|
+
|
7
|
+
from blue_assistant.script.repository.generic.classes import GenericScript
|
8
|
+
from blue_assistant.logger import logger
|
9
|
+
|
10
|
+
|
11
|
+
class BlueAmoScript(GenericScript):
|
12
|
+
name = path.name(file.path(__file__))
|
13
|
+
|
14
|
+
def __init__(
|
15
|
+
self,
|
16
|
+
verbose: bool = False,
|
17
|
+
):
|
18
|
+
super().__init__(verbose=verbose)
|
19
|
+
|
20
|
+
def run(
|
21
|
+
self,
|
22
|
+
object_name: str,
|
23
|
+
) -> bool:
|
24
|
+
if not super().run(object_name=object_name):
|
25
|
+
return False
|
26
|
+
|
27
|
+
metadata: Dict[Dict] = {"nodes": {}}
|
28
|
+
for node_name, node in tqdm(self.script["nodes"].items()):
|
29
|
+
logger.info(
|
30
|
+
"{}{}".format(
|
31
|
+
node_name,
|
32
|
+
f": {node}" if self.verbose else " ...",
|
33
|
+
)
|
34
|
+
)
|
35
|
+
|
36
|
+
metadata["nodes"][node_name] = "..."
|
37
|
+
|
38
|
+
return post_to_object(
|
39
|
+
object_name,
|
40
|
+
"output",
|
41
|
+
metadata,
|
42
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
from blue_assistant.script.repository.generic.classes import GenericScript
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from blueness import module
|
4
|
+
from blue_objects import file, path
|
5
|
+
from blue_objects.metadata import post_to_object
|
6
|
+
|
7
|
+
from blue_assistant import NAME
|
8
|
+
from blue_assistant.logger import logger
|
9
|
+
|
10
|
+
|
11
|
+
NAME = module.name(__file__, NAME)
|
12
|
+
|
13
|
+
|
14
|
+
class GenericScript:
|
15
|
+
name = path.name(file.path(__file__))
|
16
|
+
|
17
|
+
def __init__(
|
18
|
+
self,
|
19
|
+
verbose: bool = False,
|
20
|
+
):
|
21
|
+
self.verbose = verbose
|
22
|
+
|
23
|
+
metadata_filename = os.path.join(
|
24
|
+
file.path(__file__),
|
25
|
+
f"../{self.name}",
|
26
|
+
"metadata.yaml",
|
27
|
+
)
|
28
|
+
success, self.metadata = file.load_yaml(metadata_filename)
|
29
|
+
|
30
|
+
self.script = self.metadata.get("script", [])
|
31
|
+
|
32
|
+
assert success, f"cannot load {self.name}/metadata.yaml"
|
33
|
+
|
34
|
+
def run(
|
35
|
+
self,
|
36
|
+
object_name: str,
|
37
|
+
) -> bool:
|
38
|
+
logger.info(
|
39
|
+
"{}.run: {}:{} -> {}".format(
|
40
|
+
NAME,
|
41
|
+
self.__class__.__name__,
|
42
|
+
self.name,
|
43
|
+
object_name,
|
44
|
+
)
|
45
|
+
)
|
46
|
+
|
47
|
+
return post_to_object(
|
48
|
+
object_name,
|
49
|
+
"input",
|
50
|
+
self.script,
|
51
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from tqdm import tqdm
|
3
|
+
|
4
|
+
from blue_objects import file, path
|
5
|
+
|
6
|
+
from blue_assistant.script.repository.generic.classes import GenericScript
|
7
|
+
|
8
|
+
|
9
|
+
class MiningOnMoonScript(GenericScript):
|
10
|
+
name = path.name(file.path(__file__))
|
11
|
+
|
12
|
+
def __init__(
|
13
|
+
self,
|
14
|
+
verbose: bool = False,
|
15
|
+
):
|
16
|
+
super().__init__(verbose=verbose)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: blue_assistant
|
3
|
-
Version: 4.
|
4
|
-
Summary:
|
3
|
+
Version: 4.43.1
|
4
|
+
Summary: 🧠 An AI Assistant.
|
5
5
|
Home-page: https://github.com/kamangir/blue-assistant
|
6
6
|
Author: Arash Abadpour (Kamangir)
|
7
7
|
Author-email: arash@kamangir.net
|
@@ -38,9 +38,9 @@ Dynamic: license
|
|
38
38
|
Dynamic: requires-dist
|
39
39
|
Dynamic: summary
|
40
40
|
|
41
|
-
#
|
41
|
+
# 🧠 blue-assistant
|
42
42
|
|
43
|
-
|
43
|
+
🧠 `@assistant` is an AI assistant.
|
44
44
|
|
45
45
|
```bash
|
46
46
|
pip install blue-assistant
|
@@ -48,10 +48,12 @@ pip install blue-assistant
|
|
48
48
|
|
49
49
|
```mermaid
|
50
50
|
graph LR
|
51
|
-
assistant_script_run["@assistant<br>script<br>run -<br><object-name>"]
|
51
|
+
assistant_script_run["@assistant<br>script<br>run -<br><script><br><object-name>"]
|
52
52
|
|
53
|
+
script["📜 script"]:::folder
|
53
54
|
object["📂 object"]:::folder
|
54
55
|
|
56
|
+
script --> assistant_script_run
|
55
57
|
object --> assistant_script_run
|
56
58
|
assistant_script_run --> object
|
57
59
|
|
@@ -63,4 +65,4 @@ graph LR
|
|
63
65
|
|
64
66
|
[](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [](https://pypi.org/project/blue-assistant/) [](https://pypistats.org/packages/blue-assistant)
|
65
67
|
|
66
|
-
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on
|
68
|
+
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.43.1`](https://github.com/kamangir/blue-assistant).
|
@@ -1,5 +1,5 @@
|
|
1
1
|
blue_assistant/README.py,sha256=q6EWCy7zojQESGDF-2xEoXS1Bl0wRJTe2jw_1QM_WYw,600
|
2
|
-
blue_assistant/__init__.py,sha256=
|
2
|
+
blue_assistant/__init__.py,sha256=BvFZ2zMLuhu23_eXZnSReXQU0tuNy0WUnaYXWAfEiNw,310
|
3
3
|
blue_assistant/__main__.py,sha256=URtal70XZc0--3FDTYWcLtnGOqBYjMX9gt-L1k8hDXI,361
|
4
4
|
blue_assistant/config.env,sha256=es6XIU6yOA69IV0WXtLru5uTM5Dvvmq-q6BJmcE8NyY,36
|
5
5
|
blue_assistant/env.py,sha256=TG2YL5jn7qJApHIGi7IuXvqcPFT771zXKJHomGC63Z4,189
|
@@ -14,23 +14,27 @@ blue_assistant/.abcli/alias.sh,sha256=MCJzXaDnX1QMllWsZJJkDePBYt1nY9ZWa3o4msfGD2
|
|
14
14
|
blue_assistant/.abcli/blue_assistant.sh,sha256=plLTQQerVmfb_SNlOkv0MEaQCF7YdsOHzCq0M3FWT4c,239
|
15
15
|
blue_assistant/.abcli/browse.sh,sha256=qZ_RK_WnsjmF-hfWKiMEOnnv22QtZh9HQ0VFJUbP6aI,294
|
16
16
|
blue_assistant/.abcli/script.sh,sha256=XIkY4eZyFPKLi_mLoPMbnq76E4K1GG3xxha8VYJC2zI,356
|
17
|
-
blue_assistant/.abcli/script/run.sh,sha256=
|
17
|
+
blue_assistant/.abcli/script/run.sh,sha256=kSXmyM9NUj2X2orSGyu5t_P5frG-gyumbRq-xqF692c,911
|
18
18
|
blue_assistant/.abcli/tests/README.sh,sha256=Qs0YUxVB1OZZ70Nqw2kT1LKXeUnC5-XfQRMfqb8Cbwg,152
|
19
19
|
blue_assistant/.abcli/tests/help.sh,sha256=bxocRb83kKjrA7eeCmI-UaAlVPJZ_xfKy-woJciig_Y,689
|
20
|
-
blue_assistant/.abcli/tests/script_run.sh,sha256=
|
20
|
+
blue_assistant/.abcli/tests/script_run.sh,sha256=UXOvYOBe2FcqWywZvjyazDly6j9_GYAwuxLmmM4GLMM,725
|
21
21
|
blue_assistant/.abcli/tests/version.sh,sha256=oR2rvYR8zi-0VDPIdPJsmsmWwYaamT8dmNTqUh3-8Gw,154
|
22
22
|
blue_assistant/help/__init__.py,sha256=ajz1GSNU9xYVrFEDSz6Xwg7amWQ_yvW75tQa1ZvRIWc,3
|
23
23
|
blue_assistant/help/__main__.py,sha256=cVejR7OpoWPg0qLbm-PZf5TuJS27x49jzfiyCLyzEns,241
|
24
24
|
blue_assistant/help/functions.py,sha256=9WsmXGMN-R7sqlkGLK0nY90Peg8Gah4rIu75QbLhImo,689
|
25
|
-
blue_assistant/help/script.py,sha256=
|
25
|
+
blue_assistant/help/script.py,sha256=knI6aNntFh8OxXuIaWYgcswLqHXz6_cppTvClvuSK-I,740
|
26
26
|
blue_assistant/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
-
blue_assistant/script/__main__.py,sha256=
|
28
|
-
blue_assistant/script/
|
29
|
-
blue_assistant/script/
|
30
|
-
blue_assistant/script/
|
31
|
-
blue_assistant/script/
|
32
|
-
blue_assistant
|
33
|
-
blue_assistant
|
34
|
-
blue_assistant
|
35
|
-
blue_assistant
|
36
|
-
blue_assistant-4.
|
27
|
+
blue_assistant/script/__main__.py,sha256=LAbStVfkw1-kCa7GcutCmimwLB37dTx1hG4LNU-6hXg,1229
|
28
|
+
blue_assistant/script/load.py,sha256=9hzXmHzJ9t8VcWna-oZbo7GWYDUnHou5LUMWD9l0HmA,555
|
29
|
+
blue_assistant/script/repository/__init__.py,sha256=iuiwMKpqTjL4iaVnj4bS5Nev_MgiWKJmeJgZFlM5-lU,483
|
30
|
+
blue_assistant/script/repository/blue_amo/__init__.py,sha256=WjL9GIlN-DBnbUMJ8O_FxTp0rcVGlsIS3H9YtXEefTk,76
|
31
|
+
blue_assistant/script/repository/blue_amo/classes.py,sha256=yhCeP1vHUUQe_iyUzRFcpiELnLi1Bo5qPnVh3J1QvM8,1043
|
32
|
+
blue_assistant/script/repository/generic/__init__.py,sha256=kLffGsQMQAFJTw6IZBE5eBxvshP1x9wwHHR4hsDJblo,75
|
33
|
+
blue_assistant/script/repository/generic/classes.py,sha256=eQl4guWRy0_Xy5FJpmdY740XPkgx4ShYIZ6Jhz0lfiw,1124
|
34
|
+
blue_assistant/script/repository/moon_datasets/__init__.py,sha256=aCtmP2avh3yKAJ668S3GsLR9vbBOm5zt9FSFCqy_tAs,86
|
35
|
+
blue_assistant/script/repository/moon_datasets/classes.py,sha256=9LFbLAo06Jux9lWBRNOv_8QaXznPgqTqxmcZBWaWPDI,357
|
36
|
+
blue_assistant-4.43.1.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
|
37
|
+
blue_assistant-4.43.1.dist-info/METADATA,sha256=iPMa_AwFKj5RGpWJKeC4mkqjhw69CI1z9bqC-QoWPNk,2438
|
38
|
+
blue_assistant-4.43.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
39
|
+
blue_assistant-4.43.1.dist-info/top_level.txt,sha256=ud0BkBbdOVze13bNqHuhZj1rwCztaBtDf5ChEYzASOs,15
|
40
|
+
blue_assistant-4.43.1.dist-info/RECORD,,
|
@@ -1,18 +0,0 @@
|
|
1
|
-
from blue_assistant.script.generic import GenericScript
|
2
|
-
from blue_assistant.script.kinds import ScriptKind
|
3
|
-
|
4
|
-
|
5
|
-
class BlueAmoScript(GenericScript):
|
6
|
-
def __init__(
|
7
|
-
self,
|
8
|
-
object_name: str,
|
9
|
-
verbose: bool = False,
|
10
|
-
download: bool = False,
|
11
|
-
):
|
12
|
-
super().__init__(
|
13
|
-
object_name=object_name,
|
14
|
-
verbose=verbose,
|
15
|
-
download=download,
|
16
|
-
)
|
17
|
-
|
18
|
-
self.kind = ScriptKind.BLUE_AMO
|
@@ -1,40 +0,0 @@
|
|
1
|
-
from typing import Tuple, Union, Type
|
2
|
-
|
3
|
-
from blueness import module
|
4
|
-
from blue_objects.metadata import get_from_object
|
5
|
-
|
6
|
-
from blue_assistant import NAME
|
7
|
-
from blue_assistant.script.generic import GenericScript
|
8
|
-
from blue_assistant.script.blue_amo import BlueAmoScript
|
9
|
-
from blue_assistant.logger import logger
|
10
|
-
|
11
|
-
|
12
|
-
NAME = module.name(__file__, NAME)
|
13
|
-
|
14
|
-
|
15
|
-
def load_script(
|
16
|
-
object_name: str,
|
17
|
-
verbose: bool = False,
|
18
|
-
download: bool = False,
|
19
|
-
) -> Tuple[bool, Union[GenericScript, None]]:
|
20
|
-
script_kind = get_from_object(
|
21
|
-
object_name=object_name,
|
22
|
-
key="script.kind",
|
23
|
-
default="generic",
|
24
|
-
)
|
25
|
-
|
26
|
-
script_class: Type[GenericScript] = GenericScript
|
27
|
-
if script_kind == "blue_amo":
|
28
|
-
script_class = BlueAmoScript
|
29
|
-
if verbose:
|
30
|
-
logger.info(f"script class: {script_class.__name__}")
|
31
|
-
|
32
|
-
script = script_class(
|
33
|
-
object_name=object_name,
|
34
|
-
verbose=verbose,
|
35
|
-
download=download,
|
36
|
-
)
|
37
|
-
if verbose:
|
38
|
-
logger.info(f"script kind: {script.kind}")
|
39
|
-
|
40
|
-
return True, script
|
blue_assistant/script/generic.py
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
from blueness import module
|
2
|
-
from blue_objects.metadata import get_from_object
|
3
|
-
|
4
|
-
from blue_assistant import NAME
|
5
|
-
from blue_assistant.script.kinds import ScriptKind
|
6
|
-
from blue_assistant.logger import logger
|
7
|
-
|
8
|
-
|
9
|
-
NAME = module.name(__file__, NAME)
|
10
|
-
|
11
|
-
|
12
|
-
class GenericScript:
|
13
|
-
def __init__(
|
14
|
-
self,
|
15
|
-
object_name: str,
|
16
|
-
verbose: bool = False,
|
17
|
-
download: bool = False,
|
18
|
-
):
|
19
|
-
self.verbose = verbose
|
20
|
-
|
21
|
-
self.object_name = object_name
|
22
|
-
|
23
|
-
self.kind = ScriptKind.GENERIC
|
24
|
-
|
25
|
-
self.script = get_from_object(
|
26
|
-
object_name=object_name,
|
27
|
-
key="script",
|
28
|
-
default={},
|
29
|
-
download=download,
|
30
|
-
)
|
31
|
-
|
32
|
-
def run(self) -> bool:
|
33
|
-
logger.info(
|
34
|
-
"{}.run({} @ {})".format(
|
35
|
-
NAME,
|
36
|
-
self.__class__.__name__,
|
37
|
-
self.object_name,
|
38
|
-
)
|
39
|
-
)
|
40
|
-
|
41
|
-
return True
|
blue_assistant/script/kinds.py
DELETED
File without changes
|
File without changes
|
File without changes
|