blue-assistant 4.243.1__tar.gz → 4.273.1__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.
- {blue_assistant-4.243.1/blue_assistant.egg-info → blue_assistant-4.273.1}/PKG-INFO +4 -4
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/README.md +3 -3
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/script/run.sh +3 -1
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/tests/script_run.sh +3 -1
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/web/crawl.sh +5 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/README.py +22 -8
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/__init__.py +1 -1
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/help/script.py +1 -1
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/help/web.py +1 -1
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/__main__.py +9 -1
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/actions/__init__.py +3 -2
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/actions/generate_image.py +1 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/actions/generate_text.py +1 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/actions/generic.py +1 -0
- blue_assistant-4.273.1/blue_assistant/script/actions/web_crawl.py +49 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/base/classes.py +68 -10
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/blue_amo/actions/slicing_into_frames.py +1 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/blue_amo/actions/stitching_the_frames.py +1 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/blue_amo/classes.py +6 -1
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/generic/classes.py +11 -3
- blue_assistant-4.273.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +7 -0
- blue_assistant-4.273.1/blue_assistant/web/__init__.py +2 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/web/__main__.py +10 -6
- blue_assistant-4.273.1/blue_assistant/web/crawl.py +91 -0
- blue_assistant-4.273.1/blue_assistant/web/fetch.py +75 -0
- blue_assistant-4.273.1/blue_assistant/web/functions.py +39 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1/blue_assistant.egg-info}/PKG-INFO +4 -4
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant.egg-info/SOURCES.txt +3 -2
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/setup.py +0 -1
- blue_assistant-4.243.1/blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py +0 -11
- blue_assistant-4.243.1/blue_assistant/script/repository/orbital_data_explorer/actions/researching_the_questions.py +0 -42
- blue_assistant-4.243.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +0 -40
- blue_assistant-4.243.1/blue_assistant/web/__init__.py +0 -0
- blue_assistant-4.243.1/blue_assistant/web/functions.py +0 -97
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/LICENSE +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/MANIFEST.in +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/abcli.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/actions.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/alias.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/browse.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/hue/create_user.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/hue/list.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/hue/set.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/hue.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/script/list.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/script.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/tests/README.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/tests/help.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/tests/version.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/tests/web_crawl.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/tests/web_fetch.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/web/fetch.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/.abcli/web.sh +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/__main__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/config.env +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/env.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/functions.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/help/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/help/__main__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/help/functions.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/help/hue.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/host.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/logger.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/sample.env +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/load.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/base/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/blue_amo/actions/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/generic/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/hue/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/hue/__main__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/hue/api.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/hue/classes.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/hue/colors.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/orbital_data_explorer/__init__.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/urls.py +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant.egg-info/requires.txt +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant.egg-info/top_level.txt +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/pyproject.toml +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/requirements.txt +0 -0
- {blue_assistant-4.243.1 → blue_assistant-4.273.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: blue_assistant
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.273.1
|
4
4
|
Summary: 🧠 An AI Assistant.
|
5
5
|
Home-page: https://github.com/kamangir/blue-assistant
|
6
6
|
Author: Arash Abadpour (Kamangir)
|
@@ -112,8 +112,8 @@ graph LR
|
|
112
112
|
|
113
113
|
| | |
|
114
114
|
| --- | --- |
|
115
|
-
| [`
|
116
|
-
| [`
|
115
|
+
| [`orbital-data-explorer`](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/orbital_data_explorer) [](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/orbital_data_explorer) Access to the [Orbital Data Explorer](https://ode.rsl.wustl.edu/). 🔥 | [`🌀 blue script`](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/) [](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/) A minimal AI DAG interface. |
|
116
|
+
| [`@hue`](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/hue) [](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/hue) "send a color command to the Hue LED lights in my apartment." | [`blue-amo`](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/blue_amo/README.md) [](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/blue_amo/README.md) Story development and visualization. |
|
117
117
|
|
118
118
|
---
|
119
119
|
|
@@ -124,4 +124,4 @@ Also home to [`@web`](https://raw.githubusercontent.com/kamangir/blue-assistant/
|
|
124
124
|
|
125
125
|
[](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)
|
126
126
|
|
127
|
-
built by 🌀 [`blue_options-4.236.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.
|
127
|
+
built by 🌀 [`blue_options-4.236.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.273.1`](https://github.com/kamangir/blue-assistant).
|
@@ -67,8 +67,8 @@ graph LR
|
|
67
67
|
|
68
68
|
| | |
|
69
69
|
| --- | --- |
|
70
|
-
| [`
|
71
|
-
| [`
|
70
|
+
| [`orbital-data-explorer`](./blue_assistant/script/repository/orbital_data_explorer) [](./blue_assistant/script/repository/orbital_data_explorer) Access to the [Orbital Data Explorer](https://ode.rsl.wustl.edu/). 🔥 | [`🌀 blue script`](./blue_assistant/script/) [](./blue_assistant/script/) A minimal AI DAG interface. |
|
71
|
+
| [`@hue`](./blue_assistant/script/repository/hue) [](./blue_assistant/script/repository/hue) "send a color command to the Hue LED lights in my apartment." | [`blue-amo`](./blue_assistant/script/repository/blue_amo/README.md) [](./blue_assistant/script/repository/blue_amo/README.md) Story development and visualization. |
|
72
72
|
|
73
73
|
---
|
74
74
|
|
@@ -79,4 +79,4 @@ Also home to [`@web`](./blue_assistant/web/)
|
|
79
79
|
|
80
80
|
[](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)
|
81
81
|
|
82
|
-
built by 🌀 [`blue_options-4.236.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.
|
82
|
+
built by 🌀 [`blue_options-4.236.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.273.1`](https://github.com/kamangir/blue-assistant).
|
@@ -3,7 +3,8 @@
|
|
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
|
6
|
+
local use_cache=$(abcli_option_int "$options" cache 1)
|
7
|
+
local do_download=$(abcli_option_int "$options" download $use_cache)
|
7
8
|
local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun))
|
8
9
|
|
9
10
|
local script_options=$2
|
@@ -20,6 +21,7 @@ function blue_assistant_script_run() {
|
|
20
21
|
run \
|
21
22
|
--script_name $script_name \
|
22
23
|
--object_name $object_name \
|
24
|
+
--use_cache $use_cache \
|
23
25
|
"${@:4}"
|
24
26
|
[[ $? -ne 0 ]] && return 1
|
25
27
|
|
@@ -11,11 +11,13 @@ function test_blue_assistant_script_run() {
|
|
11
11
|
for script_name in $(echo "$list_of_script_name" | tr + " "); do
|
12
12
|
abcli_log "testing $script_name ..."
|
13
13
|
|
14
|
+
local object_name=test_blue_assistant_script_run-$(abcli_string_timestamp_short)
|
15
|
+
|
14
16
|
abcli_eval ,$options \
|
15
17
|
blue_assistant_script_run \
|
16
18
|
~upload,$options \
|
17
19
|
script=$script_name \
|
18
|
-
|
20
|
+
$object_name \
|
19
21
|
"${@:2}" \
|
20
22
|
--test_mode 1 \
|
21
23
|
--verbose 1
|
@@ -3,11 +3,15 @@
|
|
3
3
|
function blue_assistant_web_crawl() {
|
4
4
|
local options=$1
|
5
5
|
local do_dryrun=$(abcli_option_int "$options" dryrun 0)
|
6
|
+
local use_cache=$(abcli_option_int "$options" cache 0)
|
7
|
+
local do_download=$(abcli_option_int "$options" download $use_cache)
|
6
8
|
local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun))
|
7
9
|
|
8
10
|
local seed_urls=${2:-void}
|
9
11
|
|
10
12
|
local object_name=$(abcli_clarify_object $3 web-crawl-$(abcli_string_timestamp_short))
|
13
|
+
[[ "$do_download" == 1 ]] &&
|
14
|
+
abcli_download - $object_name
|
11
15
|
|
12
16
|
abcli_log "crawling $seed_urls -> $object_name ..."
|
13
17
|
|
@@ -16,6 +20,7 @@ function blue_assistant_web_crawl() {
|
|
16
20
|
crawl \
|
17
21
|
--seed_urls $seed_urls \
|
18
22
|
--object_name $object_name \
|
23
|
+
--use_cache $use_cache \
|
19
24
|
"${@:4}"
|
20
25
|
[[ $? -ne 0 ]] && return 1
|
21
26
|
|
@@ -1,14 +1,28 @@
|
|
1
1
|
import os
|
2
2
|
|
3
|
+
from blue_options.help.functions import get_help
|
3
4
|
from blue_objects import file, README
|
4
5
|
|
5
6
|
from blue_assistant import NAME, VERSION, ICON, REPO_NAME
|
7
|
+
from blue_assistant.help.functions import help_functions
|
6
8
|
|
7
9
|
|
8
10
|
items = README.Items(
|
9
11
|
[
|
10
12
|
{
|
11
|
-
"name": "
|
13
|
+
"name": "orbital-data-explorer",
|
14
|
+
"url": "./blue_assistant/script/repository/orbital_data_explorer",
|
15
|
+
"marquee": "https://github.com/kamangir/assets/blob/main/blue-assistant/orbital-data-explorer.png?raw=true",
|
16
|
+
"description": "Access to the [Orbital Data Explorer](https://ode.rsl.wustl.edu/). 🔥",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"name": "🌀 blue script",
|
20
|
+
"marquee": "https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true",
|
21
|
+
"description": "A minimal AI DAG interface.",
|
22
|
+
"url": "./blue_assistant/script/",
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"name": "@hue",
|
12
26
|
"url": "./blue_assistant/script/repository/hue",
|
13
27
|
"marquee": "https://github.com/kamangir/assets/raw/main/blue-assistant/20250314_143702.jpg?raw=true",
|
14
28
|
"description": '"send a color command to the Hue LED lights in my apartment."',
|
@@ -17,13 +31,7 @@ items = README.Items(
|
|
17
31
|
"name": "blue-amo",
|
18
32
|
"url": "./blue_assistant/script/repository/blue_amo/README.md",
|
19
33
|
"marquee": "https://github.com/kamangir/assets/raw/main/blue-amo-2025-02-03-nswnx6/stitching_the_frames-2.png?raw=true",
|
20
|
-
"description": "
|
21
|
-
},
|
22
|
-
{
|
23
|
-
"name": "orbital-data-explorer",
|
24
|
-
"url": "./blue_assistant/script/repository/orbital_data_explorer",
|
25
|
-
"marquee": "https://github.com/kamangir/assets/blob/main/blue-assistant/orbital-data-explorer.png?raw=true",
|
26
|
-
"description": "Access to the [Orbital Data Explorer](https://ode.rsl.wustl.edu/), through AI. ⏸️",
|
34
|
+
"description": "Story development and visualization.",
|
27
35
|
},
|
28
36
|
]
|
29
37
|
)
|
@@ -39,6 +47,11 @@ def build():
|
|
39
47
|
NAME=NAME,
|
40
48
|
VERSION=VERSION,
|
41
49
|
REPO_NAME=REPO_NAME,
|
50
|
+
help_function=lambda tokens: get_help(
|
51
|
+
tokens,
|
52
|
+
help_functions,
|
53
|
+
mono=True,
|
54
|
+
),
|
42
55
|
)
|
43
56
|
for readme in [
|
44
57
|
{
|
@@ -54,6 +67,7 @@ def build():
|
|
54
67
|
{"path": "script/repository/hue/docs/round-1.md"},
|
55
68
|
{"path": "script/repository/hue/docs"},
|
56
69
|
#
|
70
|
+
{"path": "script/"},
|
57
71
|
{"path": "web/"},
|
58
72
|
]
|
59
73
|
)
|
@@ -48,6 +48,12 @@ parser.add_argument(
|
|
48
48
|
default=1,
|
49
49
|
help="0 | 1",
|
50
50
|
)
|
51
|
+
parser.add_argument(
|
52
|
+
"--use_cache",
|
53
|
+
type=int,
|
54
|
+
default=1,
|
55
|
+
help="0 | 1",
|
56
|
+
)
|
51
57
|
args = parser.parse_args()
|
52
58
|
|
53
59
|
delim = " " if args.delim == "space" else args.delim
|
@@ -70,7 +76,9 @@ elif args.task == "run":
|
|
70
76
|
)
|
71
77
|
|
72
78
|
if success:
|
73
|
-
success = script.run(
|
79
|
+
success = script.run(
|
80
|
+
use_cache=args.use_cache == 1,
|
81
|
+
)
|
74
82
|
else:
|
75
83
|
success = None
|
76
84
|
|
@@ -1,14 +1,15 @@
|
|
1
|
-
from typing import Dict, Callable
|
1
|
+
from typing import Dict, Callable
|
2
2
|
|
3
3
|
from blue_assistant.script.repository.base.classes import BaseScript
|
4
4
|
from blue_assistant.script.actions.generic import generic_action
|
5
5
|
from blue_assistant.script.actions.generate_image import generate_image
|
6
6
|
from blue_assistant.script.actions.generate_text import generate_text
|
7
|
-
from blue_assistant.
|
7
|
+
from blue_assistant.script.actions.web_crawl import web_crawl
|
8
8
|
|
9
9
|
|
10
10
|
dict_of_actions: Dict[str, Callable[[BaseScript, str], bool]] = {
|
11
11
|
"generic": generic_action,
|
12
12
|
"generate_image": generate_image,
|
13
13
|
"generate_text": generate_text,
|
14
|
+
"web_crawl": web_crawl,
|
14
15
|
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
from blueness import module
|
2
|
+
|
3
|
+
from blue_options.logger import log_list
|
4
|
+
|
5
|
+
from blue_assistant import NAME
|
6
|
+
from blue_assistant.web.crawl import crawl_list_of_urls
|
7
|
+
from blue_assistant.script.repository.base.classes import BaseScript
|
8
|
+
from blue_assistant.logger import logger
|
9
|
+
|
10
|
+
|
11
|
+
NAME = module.name(__file__, NAME)
|
12
|
+
|
13
|
+
|
14
|
+
def web_crawl(
|
15
|
+
script: BaseScript,
|
16
|
+
node_name: str,
|
17
|
+
use_cache: bool,
|
18
|
+
) -> bool:
|
19
|
+
logger.info(f"{NAME}: {script} @ {node_name} ...")
|
20
|
+
|
21
|
+
seed_url_var_name = script.nodes[node_name].get("seed_urls", "")
|
22
|
+
if not isinstance(seed_url_var_name, str):
|
23
|
+
logger.error(f"{node_name}: seed_urls must be a string.")
|
24
|
+
return False
|
25
|
+
if not seed_url_var_name:
|
26
|
+
logger.error(f"{node_name}: seed_urls not found.")
|
27
|
+
return False
|
28
|
+
|
29
|
+
# to allow both :::<var-name> and <var-name> - for convenience :)
|
30
|
+
if seed_url_var_name.startswith(":::"):
|
31
|
+
seed_url_var_name = seed_url_var_name[3:].strip()
|
32
|
+
|
33
|
+
if seed_url_var_name not in script.vars:
|
34
|
+
logger.error(f"{node_name}: {seed_url_var_name}: seed_urls not found in vars.")
|
35
|
+
return False
|
36
|
+
seed_urls = script.vars[seed_url_var_name]
|
37
|
+
log_list(logger, seed_urls, "seed url(s)")
|
38
|
+
|
39
|
+
visited_urls = crawl_list_of_urls(
|
40
|
+
seed_urls=seed_urls,
|
41
|
+
object_name=script.object_name,
|
42
|
+
max_iterations=script.nodes[node_name]["max_iterations"],
|
43
|
+
use_cache=use_cache,
|
44
|
+
)
|
45
|
+
|
46
|
+
script.nodes[node_name]["visited_urls"] = visited_urls
|
47
|
+
script.nodes[node_name]["output"] = "TBA"
|
48
|
+
|
49
|
+
return True
|
{blue_assistant-4.243.1 → blue_assistant-4.273.1}/blue_assistant/script/repository/base/classes.py
RENAMED
@@ -27,8 +27,6 @@ class BaseScript:
|
|
27
27
|
self.object_name = object_name
|
28
28
|
|
29
29
|
self.test_mode = test_mode
|
30
|
-
if self.test_mode:
|
31
|
-
logger.info("💰 test mode is on.")
|
32
30
|
|
33
31
|
self.verbose = verbose
|
34
32
|
|
@@ -41,14 +39,70 @@ class BaseScript:
|
|
41
39
|
success, self.metadata = file.load_yaml(metadata_filename)
|
42
40
|
assert success, f"cannot load {self.name}/metadata.yaml"
|
43
41
|
|
44
|
-
|
42
|
+
self.metadata.setdefault("script", {})
|
43
|
+
assert isinstance(
|
44
|
+
self.script,
|
45
|
+
dict,
|
46
|
+
), "script: expected dict, received {}.".format(
|
47
|
+
self.script.__class__.__name__,
|
48
|
+
)
|
49
|
+
|
50
|
+
self.script.setdefault("nodes", {})
|
51
|
+
assert isinstance(
|
52
|
+
self.nodes,
|
53
|
+
dict,
|
54
|
+
), "nodes: expected dict, received {}.".format(
|
55
|
+
self.nodes.__class__.__name__,
|
56
|
+
)
|
57
|
+
|
58
|
+
self.script.setdefault("vars", {})
|
59
|
+
assert isinstance(
|
60
|
+
self.vars,
|
61
|
+
dict,
|
62
|
+
), "vars: expected dict, received {}.".format(
|
63
|
+
self.vars.__class__.__name__,
|
64
|
+
)
|
65
|
+
|
66
|
+
if self.test_mode:
|
67
|
+
logger.info("🧪 test mode is on.")
|
68
|
+
|
69
|
+
for node_name, node in self.nodes.items():
|
70
|
+
if "test_mode" in self.script:
|
71
|
+
updates = self.script["test_mode"]
|
72
|
+
logger.info(f"🧪 vars.update({updates})")
|
73
|
+
self.vars.update(updates)
|
74
|
+
|
75
|
+
if "test_mode" in node:
|
76
|
+
updates = node["test_mode"]
|
77
|
+
logger.info(f"🧪 {node_name}.update({updates})")
|
78
|
+
node.update(updates)
|
45
79
|
|
46
|
-
logger.info(
|
80
|
+
logger.info(
|
81
|
+
"loaded {} node(s): {}".format(
|
82
|
+
len(self.nodes),
|
83
|
+
", ".join(self.nodes.keys()),
|
84
|
+
)
|
85
|
+
)
|
86
|
+
|
87
|
+
logger.info(
|
88
|
+
"loaded {} var(s){}".format(
|
89
|
+
len(self.vars),
|
90
|
+
"" if verbose else ": {}".format(", ".join(self.vars.keys())),
|
91
|
+
)
|
92
|
+
)
|
47
93
|
if verbose:
|
48
94
|
for var_name, var_value in self.vars.items():
|
49
95
|
logger.info("{}: {}".format(var_name, var_value))
|
50
96
|
|
51
|
-
assert self.generate_graph(), "cannot generate graph"
|
97
|
+
assert self.generate_graph(), "cannot generate graph."
|
98
|
+
|
99
|
+
def __str__(self) -> str:
|
100
|
+
return "{}[{} var(s), {} node(s) -> {}]".format(
|
101
|
+
self.__class__.__name__,
|
102
|
+
len(self.vars),
|
103
|
+
len(self.nodes),
|
104
|
+
self.object_name,
|
105
|
+
)
|
52
106
|
|
53
107
|
def apply_vars(self, text: str) -> str:
|
54
108
|
for var_name, var_value in self.vars.items():
|
@@ -91,12 +145,16 @@ class BaseScript:
|
|
91
145
|
[node_name],
|
92
146
|
)
|
93
147
|
|
94
|
-
def run(
|
148
|
+
def run(
|
149
|
+
self,
|
150
|
+
use_cache: bool = True,
|
151
|
+
) -> bool:
|
95
152
|
logger.info(
|
96
|
-
"{}.run: {}:{}
|
153
|
+
"{}.run: {}:{} -{}> {}".format(
|
97
154
|
NAME,
|
98
155
|
self.__class__.__name__,
|
99
156
|
self.name,
|
157
|
+
"use-cache-" if use_cache else "",
|
100
158
|
self.object_name,
|
101
159
|
)
|
102
160
|
)
|
@@ -126,12 +184,12 @@ class BaseScript:
|
|
126
184
|
# Aliases
|
127
185
|
@property
|
128
186
|
def script(self) -> Dict:
|
129
|
-
return self.metadata
|
187
|
+
return self.metadata["script"]
|
130
188
|
|
131
189
|
@property
|
132
190
|
def nodes(self) -> Dict[str, Dict]:
|
133
|
-
return self.metadata
|
191
|
+
return self.metadata["script"]["nodes"]
|
134
192
|
|
135
193
|
@property
|
136
194
|
def vars(self) -> Dict:
|
137
|
-
return self.metadata
|
195
|
+
return self.metadata["script"]["vars"]
|
@@ -66,14 +66,19 @@ class BlueAmoScript(GenericScript):
|
|
66
66
|
def perform_action(
|
67
67
|
self,
|
68
68
|
node_name: str,
|
69
|
+
use_cache: bool,
|
69
70
|
) -> bool:
|
70
|
-
if not super().perform_action(
|
71
|
+
if not super().perform_action(
|
72
|
+
node_name=node_name,
|
73
|
+
use_cache=use_cache,
|
74
|
+
):
|
71
75
|
return False
|
72
76
|
|
73
77
|
if node_name in dict_of_actions:
|
74
78
|
return dict_of_actions[node_name](
|
75
79
|
script=self,
|
76
80
|
node_name=node_name,
|
81
|
+
use_cache=use_cache,
|
77
82
|
)
|
78
83
|
|
79
84
|
return True
|
@@ -22,6 +22,7 @@ class GenericScript(BaseScript):
|
|
22
22
|
def perform_action(
|
23
23
|
self,
|
24
24
|
node_name: str,
|
25
|
+
use_cache: bool,
|
25
26
|
) -> bool:
|
26
27
|
action_name = self.nodes[node_name].get("action", "unknown")
|
27
28
|
logger.info(f"---- node: {node_name} ---- ")
|
@@ -33,10 +34,14 @@ class GenericScript(BaseScript):
|
|
33
34
|
return dict_of_actions[action_name](
|
34
35
|
script=self,
|
35
36
|
node_name=node_name,
|
37
|
+
use_cache=use_cache,
|
36
38
|
)
|
37
39
|
|
38
|
-
def run(
|
39
|
-
|
40
|
+
def run(
|
41
|
+
self,
|
42
|
+
use_cache: bool = True,
|
43
|
+
) -> bool:
|
44
|
+
if not super().run(use_cache=use_cache):
|
40
45
|
return False
|
41
46
|
|
42
47
|
success: bool = True
|
@@ -68,7 +73,10 @@ class GenericScript(BaseScript):
|
|
68
73
|
)
|
69
74
|
continue
|
70
75
|
|
71
|
-
if not self.perform_action(
|
76
|
+
if not self.perform_action(
|
77
|
+
node_name=node_name,
|
78
|
+
use_cache=use_cache,
|
79
|
+
):
|
72
80
|
success = False
|
73
81
|
break
|
74
82
|
|
@@ -6,7 +6,7 @@ from blue_options.logger import log_dict
|
|
6
6
|
from blue_objects.metadata import post_to_object
|
7
7
|
|
8
8
|
from blue_assistant import NAME
|
9
|
-
from blue_assistant.web
|
9
|
+
from blue_assistant.web import crawl_list_of_urls, fetch_links_and_text
|
10
10
|
from blue_assistant.logger import logger
|
11
11
|
|
12
12
|
NAME = module.name(__file__, NAME)
|
@@ -40,6 +40,12 @@ parser.add_argument(
|
|
40
40
|
"--object_name",
|
41
41
|
type=str,
|
42
42
|
)
|
43
|
+
parser.add_argument(
|
44
|
+
"--use_cache",
|
45
|
+
type=int,
|
46
|
+
default=0,
|
47
|
+
help="0 | 1",
|
48
|
+
)
|
43
49
|
args = parser.parse_args()
|
44
50
|
|
45
51
|
success = False
|
@@ -48,6 +54,7 @@ if args.task == "crawl":
|
|
48
54
|
seed_urls=args.seed_urls.split("+"),
|
49
55
|
object_name=args.object_name,
|
50
56
|
max_iterations=args.max_iterations,
|
57
|
+
use_cache=args.use_cache == 1,
|
51
58
|
)
|
52
59
|
|
53
60
|
if args.verbose == 1:
|
@@ -59,7 +66,7 @@ if args.task == "crawl":
|
|
59
66
|
dict_of_urls,
|
60
67
|
)
|
61
68
|
elif args.task == "fetch":
|
62
|
-
|
69
|
+
summary = fetch_links_and_text(
|
63
70
|
url=args.url,
|
64
71
|
verbose=True,
|
65
72
|
)
|
@@ -67,10 +74,7 @@ elif args.task == "fetch":
|
|
67
74
|
success = post_to_object(
|
68
75
|
args.object_name,
|
69
76
|
NAME.replace(".", "-"),
|
70
|
-
|
71
|
-
"links": list(links),
|
72
|
-
"text": text,
|
73
|
-
},
|
77
|
+
summary,
|
74
78
|
)
|
75
79
|
else:
|
76
80
|
success = None
|