stoobly-agent 1.4.0__py3-none-any.whl → 1.4.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.
- stoobly_agent/__init__.py +1 -1
- stoobly_agent/app/cli/scaffold/hosts_file_manager.py +97 -24
- stoobly_agent/app/cli/scaffold/templates/app/.Makefile +3 -3
- stoobly_agent/app/cli/scaffold_cli.py +18 -6
- stoobly_agent/test/app/models/schemas/.stoobly/db/VERSION +1 -1
- {stoobly_agent-1.4.0.dist-info → stoobly_agent-1.4.1.dist-info}/METADATA +1 -1
- {stoobly_agent-1.4.0.dist-info → stoobly_agent-1.4.1.dist-info}/RECORD +10 -10
- {stoobly_agent-1.4.0.dist-info → stoobly_agent-1.4.1.dist-info}/LICENSE +0 -0
- {stoobly_agent-1.4.0.dist-info → stoobly_agent-1.4.1.dist-info}/WHEEL +0 -0
- {stoobly_agent-1.4.0.dist-info → stoobly_agent-1.4.1.dist-info}/entry_points.txt +0 -0
stoobly_agent/__init__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
COMMAND = 'stoobly-agent'
|
2
|
-
VERSION = '1.4.
|
2
|
+
VERSION = '1.4.1'
|
@@ -66,47 +66,120 @@ class HostsFileManager():
|
|
66
66
|
def install_hostnames(self, hostnames: list[str]) -> None:
|
67
67
|
hosts_file_path = self.__get_hosts_file_path()
|
68
68
|
|
69
|
-
self.
|
70
|
-
hosts_file_path, SCAFFOLD_HOSTS_DELIMITTER_BEGIN, SCAFFOLD_HOSTS_DELIMITTER_END
|
69
|
+
self.__add_lines_between_markers(
|
70
|
+
hosts_file_path, SCAFFOLD_HOSTS_DELIMITTER_BEGIN, SCAFFOLD_HOSTS_DELIMITTER_END, hostnames
|
71
71
|
)
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
def uninstall_hostnames(self, hostnames: list[str] = []) -> None:
|
74
|
+
hosts_file_path = self.__get_hosts_file_path()
|
75
|
+
|
76
|
+
self.__remove_lines_between_markers(
|
77
|
+
hosts_file_path, SCAFFOLD_HOSTS_DELIMITTER_BEGIN, SCAFFOLD_HOSTS_DELIMITTER_END, hostnames
|
78
|
+
)
|
79
|
+
|
80
|
+
def __remove_lines_between_markers(self, file_path, start_marker, end_marker, hostnames = []):
|
81
|
+
with open(file_path, "r") as file:
|
82
|
+
lines = file.readlines()
|
83
|
+
|
84
|
+
filtered_lines = []
|
85
|
+
index = 0
|
76
86
|
|
87
|
+
# Continue until we reach start_marker
|
88
|
+
for line in lines:
|
89
|
+
index += 1
|
90
|
+
|
91
|
+
if start_marker in line:
|
92
|
+
break
|
93
|
+
|
94
|
+
filtered_lines.append(line)
|
95
|
+
|
96
|
+
# Continue until we reach end_marker
|
97
|
+
found_hostnames = {}
|
98
|
+
section = []
|
99
|
+
for line in lines[index:]:
|
100
|
+
index += 1
|
101
|
+
|
102
|
+
if end_marker in line:
|
103
|
+
break
|
104
|
+
|
105
|
+
found = False
|
77
106
|
for hostname in hostnames:
|
78
|
-
|
79
|
-
|
80
|
-
|
107
|
+
if hostname in line:
|
108
|
+
if hostname not in found_hostnames:
|
109
|
+
print(f"Removing hostname {hostname}")
|
81
110
|
|
82
|
-
|
83
|
-
|
111
|
+
found_hostnames[hostname] = True
|
112
|
+
found = True
|
84
113
|
|
85
|
-
|
86
|
-
|
114
|
+
if not found:
|
115
|
+
section.append(line)
|
87
116
|
|
88
|
-
|
89
|
-
|
90
|
-
|
117
|
+
# If there are still lines in the section
|
118
|
+
if len(section):
|
119
|
+
filtered_lines.append(start_marker)
|
120
|
+
section.append(end_marker)
|
121
|
+
filtered_lines += section
|
122
|
+
|
123
|
+
for line in lines[index:]:
|
124
|
+
filtered_lines.append(line)
|
91
125
|
|
92
|
-
|
126
|
+
with open(file_path, "w") as file:
|
127
|
+
file.writelines(filtered_lines)
|
93
128
|
|
94
|
-
def
|
129
|
+
def __add_lines_between_markers(self, file_path, start_marker, end_marker, hostnames = []):
|
95
130
|
with open(file_path, "r") as file:
|
96
131
|
lines = file.readlines()
|
97
|
-
|
98
|
-
inside_block = False
|
132
|
+
|
99
133
|
filtered_lines = []
|
134
|
+
index = 0
|
100
135
|
|
136
|
+
# Continue until we reach start_marker
|
101
137
|
for line in lines:
|
138
|
+
index += 1
|
102
139
|
if start_marker in line:
|
103
|
-
|
104
|
-
|
140
|
+
break
|
141
|
+
|
142
|
+
filtered_lines.append(line)
|
143
|
+
|
144
|
+
# If no empty line before start_marker, add one
|
145
|
+
if len(filtered_lines):
|
146
|
+
last_line = filtered_lines[-1]
|
147
|
+
|
148
|
+
if last_line != "\n":
|
149
|
+
filtered_lines.append("\n")
|
150
|
+
|
151
|
+
filtered_lines.append(start_marker)
|
152
|
+
|
153
|
+
# Continue until we reach end_marker
|
154
|
+
found_hostnames = {}
|
155
|
+
for line in lines[index:]:
|
156
|
+
index += 1
|
157
|
+
|
105
158
|
if end_marker in line:
|
106
|
-
|
107
|
-
|
108
|
-
|
159
|
+
break
|
160
|
+
|
161
|
+
found = False
|
162
|
+
for hostname in hostnames:
|
163
|
+
if hostname in line:
|
164
|
+
filtered_lines.append(line)
|
165
|
+
found_hostnames[hostname] = True
|
166
|
+
found = True
|
167
|
+
|
168
|
+
if not found:
|
109
169
|
filtered_lines.append(line)
|
170
|
+
|
171
|
+
for hostname in hostnames:
|
172
|
+
if hostname in found_hostnames:
|
173
|
+
continue
|
174
|
+
|
175
|
+
print(f"Installing hostname {hostname}")
|
176
|
+
filtered_lines.append(f"127.0.0.1 {hostname}\n")
|
177
|
+
filtered_lines.append(f"::1 {hostname}\n")
|
178
|
+
|
179
|
+
filtered_lines.append(end_marker)
|
180
|
+
|
181
|
+
for line in lines[index:]:
|
182
|
+
filtered_lines.append(line)
|
110
183
|
|
111
184
|
with open(file_path, "w") as file:
|
112
185
|
file.writelines(filtered_lines)
|
@@ -158,12 +158,12 @@ workflow/hostname: stoobly/install
|
|
158
158
|
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
|
159
159
|
CURRENT_VERSION=$$(stoobly-agent --version); \
|
160
160
|
REQUIRED_VERSION="1.4.0"; \
|
161
|
-
if [ "$$(printf '%s\n' "$$REQUIRED_VERSION" "$$CURRENT_VERSION" | sort -V |
|
161
|
+
if [ "$$(printf '%s\n' "$$REQUIRED_VERSION" "$$CURRENT_VERSION" | sort -V | head -n 1)" != "$$REQUIRED_VERSION" ]; then \
|
162
162
|
echo "stoobly-agent version $$REQUIRED_VERSION required. Please run: pipx upgrade stoobly-agent"; \
|
163
163
|
exit 1; \
|
164
164
|
fi; \
|
165
|
-
echo "Running stoobly-agent scaffold hostname $(COMMAND)
|
166
|
-
stoobly-agent scaffold hostname $(COMMAND) --app-dir-path $(app_dir) --workflow $(WORKFLOW); \
|
165
|
+
echo "Running stoobly-agent scaffold hostname $(COMMAND) $(workflow_service_options)"; \
|
166
|
+
stoobly-agent scaffold hostname $(COMMAND) --app-dir-path $(app_dir) --workflow $(WORKFLOW) $(workflow_service_options); \
|
167
167
|
fi
|
168
168
|
workflow/hostname/install: command/install workflow/hostname
|
169
169
|
workflow/hostname/uninstall: command/uninstall workflow/hostname
|
@@ -565,25 +565,37 @@ def install(**kwargs):
|
|
565
565
|
hosts_file_manager.install_hostnames(hostnames)
|
566
566
|
except PermissionError:
|
567
567
|
print("Permission denied. Please run this command with sudo.", file=sys.stderr)
|
568
|
+
sys.exit(1)
|
568
569
|
|
569
570
|
@hostname.command(
|
570
571
|
help="Delete from the system hosts file all scaffold service hostnames"
|
571
572
|
)
|
572
573
|
@click.option('--app-dir-path', default=current_working_dir, help='Path to application directory.')
|
574
|
+
@click.option('--service', multiple=True, help='Select specific services.')
|
575
|
+
@click.option('--workflow', multiple=True, help='Specify services by workflow(s).')
|
573
576
|
def uninstall(**kwargs):
|
574
577
|
app = App(kwargs['app_dir_path'], DOCKER_NAMESPACE)
|
575
578
|
__validate_app(app)
|
576
579
|
|
580
|
+
services = __get_workflow_services(app, **kwargs)
|
581
|
+
|
582
|
+
hostnames = []
|
583
|
+
for service_name in services:
|
584
|
+
service = Service(service_name, app)
|
585
|
+
__validate_service_dir(service.dir_path)
|
586
|
+
|
587
|
+
service_config = ServiceConfig(service.dir_path)
|
588
|
+
if service_config.hostname:
|
589
|
+
hostnames.append(service_config.hostname)
|
590
|
+
|
577
591
|
__elevate_sudo()
|
578
592
|
|
579
593
|
try:
|
580
594
|
hosts_file_manager = HostsFileManager()
|
581
|
-
hosts_file_manager.uninstall_hostnames()
|
582
|
-
except
|
583
|
-
|
584
|
-
|
585
|
-
else:
|
586
|
-
print(f"An unexpected error occurred: {e}", file=sys.stderr)
|
595
|
+
hosts_file_manager.uninstall_hostnames(hostnames)
|
596
|
+
except PermissionError:
|
597
|
+
print("Permission denied. Please run this command with sudo.", file=sys.stderr)
|
598
|
+
sys.exit(1)
|
587
599
|
|
588
600
|
scaffold.add_command(app)
|
589
601
|
scaffold.add_command(service)
|
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.1
|
@@ -1,4 +1,4 @@
|
|
1
|
-
stoobly_agent/__init__.py,sha256=
|
1
|
+
stoobly_agent/__init__.py,sha256=WY71ZV8dbTRkfHb3ftjHsgTWeLuG9efgIYp8xc2A8Qk,44
|
2
2
|
stoobly_agent/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
stoobly_agent/app/api/__init__.py,sha256=ctkB8KR-eXO0SFhj602huHiyvQ3PslFWd8fkcufgrAI,1000
|
4
4
|
stoobly_agent/app/api/application_http_request_handler.py,sha256=ZgCfmdr5um-OFAiuRHdBxFqPIeph9WqYkVg-oVQWw-E,5543
|
@@ -91,7 +91,7 @@ stoobly_agent/app/cli/scaffold/docker/workflow/development_decorator.py,sha256=c
|
|
91
91
|
stoobly_agent/app/cli/scaffold/docker/workflow/mock_decorator.py,sha256=V9y4RIyEIT8SiGm3U9OcmU1dr22wqpbSbGO_Z2EMYEI,1197
|
92
92
|
stoobly_agent/app/cli/scaffold/docker/workflow/reverse_proxy_decorator.py,sha256=s1l99Y-2h-sSLVtPhcgaa1YRTbSvb6QdgaUeBLHYc4w,1804
|
93
93
|
stoobly_agent/app/cli/scaffold/env.py,sha256=e-Ve4p3RUgzFx22B3SIYttvJ_yLuDtA27oDACZ8n-6E,1140
|
94
|
-
stoobly_agent/app/cli/scaffold/hosts_file_manager.py,sha256=
|
94
|
+
stoobly_agent/app/cli/scaffold/hosts_file_manager.py,sha256=FiX1hYEWN4cJiCOV4h6wOOlY7t71uwIwe6t2upS65aQ,5006
|
95
95
|
stoobly_agent/app/cli/scaffold/managed_services_docker_compose.py,sha256=-wLBXUi7DCWsfm5KzZzd_kdJKOTl1NT924XR7dyjbSY,574
|
96
96
|
stoobly_agent/app/cli/scaffold/service.py,sha256=L9K6QE0k5KSEC8_fSwtdwwTSO_DsIpqSPW-AG7Bg76o,501
|
97
97
|
stoobly_agent/app/cli/scaffold/service_command.py,sha256=9kIKiFC5Jo425VWYD4NDvUOdMP-pNyq2D5Ip1ZAPj3A,1054
|
@@ -103,7 +103,7 @@ stoobly_agent/app/cli/scaffold/service_workflow.py,sha256=sQ_Edy_wGHKMXpD0DmhnOW
|
|
103
103
|
stoobly_agent/app/cli/scaffold/service_workflow_validate_command.py,sha256=hF3c6cFRaKH01BfwdrCJdX8SEbsfD5CCG8W_yZU4FK4,9948
|
104
104
|
stoobly_agent/app/cli/scaffold/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
105
105
|
stoobly_agent/app/cli/scaffold/templates/app/.Dockerfile.context,sha256=PRNYTWYYcLfcyrZ5h5u2I7dAJdeFmmxRFpAj_8243Bw,158
|
106
|
-
stoobly_agent/app/cli/scaffold/templates/app/.Makefile,sha256=
|
106
|
+
stoobly_agent/app/cli/scaffold/templates/app/.Makefile,sha256=GSghwhsDq4w9UsZuAc_Ozau5hHrOIJSh9B8yhtSOwH4,7649
|
107
107
|
stoobly_agent/app/cli/scaffold/templates/app/.docker-compose.base.yml,sha256=YblNDTUPndYNxupgZ3X8RP6NS4c0u_QwLklyWrpq_qs,295
|
108
108
|
stoobly_agent/app/cli/scaffold/templates/app/Makefile,sha256=TEmPG7Bf0KZOnmfsgdzza3UdwcVMmM5Lj1YdLc4cgjA,79
|
109
109
|
stoobly_agent/app/cli/scaffold/templates/app/build/.config.yml,sha256=8Wt8ZZ5irvBYYS44xGrR_EWlZDuXH9kyWmquzsh7s8g,19
|
@@ -195,7 +195,7 @@ stoobly_agent/app/cli/scaffold/workflow_env.py,sha256=x8V5pJmIiklD3f2q2-qq-CORf4
|
|
195
195
|
stoobly_agent/app/cli/scaffold/workflow_log_command.py,sha256=Bke4lMOMxuDUFuAx9nlXHbKgYMO4KAg9ASHvjz4aVWc,1372
|
196
196
|
stoobly_agent/app/cli/scaffold/workflow_run_command.py,sha256=DJNyhPrvvZgOwFnPKi5Z3VdrAWfaZW_XbGfgFcnh5QM,9608
|
197
197
|
stoobly_agent/app/cli/scaffold/workflow_validate_command.py,sha256=fhHciJXg_u32Wmh8us8LhgQj8D1SxkBADtuBBF4K0FM,4377
|
198
|
-
stoobly_agent/app/cli/scaffold_cli.py,sha256=
|
198
|
+
stoobly_agent/app/cli/scaffold_cli.py,sha256=T6kunIY8hMjBhvOydYRKWBjrmOs4X5FXcf-blOKGvyM,25977
|
199
199
|
stoobly_agent/app/cli/scenario_cli.py,sha256=3J1EiJOvunkfWrEkOsanw-XrKkOk78ij_GjBlE9p7CE,8229
|
200
200
|
stoobly_agent/app/cli/snapshot_cli.py,sha256=cpCjxFYBuVwLuq_b2lIUu-5zWqupRlrp4xWgDytirSM,10047
|
201
201
|
stoobly_agent/app/cli/trace_cli.py,sha256=K7E-vx3JUcqEDSWOdIOi_AieKNQz7dBfmRrVvKDkzFI,4605
|
@@ -693,7 +693,7 @@ stoobly_agent/test/app/models/factories/resource/local_db/helpers/log_test.py,sh
|
|
693
693
|
stoobly_agent/test/app/models/factories/resource/local_db/helpers/tiebreak_scenario_request_test.py,sha256=5IFGVGn3ogvRT0fzZgXzhrYlSfSlr8IR1p_XExaegMQ,3399
|
694
694
|
stoobly_agent/test/app/models/factories/resource/local_db/request_adapter_test.py,sha256=Pzq1cBPnP9oSWG-p0c-VoymoHxgp483QmNwmV1b78RA,8453
|
695
695
|
stoobly_agent/test/app/models/factories/resource/local_db/response_adapter_test.py,sha256=9P95EKH5rZGOrmRkRIDlQZqtiLJHk9735og18Ffwpfw,2204
|
696
|
-
stoobly_agent/test/app/models/schemas/.stoobly/db/VERSION,sha256=
|
696
|
+
stoobly_agent/test/app/models/schemas/.stoobly/db/VERSION,sha256=8LZyMhqJSE9NqFn_x0G7_otbaT04f34F-Exd5iWhzGE,5
|
697
697
|
stoobly_agent/test/app/models/schemas/.stoobly/db/stoobly_agent.sqlite3,sha256=ch8gNx6zIelLKQx65gwFx_LRNqUD3EC5xcHZ0ukIQiU,188416
|
698
698
|
stoobly_agent/test/app/models/schemas/.stoobly/settings.yml,sha256=vLwMjweKOdod6tSLtIlyBefPQuNXq9wio4kBaODKtAU,726
|
699
699
|
stoobly_agent/test/app/models/schemas/.stoobly/tmp/options.json,sha256=OTRzarwus48CTrItedXCrgQttJHSEZonEYc7R_knvYg,2212
|
@@ -730,8 +730,8 @@ stoobly_agent/test/mock_data/scaffold/docker-compose-local-service.yml,sha256=x7
|
|
730
730
|
stoobly_agent/test/mock_data/scaffold/index.html,sha256=qJwuYajKZ4ihWZrJQ3BNObV5kf1VGnnm_vqlPJzdqLE,258
|
731
731
|
stoobly_agent/test/mock_data/uspto.yaml,sha256=6U5se7C3o-86J4m9xpOk9Npias399f5CbfWzR87WKwE,7835
|
732
732
|
stoobly_agent/test/test_helper.py,sha256=m_oAI7tmRYCNZdKfNqISWhMv3e44tjeYViQ3nTUfnos,1007
|
733
|
-
stoobly_agent-1.4.
|
734
|
-
stoobly_agent-1.4.
|
735
|
-
stoobly_agent-1.4.
|
736
|
-
stoobly_agent-1.4.
|
737
|
-
stoobly_agent-1.4.
|
733
|
+
stoobly_agent-1.4.1.dist-info/LICENSE,sha256=8QKGyy45eN76Zk52h8gu1DKX2B_gbWgZ3nzDLofEbaE,548
|
734
|
+
stoobly_agent-1.4.1.dist-info/METADATA,sha256=LSnoRzku6oP5q5Vy9KIfdSOlYldZLc4wlcvuJYHIbWA,3384
|
735
|
+
stoobly_agent-1.4.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
736
|
+
stoobly_agent-1.4.1.dist-info/entry_points.txt,sha256=aq5wix5oC8MDQtmyPGU0xaFrsjJg7WH28NmXh2sc3Z8,56
|
737
|
+
stoobly_agent-1.4.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|