Skip to content

Commit ea5611f

Browse files
committed
reorganize the folder structure
1 parent e13f77b commit ea5611f

20 files changed

+51
-34
lines changed

.DS_Store

0 Bytes
Binary file not shown.

pygeoweaver/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from pygeoweaver.sc_interface import *
1+
from pygeoweaver.commands.pgw_interface import *

pygeoweaver/__main__.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
helpwith,
2525
)
2626
from pygeoweaver.constants import GEOWEAVER_DEFAULT_ENDPOINT_URL
27-
from pygeoweaver.sc_create import create_process, create_process_from_file, create_workflow
28-
from pygeoweaver.sc_detail import get_process_code
29-
from pygeoweaver.sc_find import get_process_by_id, get_process_by_language, get_process_by_name
30-
from pygeoweaver.sc_history import get_process_history, get_workflow_history
31-
from pygeoweaver.sc_list import list_processes_in_workflow
32-
from pygeoweaver.sc_sync import sync, sync_workflow
27+
from pygeoweaver.commands.pgw_create import create_process, create_process_from_file, create_workflow
28+
from pygeoweaver.commands.pgw_detail import get_process_code
29+
from pygeoweaver.commands.pgw_find import get_process_by_id, get_process_by_language, get_process_by_name
30+
from pygeoweaver.commands.pgw_history import get_process_history, get_workflow_history
31+
from pygeoweaver.commands.pgw_list import list_processes_in_workflow
32+
from pygeoweaver.commands.pgw_sync import sync, sync_workflow
3333
from pygeoweaver.server import check_geoweaver_status, show
3434
from halo import Halo
3535

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pygeoweaver/commands/pgw_interface.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
All functions of subcommand interfaces
3+
"""
4+
from pygeoweaver.commands.pgw_detail import *
5+
from pygeoweaver.commands.pgw_list import *
6+
from pygeoweaver.commands.pgw_export import *
7+
from pygeoweaver.commands.pgw_history import *
8+
from pygeoweaver.commands.pgw_import import *
9+
from pygeoweaver.commands.pgw_list import *
10+
from pygeoweaver.commands.pgw_run import *
11+
from pygeoweaver.server import *
12+
from pygeoweaver.commands.pgw_resetpassword import *
13+
from pygeoweaver.commands.pgw_help import *
14+
from pygeoweaver.commands.pgw_create import *
15+
from pygeoweaver.commands.pgw_sync import *
16+
from pygeoweaver.commands.pgw_find import *
File renamed without changes.
File renamed without changes.
File renamed without changes.

pygeoweaver/jdk_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import zipfile
88
import urllib.request
99

10-
from pygeoweaver.utils import get_home_dir, get_java_bin_path
10+
from pygeoweaver.utils import get_home_dir, get_java_bin_path, safe_exit
1111

1212

1313
def install_jdk():
@@ -196,7 +196,7 @@ def install_java():
196196
os.system(f"sudo {package_manager} install -y default-jre default-jdk")
197197
else:
198198
print("Package manager not found. Unable to install Java.")
199-
sys.exit(1)
199+
safe_exit(1)
200200
elif system == "Windows":
201201
# note: this requires admin access to the pc, else it will fail saying
202202
# Access to the path 'C:\ProgramData\chocolatey\lib-bad' is denied.
@@ -208,7 +208,7 @@ def install_java():
208208
os.system("choco install -y openjdk")
209209
else:
210210
print("Unsupported operating system.")
211-
sys.exit(1)
211+
safe_exit(1)
212212

213213

214214
def is_java_installed():

pygeoweaver/sc_interface.py

-16
This file was deleted.

pygeoweaver/server.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
get_logger,
1717
get_module_absolute_path,
1818
get_root_dir,
19+
safe_exit,
1920
)
2021

2122
"""
@@ -75,7 +76,7 @@ def start_on_windows():
7576
java_cmd = os.path.join(jdk_home, "bin", "java.exe")
7677
if not os.path.exists(java_cmd):
7778
print("Java command not found.")
78-
sys.exit(1)
79+
safe_exit(1)
7980

8081
with Halo(text=f'Starting Geowaever...', spinner='dots'):
8182
geoweaver_jar = os.path.join(home_dir, "geoweaver.jar")
@@ -101,13 +102,13 @@ def start_on_windows():
101102
with open(log_file, "r") as f:
102103
print(f.read())
103104
print("Success: Geoweaver is up")
104-
sys.exit(0)
105+
safe_exit(0)
105106
except Exception as e:
106107
# print(f"Error occurred during request: {e}")
107108
continue
108109

109110
print("Error: Geoweaver is not up")
110-
sys.exit(1)
111+
safe_exit(1)
111112

112113

113114
def stop_on_windows():
@@ -146,7 +147,7 @@ def start_on_mac_linux(force_restart=True):
146147
java_path = check_java_exists()
147148
if java_path is None:
148149
print("Java not found. Exiting...")
149-
sys.exit(1)
150+
safe_exit(1)
150151

151152
with Halo(text=f'Starting Geoweaver...', spinner='dots'):
152153
# Start Geoweaver
@@ -176,10 +177,10 @@ def start_on_mac_linux(force_restart=True):
176177

177178
if counter == max_counter:
178179
print("Error: Geoweaver is not up")
179-
sys.exit(1)
180+
safe_exit(1)
180181
else:
181182
print("Success: Geoweaver is up")
182-
sys.exit(0)
183+
safe_exit(0)
183184

184185

185186
def stop_on_mac_linux() -> int:
@@ -227,7 +228,7 @@ def stop():
227228
# cwd=f"{get_root_dir()}/",
228229
# shell=True,
229230
# )
230-
sys.exit(stop_on_mac_linux())
231+
safe_exit(stop_on_mac_linux())
231232

232233

233234
def show(geoweaver_url=GEOWEAVER_DEFAULT_ENDPOINT_URL):

pygeoweaver/utils.py

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111
from pygeoweaver.constants import GEOWEAVER_URL
1212

1313

14+
def safe_exit(code=0):
15+
"""
16+
Safely exit the script or notebook session.
17+
18+
Parameters:
19+
- code (int): Exit status code (default: 0 for success).
20+
"""
21+
if 'ipykernel' in sys.modules:
22+
# Running in Jupyter notebook or IPython
23+
# don't exit at all in Jupyter
24+
pass
25+
else:
26+
# Running in a terminal or other environment
27+
safe_exit(code)
28+
29+
1430
def get_home_dir():
1531
"""
1632
Get the user's home directory.

test/test_detail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from io import StringIO
22
import sys
33
import unittest
4-
from pygeoweaver.sc_detail import detail_host, detail_process, detail_workflow
4+
from pygeoweaver.commands.pgw_detail import detail_host, detail_process, detail_workflow
55
from pygeoweaver.utils import get_logger
66

77

0 commit comments

Comments
 (0)