pingwizard 1.0.26__tar.gz → 1.1.0__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.
- pingwizard-1.1.0/PKG-INFO +51 -0
- pingwizard-1.1.0/README.md +16 -0
- pingwizard-1.1.0/pingwizard/assets/PINGWizard_Logo.png +0 -0
- pingwizard-1.1.0/pingwizard/assets/RockMapper_Logo.png +0 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/pingwizard/create_shortcut.py +17 -14
- pingwizard-1.1.0/pingwizard/environments.py +57 -0
- pingwizard-1.1.0/pingwizard/gui_wizard.py +456 -0
- pingwizard-1.1.0/pingwizard/version.py +1 -0
- pingwizard-1.1.0/pingwizard.egg-info/PKG-INFO +51 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/pingwizard.egg-info/SOURCES.txt +7 -1
- pingwizard-1.1.0/pingwizard.egg-info/requires.txt +1 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/setup.py +3 -1
- pingwizard-1.1.0/tests/test_create_shortcut.py +44 -0
- pingwizard-1.1.0/tests/test_gui_wizard.py +322 -0
- pingwizard-1.0.26/PKG-INFO +0 -43
- pingwizard-1.0.26/README.md +0 -10
- pingwizard-1.0.26/pingwizard/gui_wizard.py +0 -257
- pingwizard-1.0.26/pingwizard/version.py +0 -1
- pingwizard-1.0.26/pingwizard.egg-info/PKG-INFO +0 -43
- {pingwizard-1.0.26 → pingwizard-1.1.0}/LICENSE +0 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/pingwizard/__init__.py +0 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/pingwizard/__main__.py +0 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/pingwizard/assets/PINGMapper_Logo_small.png +0 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/pingwizard/check_available_updates.py +0 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/pingwizard.egg-info/dependency_links.txt +0 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/pingwizard.egg-info/top_level.txt +0 -0
- {pingwizard-1.0.26 → pingwizard-1.1.0}/setup.cfg +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pingwizard
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Light-weight interface for running PING ecosystem (PINGMapper, etc.)
|
|
5
|
+
Author: Cameron Bodine
|
|
6
|
+
Author-email: bodine.cs@gmail.email
|
|
7
|
+
Project-URL: Issues, https://github.com/CameronBodine/PINGWizard/issues
|
|
8
|
+
Project-URL: GitHub, https://github.com/CameronBodine/PINGWizard
|
|
9
|
+
Project-URL: Homepage, https://cameronbodine.github.io/PINGMapper/
|
|
10
|
+
Keywords: pingmapper,sonar,ecology,remotesensing,sidescan,sidescan-sonar,aquatic,humminbird,lowrance,gis,oceanography,limnology
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Oceanography
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Hydrology
|
|
20
|
+
Requires-Python: >=3.6
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: FreeSimpleGUI
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: classifier
|
|
27
|
+
Dynamic: description
|
|
28
|
+
Dynamic: description-content-type
|
|
29
|
+
Dynamic: keywords
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
Dynamic: project-url
|
|
32
|
+
Dynamic: requires-dist
|
|
33
|
+
Dynamic: requires-python
|
|
34
|
+
Dynamic: summary
|
|
35
|
+
|
|
36
|
+
# PINGWizard
|
|
37
|
+
Light-weight interface for running PING ecosystem (PINGMapper, etc.)
|
|
38
|
+
|
|
39
|
+
- Launch PINGMapper (single or batch), RockMapper, and GhostVision from the dedicated `pingwizard` environment. PINGInstaller creates or updates this environment from [`pingwizard/conda/pingwizard.yml`](pingwizard/conda/pingwizard.yml) when installing PINGMapper or RockMapper.
|
|
40
|
+
- Run `conda activate pingwizard` followed by `python -m pingwizard`, or use the shortcut created by PINGInstaller.
|
|
41
|
+
- The wizard discovers PINGMapper in `ping`, RockMapper in `rockmapper_torch`, `rockmapper`, or `rockmapper_torch_gpu`, and GhostVision in `ghostvision`. It launches each utility in its own environment. If multiple RockMapper environments exist, select one in the wizard.
|
|
42
|
+
- If a utility is missing, use **Install** for PINGMapper or RockMapper. RockMapper uses a single Torch environment. The wizard asks for confirmation, then closes and starts PINGInstaller from the base environment. On Windows, progress appears in a new console; on other systems, see the terminal that launched PINGWizard. An existing target environment may be updated with `--prune`, which removes packages not in its environment file.
|
|
43
|
+
- For a missing GhostVision installation, **Install CPU** runs `pinginstaller ghostvision`; CPU inference is experimental. For GPU setup, see [GhostVision's installation instructions](https://github.com/PINGEcosystem/GhostVision#installation). Both installers target the `ghostvision` environment. GhostVision also offers **Download Model** for its Roboflow download utility.
|
|
44
|
+
- PINGMapper's test and update controls remain available when PINGMapper is installed. RockMapper does not currently provide equivalent test commands; follow its installation instructions for updates.
|
|
45
|
+
- PINGMapper updates are launched from the base environment rather than the utility environment.
|
|
46
|
+
|
|
47
|
+
## Verbosity
|
|
48
|
+
- Default: Updates run with maximum verbosity (debug) when triggered from the wizard.
|
|
49
|
+
- Quiet mode: Set environment variable `PINGINSTALLER_VERBOSITY=quiet` before launching PINGWizard to suppress extra solver output, or use `python -m pinginstaller -q` when running from the terminal.
|
|
50
|
+
|
|
51
|
+
[)](https://pypi.org/project/pingwizard/)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# PINGWizard
|
|
2
|
+
Light-weight interface for running PING ecosystem (PINGMapper, etc.)
|
|
3
|
+
|
|
4
|
+
- Launch PINGMapper (single or batch), RockMapper, and GhostVision from the dedicated `pingwizard` environment. PINGInstaller creates or updates this environment from [`pingwizard/conda/pingwizard.yml`](pingwizard/conda/pingwizard.yml) when installing PINGMapper or RockMapper.
|
|
5
|
+
- Run `conda activate pingwizard` followed by `python -m pingwizard`, or use the shortcut created by PINGInstaller.
|
|
6
|
+
- The wizard discovers PINGMapper in `ping`, RockMapper in `rockmapper_torch`, `rockmapper`, or `rockmapper_torch_gpu`, and GhostVision in `ghostvision`. It launches each utility in its own environment. If multiple RockMapper environments exist, select one in the wizard.
|
|
7
|
+
- If a utility is missing, use **Install** for PINGMapper or RockMapper. RockMapper uses a single Torch environment. The wizard asks for confirmation, then closes and starts PINGInstaller from the base environment. On Windows, progress appears in a new console; on other systems, see the terminal that launched PINGWizard. An existing target environment may be updated with `--prune`, which removes packages not in its environment file.
|
|
8
|
+
- For a missing GhostVision installation, **Install CPU** runs `pinginstaller ghostvision`; CPU inference is experimental. For GPU setup, see [GhostVision's installation instructions](https://github.com/PINGEcosystem/GhostVision#installation). Both installers target the `ghostvision` environment. GhostVision also offers **Download Model** for its Roboflow download utility.
|
|
9
|
+
- PINGMapper's test and update controls remain available when PINGMapper is installed. RockMapper does not currently provide equivalent test commands; follow its installation instructions for updates.
|
|
10
|
+
- PINGMapper updates are launched from the base environment rather than the utility environment.
|
|
11
|
+
|
|
12
|
+
## Verbosity
|
|
13
|
+
- Default: Updates run with maximum verbosity (debug) when triggered from the wizard.
|
|
14
|
+
- Quiet mode: Set environment variable `PINGINSTALLER_VERBOSITY=quiet` before launching PINGWizard to suppress extra solver output, or use `python -m pinginstaller -q` when running from the terminal.
|
|
15
|
+
|
|
16
|
+
[)](https://pypi.org/project/pingwizard/)
|
|
Binary file
|
|
Binary file
|
|
@@ -38,12 +38,12 @@ def get_shortcut_location(home_p: str):
|
|
|
38
38
|
while True:
|
|
39
39
|
event, values = window.read()
|
|
40
40
|
|
|
41
|
-
if event
|
|
41
|
+
if event in (sg.WIN_CLOSED, "Quit", "Submit"):
|
|
42
42
|
break
|
|
43
43
|
|
|
44
44
|
window.close()
|
|
45
45
|
|
|
46
|
-
if event
|
|
46
|
+
if event in (sg.WIN_CLOSED, "Quit"):
|
|
47
47
|
sys.exit()
|
|
48
48
|
|
|
49
49
|
return values['shortcut_path']
|
|
@@ -51,10 +51,11 @@ def get_shortcut_location(home_p: str):
|
|
|
51
51
|
|
|
52
52
|
def windows_shortcut(conda_base: str, conda_env: str, f: str):
|
|
53
53
|
|
|
54
|
-
to_write = """set conda_base=
|
|
55
|
-
"""set conda_env=
|
|
54
|
+
to_write = """set "conda_base={}"\n""".format(conda_base)+\
|
|
55
|
+
"""set "conda_env={}"\n""".format(conda_env)+\
|
|
56
56
|
"\n"+\
|
|
57
|
-
'''call %conda_base%\\Scripts\\activate %conda_env
|
|
57
|
+
'''call "%conda_base%\\Scripts\\activate" "%conda_env%"\n'''+\
|
|
58
|
+
'''if errorlevel 1 (echo Failed to activate PINGWizard environment & pause & exit /b 1)\n\n'''+\
|
|
58
59
|
"call conda env list\n\n"+\
|
|
59
60
|
"echo Launching PINGWizard\n"+\
|
|
60
61
|
"python -m pingwizard\n"+\
|
|
@@ -75,7 +76,7 @@ def linux_shortcut(conda_base: str, conda_env: str, f: str):
|
|
|
75
76
|
"""conda_base="{}"\n""".format(conda_base)+\
|
|
76
77
|
"""conda_env="{}"\n""".format(conda_env)+\
|
|
77
78
|
"\n"+\
|
|
78
|
-
'''source $conda_base/bin/activate $conda_env\n'''+\
|
|
79
|
+
'''source "$conda_base/bin/activate" "$conda_env" || exit 1\n'''+\
|
|
79
80
|
"\n"+\
|
|
80
81
|
"echo Launching PINGWizard\n"+\
|
|
81
82
|
"python -m pingwizard\n"
|
|
@@ -86,7 +87,7 @@ def linux_shortcut(conda_base: str, conda_env: str, f: str):
|
|
|
86
87
|
file.write(to_write)
|
|
87
88
|
|
|
88
89
|
# Make executable
|
|
89
|
-
subprocess.run('''
|
|
90
|
+
subprocess.run(['chmod', 'u+x', f], check=True)
|
|
90
91
|
|
|
91
92
|
# Print instructions
|
|
92
93
|
print('\n\nLaunch PINGWizard from the console by passing')
|
|
@@ -99,14 +100,10 @@ def linux_shortcut(conda_base: str, conda_env: str, f: str):
|
|
|
99
100
|
|
|
100
101
|
def create_shortcut():
|
|
101
102
|
|
|
102
|
-
# Get ping Environment Path
|
|
103
103
|
conda_env = os.environ['CONDA_PREFIX']
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
# Reset conda_env
|
|
109
|
-
conda_env = 'ping'
|
|
104
|
+
conda_base = subprocess.run(
|
|
105
|
+
[os.environ.get('CONDA_EXE', 'conda'), 'info', '--base'],
|
|
106
|
+
check=True, capture_output=True, text=True).stdout.strip()
|
|
110
107
|
|
|
111
108
|
# Get shorcut location
|
|
112
109
|
file_path = get_shortcut_location(home_path)
|
|
@@ -115,11 +112,17 @@ def create_shortcut():
|
|
|
115
112
|
if "Windows" in platform.system():
|
|
116
113
|
# Set file_path
|
|
117
114
|
file_path = os.path.join(file_path, "PINGWizard.bat")
|
|
115
|
+
if os.path.exists(file_path) and sg.popup_yes_no(
|
|
116
|
+
'Replace the existing shortcut?\n{}'.format(file_path)) != 'Yes':
|
|
117
|
+
return
|
|
118
118
|
windows_shortcut(conda_base=conda_base, conda_env=conda_env, f=file_path)
|
|
119
119
|
|
|
120
120
|
else:
|
|
121
121
|
# Set file_path
|
|
122
122
|
file_path = os.path.join(file_path, "PINGWizard.sh")
|
|
123
|
+
if os.path.exists(file_path) and sg.popup_yes_no(
|
|
124
|
+
'Replace the existing shortcut?\n{}'.format(file_path)) != 'Yes':
|
|
125
|
+
return
|
|
123
126
|
linux_shortcut(conda_base=conda_base, conda_env=conda_env, f=file_path)
|
|
124
127
|
|
|
125
128
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Discover and launch utilities in their Conda environments."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
ENVIRONMENT_NAMES = {
|
|
10
|
+
'pingmapper': ('ping',),
|
|
11
|
+
'rockmapper': ('rockmapper_torch', 'rockmapper', 'rockmapper_torch_gpu'),
|
|
12
|
+
'ghostvision': ('ghostvision',),
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _run_json(args):
|
|
17
|
+
result = subprocess.run(args, capture_output=True, text=True, check=True)
|
|
18
|
+
return json.loads(result.stdout)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def discover():
|
|
22
|
+
conda = os.environ.get('CONDA_EXE') or shutil.which('conda')
|
|
23
|
+
if not conda:
|
|
24
|
+
raise RuntimeError('Conda was not found. Start PINGWizard from a Conda environment.')
|
|
25
|
+
try:
|
|
26
|
+
info = _run_json([conda, 'info', '--json'])
|
|
27
|
+
root_prefix = info['root_prefix']
|
|
28
|
+
prefixes = info['envs']
|
|
29
|
+
except (OSError, subprocess.CalledProcessError, ValueError, KeyError) as exc:
|
|
30
|
+
raise RuntimeError('Could not inspect Conda environments: {}'.format(exc)) from exc
|
|
31
|
+
environments = {name: [] for name in ENVIRONMENT_NAMES}
|
|
32
|
+
warnings = []
|
|
33
|
+
for prefix in prefixes:
|
|
34
|
+
env_name = os.path.basename(os.path.normpath(prefix)).lower()
|
|
35
|
+
utilities = [name for name, candidates in ENVIRONMENT_NAMES.items()
|
|
36
|
+
if env_name in candidates]
|
|
37
|
+
if not utilities:
|
|
38
|
+
continue
|
|
39
|
+
try:
|
|
40
|
+
packages = _run_json([conda, 'list', '--json', '--prefix', prefix])
|
|
41
|
+
versions = {package['name'].lower(): package['version'] for package in packages}
|
|
42
|
+
except (OSError, subprocess.CalledProcessError, ValueError, KeyError) as exc:
|
|
43
|
+
detail = getattr(exc, 'stderr', None) or str(exc)
|
|
44
|
+
warnings.append('{}: {}'.format(prefix, detail.strip()))
|
|
45
|
+
continue
|
|
46
|
+
for name in utilities:
|
|
47
|
+
if name in versions:
|
|
48
|
+
environments[name].append((prefix, versions[name]))
|
|
49
|
+
for name, candidates in environments.items():
|
|
50
|
+
candidates.sort(key=lambda item: ENVIRONMENT_NAMES[name].index(
|
|
51
|
+
os.path.basename(os.path.normpath(item[0])).lower()))
|
|
52
|
+
return conda, root_prefix, environments, warnings
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def command(conda, prefix, module, args):
|
|
56
|
+
return [conda, 'run', '--no-capture-output', '--prefix', prefix,
|
|
57
|
+
'python', '-m', module, *args]
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
|
|
2
|
+
import sys, os
|
|
3
|
+
import tempfile
|
|
4
|
+
import time
|
|
5
|
+
import subprocess
|
|
6
|
+
import webbrowser
|
|
7
|
+
from pingwizard.version import __version__ as pwversion
|
|
8
|
+
from pingwizard.environments import discover, command
|
|
9
|
+
|
|
10
|
+
import FreeSimpleGUI as sg
|
|
11
|
+
|
|
12
|
+
# Script directory
|
|
13
|
+
# Add 'pingmapper' to the path, may not need after pypi package...
|
|
14
|
+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
15
|
+
PACKAGE_DIR = os.path.dirname(SCRIPT_DIR)
|
|
16
|
+
sys.path.append(PACKAGE_DIR)
|
|
17
|
+
|
|
18
|
+
# Logo's
|
|
19
|
+
env_dir = os.environ.get('CONDA_PREFIX', sys.prefix)
|
|
20
|
+
pingmapper_logo_name = "PINGMapper_Logo_small.png"
|
|
21
|
+
pingmapper_logo = os.path.join(env_dir, 'pingmapper_config', pingmapper_logo_name)
|
|
22
|
+
if not os.path.isfile(pingmapper_logo):
|
|
23
|
+
pingmapper_logo = os.path.join(SCRIPT_DIR, "assets", pingmapper_logo_name)
|
|
24
|
+
rockmapper_logo = os.path.join(SCRIPT_DIR, "assets", "RockMapper_Logo.png")
|
|
25
|
+
def _start_installer(conda, conda_base, utility):
|
|
26
|
+
if utility not in ('pingmapper', 'rockmapper', 'ghostvision'):
|
|
27
|
+
raise ValueError('Unsupported utility: {}'.format(utility))
|
|
28
|
+
child_env = os.environ.copy()
|
|
29
|
+
child_env.pop('PYTHONPATH', None)
|
|
30
|
+
child_env.pop('PYTHONHOME', None)
|
|
31
|
+
args = [] if utility == 'pingmapper' else [utility]
|
|
32
|
+
batch_file = None
|
|
33
|
+
try:
|
|
34
|
+
if os.name != 'nt':
|
|
35
|
+
subprocess.Popen(
|
|
36
|
+
['/bin/sh', '-c',
|
|
37
|
+
'while kill -0 "$1" 2>/dev/null; do sleep 0.2; done; shift; exec "$@"',
|
|
38
|
+
'pingwizard-installer', str(os.getpid()),
|
|
39
|
+
*command(conda, conda_base, 'pinginstaller', args)],
|
|
40
|
+
env=child_env, start_new_session=True)
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
conda_bat = os.path.join(conda_base, 'condabin', 'conda.bat').replace('%', '%%')
|
|
44
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.bat', encoding='utf-8',
|
|
45
|
+
delete=False) as file:
|
|
46
|
+
batch_file = file.name
|
|
47
|
+
file.write('''@echo off
|
|
48
|
+
chcp 65001 >nul
|
|
49
|
+
echo Waiting for PINGWizard to close...
|
|
50
|
+
:wait_for_pingwizard
|
|
51
|
+
tasklist /FI "PID eq {pid}" /FO CSV /NH 2>nul | find ",""{pid}""," >nul
|
|
52
|
+
if not errorlevel 1 (
|
|
53
|
+
ping -n 2 127.0.0.1 >nul
|
|
54
|
+
goto wait_for_pingwizard
|
|
55
|
+
)
|
|
56
|
+
call "{}" activate base
|
|
57
|
+
if errorlevel 1 (
|
|
58
|
+
echo Failed to activate the base environment.
|
|
59
|
+
pause
|
|
60
|
+
del "%~f0"
|
|
61
|
+
exit /b 1
|
|
62
|
+
)
|
|
63
|
+
python -m pinginstaller {}
|
|
64
|
+
if errorlevel 1 (
|
|
65
|
+
echo Installation failed. See the messages above.
|
|
66
|
+
) else (
|
|
67
|
+
echo Installation finished.
|
|
68
|
+
)
|
|
69
|
+
pause
|
|
70
|
+
del "%~f0"
|
|
71
|
+
'''.format(conda_bat, ' '.join(args), pid=os.getpid()))
|
|
72
|
+
subprocess.Popen(
|
|
73
|
+
[os.environ.get('COMSPEC', 'cmd.exe'), '/c', batch_file],
|
|
74
|
+
env=child_env, creationflags=subprocess.CREATE_NEW_CONSOLE)
|
|
75
|
+
except OSError:
|
|
76
|
+
if batch_file and os.path.exists(batch_file):
|
|
77
|
+
os.remove(batch_file)
|
|
78
|
+
raise
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def wizard():
|
|
82
|
+
|
|
83
|
+
print("Welcome to the PING Wizard!")
|
|
84
|
+
try:
|
|
85
|
+
conda, conda_base, environments, warnings = discover()
|
|
86
|
+
except RuntimeError as exc:
|
|
87
|
+
sg.popup_error(str(exc), title='PING Wizard')
|
|
88
|
+
return
|
|
89
|
+
if warnings:
|
|
90
|
+
sg.popup_error('Some environments could not be inspected:\n\n{}'.format(
|
|
91
|
+
'\n'.join(warnings)), title='PING Wizard')
|
|
92
|
+
pm_envs = environments['pingmapper']
|
|
93
|
+
rm_envs = environments['rockmapper']
|
|
94
|
+
gv_envs = environments['ghostvision']
|
|
95
|
+
pmversion = pm_envs[0][1] if pm_envs else None
|
|
96
|
+
rmversion = rm_envs[0][1] if rm_envs else None
|
|
97
|
+
gvversion = gv_envs[0][1] if gv_envs else None
|
|
98
|
+
rm_env_names = {os.path.basename(os.path.normpath(prefix)).lower()
|
|
99
|
+
for prefix, version in rm_envs}
|
|
100
|
+
rm_standard_installed = bool(rm_env_names & {'rockmapper', 'rockmapper_torch'})
|
|
101
|
+
pm_choices = {'{} (v{})'.format(prefix, version): prefix for prefix, version in pm_envs}
|
|
102
|
+
rm_choices = {'{} (v{})'.format(prefix, version): prefix for prefix, version in rm_envs}
|
|
103
|
+
gv_choices = {'{} (v{})'.format(prefix, version): prefix for prefix, version in gv_envs}
|
|
104
|
+
|
|
105
|
+
# Default to debug verbosity for installer runs unless explicitly overridden
|
|
106
|
+
if 'PINGINSTALLER_VERBOSITY' not in os.environ:
|
|
107
|
+
os.environ['PINGINSTALLER_VERBOSITY'] = 'debug'
|
|
108
|
+
|
|
109
|
+
##########################
|
|
110
|
+
# Define the layout blocks
|
|
111
|
+
|
|
112
|
+
# Title #
|
|
113
|
+
title = sg.Text("PING Wizard", font=("Helvetica", 24), justification="center", size=(25, 1))
|
|
114
|
+
version = sg.Text("ver. {}".format(pwversion), font=("Helvetica", 8), justification="center", size=(75, 1))
|
|
115
|
+
|
|
116
|
+
# PINGMapper #
|
|
117
|
+
## Title
|
|
118
|
+
pm_title = sg.Text("PINGMapper", font=("Helvetica", 16), justification="center")
|
|
119
|
+
|
|
120
|
+
## Description
|
|
121
|
+
pm_desc = sg.Text("PINGMapper ({}) - Open-source interface for processing recreation-grade side scan sonar datasets and reproducibly mapping benthic habitat.".format(
|
|
122
|
+
'installed' if pmversion is not None else 'not installed'),
|
|
123
|
+
font=("Helvetica", 10), justification="left", size=(30, 5))
|
|
124
|
+
|
|
125
|
+
##############
|
|
126
|
+
# PINGMapper #
|
|
127
|
+
##############
|
|
128
|
+
|
|
129
|
+
## Logo
|
|
130
|
+
pm_logo = sg.Image(pingmapper_logo, size=(200, 120))
|
|
131
|
+
|
|
132
|
+
## Launch GUI Buttons
|
|
133
|
+
pm_gui_text = sg.Text("Process\nSonar Log", font=("Helvetica", 10, "bold"), size=(11, 2))
|
|
134
|
+
pm_gui_btn = sg.Button("Single Log", key="launch_pingmapper_gui", button_color="green", size=(10, 2), disabled=pmversion is None)
|
|
135
|
+
pm_batch_gui_btn = sg.Button("Batch\nSonar Logs", key="launch_pingmapper_batch_gui", button_color="darkgreen", size=(10, 2), disabled=pmversion is None)
|
|
136
|
+
|
|
137
|
+
## Test Buttons
|
|
138
|
+
pm_test_text = sg.Text("Test\nPINGMapper", font=("Helvetica", 10, "bold"),size=(11, 2))
|
|
139
|
+
pm_test_single_btn = sg.Button("Small\nDataset", key="test", button_color="navy", size=(10, 2), disabled=pmversion is None)
|
|
140
|
+
pm_test_batch_btn = sg.Button("Large\nDataset", key="test_large", size=(10, 2), disabled=pmversion is None)
|
|
141
|
+
|
|
142
|
+
## Update Installation Buttons
|
|
143
|
+
pm_install_text = sg.Text("Install /\nUpdate", font=("Helvetica", 10, "bold"),size=(11, 2))
|
|
144
|
+
pm_install_btn = sg.Button("Update" if pmversion is not None else "Install",
|
|
145
|
+
key="pinginstaller", button_color="darkorange", size=(10, 2))
|
|
146
|
+
pm_check_btn = sg.Button("Check for Updates", key="check_updates", button_color="grey", size=(10, 2), disabled=pmversion is None)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
##############
|
|
150
|
+
# RockMapper #
|
|
151
|
+
##############
|
|
152
|
+
|
|
153
|
+
rm_desc = sg.Text("RockMapper ({}) - Predict and map rocky substrate from side-scan sonar mosaics.".format(
|
|
154
|
+
'installed' if rmversion is not None else 'not installed'),
|
|
155
|
+
font=("Helvetica", 10), justification="left", size=(30, 5))
|
|
156
|
+
rm_logo = sg.Image(rockmapper_logo, subsample=3)
|
|
157
|
+
rm_gui_text = sg.Text("Map\nSubstrate", font=("Helvetica", 10, "bold"), size=(11, 2))
|
|
158
|
+
rm_gui_btn = sg.Button("RockMapper", key="launch_rockmapper_gui",
|
|
159
|
+
button_color="green", size=(10, 2), disabled=rmversion is None)
|
|
160
|
+
rm_install_btn = sg.Button("Install", key="install_rockmapper",
|
|
161
|
+
button_color="darkorange", size=(10, 2),
|
|
162
|
+
disabled=rm_standard_installed)
|
|
163
|
+
|
|
164
|
+
gv_desc = sg.Text(
|
|
165
|
+
"GhostVision ({}) - Detect and map derelict crab pots from side-scan sonar."
|
|
166
|
+
.format('installed' if gvversion is not None else 'not installed'),
|
|
167
|
+
font=("Helvetica", 10), justification="left", size=(50, 3))
|
|
168
|
+
gv_gui_btn = sg.Button("GhostVision", key="launch_ghostvision_gui",
|
|
169
|
+
button_color="green", size=(12, 2), disabled=gvversion is None)
|
|
170
|
+
gv_download_btn = sg.Button("Download\nModel", key="ghostvision_download",
|
|
171
|
+
size=(12, 2), disabled=gvversion is None)
|
|
172
|
+
gv_install_btn = sg.Button("Install CPU", key="install_ghostvision",
|
|
173
|
+
button_color="darkorange", size=(12, 2),
|
|
174
|
+
disabled=gvversion is not None)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
#############
|
|
178
|
+
# Exit Button
|
|
179
|
+
exit_btn = sg.Button("Quit", key="exit_pingwizard", font=("Helvetica", 12, "bold"), button_color="darkred", size=(10, 1))
|
|
180
|
+
|
|
181
|
+
# Splash + utility selector #
|
|
182
|
+
ecosystem_url = "https://github.com/PINGEcosystem"
|
|
183
|
+
placeholder = "Select a utility..."
|
|
184
|
+
utilities = [("PINGMapper", pmversion is not None, 'pm'),
|
|
185
|
+
("RockMapper", rmversion is not None, 'rm'),
|
|
186
|
+
("GhostVision", gvversion is not None, 'gv')]
|
|
187
|
+
utility_keys = {}
|
|
188
|
+
utility_choices = [placeholder]
|
|
189
|
+
for installed in (True, False):
|
|
190
|
+
for name, is_installed, panel in utilities:
|
|
191
|
+
if is_installed == installed:
|
|
192
|
+
label = "{} ({})".format(name, 'installed' if installed else 'not installed')
|
|
193
|
+
utility_keys[label] = panel
|
|
194
|
+
utility_choices.append(label)
|
|
195
|
+
|
|
196
|
+
splash_logo_path = os.path.join(SCRIPT_DIR, "assets", "PINGWizard_Logo.png")
|
|
197
|
+
splash_logo = (sg.Image(splash_logo_path) if os.path.isfile(splash_logo_path)
|
|
198
|
+
else sg.Text("PW", font=("Helvetica", 48, "bold"), justification="center"))
|
|
199
|
+
splash = [
|
|
200
|
+
[sg.Push(), splash_logo, sg.Push()],
|
|
201
|
+
[sg.Push(), sg.Text("PINGWizard: The Gateway to the", font=("Helvetica", 14)),
|
|
202
|
+
sg.Text("PING Ecosystem", font=("Helvetica", 14, "underline"),
|
|
203
|
+
text_color="blue", enable_events=True, key="-ECOSYSTEM_LINK-",
|
|
204
|
+
tooltip=ecosystem_url),
|
|
205
|
+
sg.Push()],
|
|
206
|
+
]
|
|
207
|
+
selector = [sg.Text("Utility:", size=(11, 1)),
|
|
208
|
+
sg.Combo(utility_choices, default_value=placeholder, key="utility_select",
|
|
209
|
+
readonly=True, enable_events=True, size=(50, 1))]
|
|
210
|
+
|
|
211
|
+
pm_panel = [
|
|
212
|
+
[pm_logo, pm_desc],
|
|
213
|
+
[sg.Text('Environment:', size=(11, 1)),
|
|
214
|
+
sg.Combo(list(pm_choices),
|
|
215
|
+
default_value=next(iter(pm_choices), ''),
|
|
216
|
+
key='pingmapper_env', readonly=True, size=(50, 1),
|
|
217
|
+
disabled=not pm_envs)],
|
|
218
|
+
# [pm_title],
|
|
219
|
+
# [pm_desc],
|
|
220
|
+
[pm_gui_text, sg.VerticalSeparator(), pm_gui_btn, pm_batch_gui_btn],
|
|
221
|
+
[pm_test_text, sg.VerticalSeparator(), pm_test_single_btn, pm_test_batch_btn],
|
|
222
|
+
[pm_install_text, sg.VerticalSeparator(), pm_install_btn, pm_check_btn],
|
|
223
|
+
]
|
|
224
|
+
rm_panel = [
|
|
225
|
+
[rm_logo, rm_desc],
|
|
226
|
+
[sg.Text('Environment:', size=(11, 1)),
|
|
227
|
+
sg.Combo(list(rm_choices),
|
|
228
|
+
default_value=next(iter(rm_choices), ''),
|
|
229
|
+
key='rockmapper_env', readonly=True, size=(50, 1),
|
|
230
|
+
disabled=not rm_envs)],
|
|
231
|
+
[rm_gui_text, sg.VerticalSeparator(), rm_gui_btn, rm_install_btn],
|
|
232
|
+
]
|
|
233
|
+
gv_panel = [
|
|
234
|
+
[gv_desc],
|
|
235
|
+
[sg.Text('Environment:', size=(11, 1)),
|
|
236
|
+
sg.Combo(list(gv_choices),
|
|
237
|
+
default_value=next(iter(gv_choices), ''),
|
|
238
|
+
key='ghostvision_env', readonly=True, size=(50, 1),
|
|
239
|
+
disabled=not gv_envs)],
|
|
240
|
+
[gv_gui_btn, gv_download_btn, gv_install_btn],
|
|
241
|
+
]
|
|
242
|
+
|
|
243
|
+
layout = [
|
|
244
|
+
[title],
|
|
245
|
+
[version],
|
|
246
|
+
[sg.HorizontalSeparator()],
|
|
247
|
+
[sg.pin(sg.Column(splash, key="panel_splash"))],
|
|
248
|
+
selector,
|
|
249
|
+
[sg.HorizontalSeparator()],
|
|
250
|
+
[sg.pin(sg.Column(pm_panel, key="panel_pm", visible=False))],
|
|
251
|
+
[sg.pin(sg.Column(rm_panel, key="panel_rm", visible=False))],
|
|
252
|
+
[sg.pin(sg.Column(gv_panel, key="panel_gv", visible=False))],
|
|
253
|
+
[sg.HorizontalSeparator()],
|
|
254
|
+
[exit_btn],
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
layout2 =[[sg.Column(layout, vertical_scroll_only=True, size_subsample_height=1, expand_x=True, expand_y=True)]]
|
|
260
|
+
window = sg.Window('PING Wizard', layout=layout2, resizable=True, finalize=True)
|
|
261
|
+
pre_minimize_state = {'state': 'normal'}
|
|
262
|
+
|
|
263
|
+
def _minimize_wizard(win):
|
|
264
|
+
# Force a repaint before blocking on subprocess so minimize is visible.
|
|
265
|
+
try:
|
|
266
|
+
win.refresh()
|
|
267
|
+
except Exception:
|
|
268
|
+
pass
|
|
269
|
+
|
|
270
|
+
try:
|
|
271
|
+
pre_minimize_state['state'] = win.TKroot.state()
|
|
272
|
+
except Exception:
|
|
273
|
+
pre_minimize_state['state'] = 'normal'
|
|
274
|
+
|
|
275
|
+
try:
|
|
276
|
+
win.minimize()
|
|
277
|
+
except Exception:
|
|
278
|
+
try:
|
|
279
|
+
win.TKroot.iconify()
|
|
280
|
+
except Exception:
|
|
281
|
+
win.Disappear()
|
|
282
|
+
|
|
283
|
+
# Give the window manager a moment to process minimize events.
|
|
284
|
+
time.sleep(0.1)
|
|
285
|
+
|
|
286
|
+
def _restore_wizard(win):
|
|
287
|
+
restored = False
|
|
288
|
+
try:
|
|
289
|
+
win.TKroot.deiconify()
|
|
290
|
+
win.Reappear()
|
|
291
|
+
win.TKroot.lift()
|
|
292
|
+
win.TKroot.focus_force()
|
|
293
|
+
restored = True
|
|
294
|
+
except Exception:
|
|
295
|
+
pass
|
|
296
|
+
|
|
297
|
+
if not restored:
|
|
298
|
+
try:
|
|
299
|
+
win.normal()
|
|
300
|
+
restored = True
|
|
301
|
+
except Exception:
|
|
302
|
+
pass
|
|
303
|
+
|
|
304
|
+
if not restored:
|
|
305
|
+
try:
|
|
306
|
+
win.Reappear()
|
|
307
|
+
except Exception:
|
|
308
|
+
pass
|
|
309
|
+
|
|
310
|
+
try:
|
|
311
|
+
win.refresh()
|
|
312
|
+
except Exception:
|
|
313
|
+
pass
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
#################
|
|
317
|
+
# Open the wizard
|
|
318
|
+
while True:
|
|
319
|
+
read_result = window.read()
|
|
320
|
+
if read_result is None:
|
|
321
|
+
break
|
|
322
|
+
event, values = read_result
|
|
323
|
+
if event in (sg.WIN_CLOSED, "exit_pingwizard", "Submit"):
|
|
324
|
+
break
|
|
325
|
+
|
|
326
|
+
if event == "-ECOSYSTEM_LINK-":
|
|
327
|
+
webbrowser.open(ecosystem_url)
|
|
328
|
+
continue
|
|
329
|
+
if event == "utility_select":
|
|
330
|
+
selected = utility_keys.get(values["utility_select"])
|
|
331
|
+
window["panel_splash"].update(visible=selected is None)
|
|
332
|
+
window["panel_pm"].update(visible=selected == 'pm')
|
|
333
|
+
window["panel_rm"].update(visible=selected == 'rm')
|
|
334
|
+
window["panel_gv"].update(visible=selected == 'gv')
|
|
335
|
+
window.refresh()
|
|
336
|
+
continue
|
|
337
|
+
|
|
338
|
+
module_name = None
|
|
339
|
+
module_args = []
|
|
340
|
+
|
|
341
|
+
if (event in ("launch_pingmapper_gui", "launch_pingmapper_batch_gui",
|
|
342
|
+
"test", "test_large", "check_updates")
|
|
343
|
+
and pmversion is None):
|
|
344
|
+
sg.popup_error("PINGMapper was not found in a supported Conda environment.")
|
|
345
|
+
continue
|
|
346
|
+
if event == "launch_rockmapper_gui" and rmversion is None:
|
|
347
|
+
sg.popup_error("RockMapper was not found in a supported Conda environment.")
|
|
348
|
+
continue
|
|
349
|
+
if event == "install_rockmapper" and rm_standard_installed:
|
|
350
|
+
sg.popup_error("RockMapper is already installed in a standard environment.")
|
|
351
|
+
continue
|
|
352
|
+
if event in ("launch_ghostvision_gui", "ghostvision_download") and gvversion is None:
|
|
353
|
+
sg.popup_error("GhostVision was not found in a supported Conda environment.")
|
|
354
|
+
continue
|
|
355
|
+
if event == "install_ghostvision" and gvversion is not None:
|
|
356
|
+
sg.popup_error("GhostVision is already installed in the ghostvision environment.")
|
|
357
|
+
continue
|
|
358
|
+
|
|
359
|
+
# Launch PINGMapper GUI
|
|
360
|
+
if event == "launch_pingmapper_gui":
|
|
361
|
+
print("Launching PINGMapper GUI...")
|
|
362
|
+
# Set the arguments for the PINGMapper GUI
|
|
363
|
+
module_name = "pingmapper"
|
|
364
|
+
module_args = ["gui"]
|
|
365
|
+
|
|
366
|
+
elif event == "launch_pingmapper_batch_gui":
|
|
367
|
+
print("Launching PINGMapper Batch GUI...")
|
|
368
|
+
# Set the arguments for the PINGMapper Batch GUI
|
|
369
|
+
module_name = "pingmapper"
|
|
370
|
+
module_args = ["gui_batch"]
|
|
371
|
+
|
|
372
|
+
elif event == "launch_rockmapper_gui":
|
|
373
|
+
print("Launching RockMapper GUI...")
|
|
374
|
+
module_name = "rockmapper"
|
|
375
|
+
module_args = ["gui"]
|
|
376
|
+
|
|
377
|
+
elif event in ("launch_ghostvision_gui", "ghostvision_download"):
|
|
378
|
+
print("Launching GhostVision...")
|
|
379
|
+
module_name = "ghostvision"
|
|
380
|
+
module_args = ["rf-download"] if event == "ghostvision_download" else []
|
|
381
|
+
|
|
382
|
+
elif event == "test":
|
|
383
|
+
print("Testing PINGMapper...")
|
|
384
|
+
# Set the arguments for the PINGMapper GUI
|
|
385
|
+
module_name = "pingmapper"
|
|
386
|
+
module_args = ["test"]
|
|
387
|
+
|
|
388
|
+
elif event == "test_large":
|
|
389
|
+
print("Testing PINGMapper Batch...")
|
|
390
|
+
# Set the arguments for the PINGMapper Batch GUI
|
|
391
|
+
module_name = "pingmapper"
|
|
392
|
+
module_args = ["test_large"]
|
|
393
|
+
|
|
394
|
+
elif event in ("pinginstaller", "install_rockmapper", "install_ghostvision"):
|
|
395
|
+
utility, target = {
|
|
396
|
+
'pinginstaller': ('pingmapper', 'ping'),
|
|
397
|
+
'install_rockmapper': ('rockmapper', 'rockmapper_torch'),
|
|
398
|
+
'install_ghostvision': ('ghostvision', 'ghostvision, CPU'),
|
|
399
|
+
}[event]
|
|
400
|
+
output = ('a new console window' if os.name == 'nt'
|
|
401
|
+
else 'the terminal used to launch PINGWizard')
|
|
402
|
+
answer = sg.popup_yes_no(
|
|
403
|
+
'Run PINGInstaller for {} ({})?\n\n'
|
|
404
|
+
'An existing environment may be updated with --prune, removing packages '
|
|
405
|
+
'not in its environment file. PINGWizard will close; follow progress in {}.'
|
|
406
|
+
.format(utility, target, output), title='Confirm installation')
|
|
407
|
+
if answer != 'Yes':
|
|
408
|
+
continue
|
|
409
|
+
try:
|
|
410
|
+
_start_installer(conda, conda_base, utility)
|
|
411
|
+
except (OSError, ValueError) as exc:
|
|
412
|
+
sg.popup_error('Could not start PINGInstaller: {}'.format(exc),
|
|
413
|
+
title='PING Wizard')
|
|
414
|
+
continue
|
|
415
|
+
print('PINGInstaller started for {}. Closing PINGWizard.'.format(utility))
|
|
416
|
+
break
|
|
417
|
+
|
|
418
|
+
elif event == "check_updates":
|
|
419
|
+
print("Checking for updates...")
|
|
420
|
+
# Set the arguments for the PINGMapper Batch GUI
|
|
421
|
+
module_name = "pinginstaller"
|
|
422
|
+
module_args = ["check"]
|
|
423
|
+
|
|
424
|
+
# Ignore non-launch events so the wizard does not re-minimize/relaunch unexpectedly.
|
|
425
|
+
if module_name is None:
|
|
426
|
+
continue
|
|
427
|
+
|
|
428
|
+
_minimize_wizard(window)
|
|
429
|
+
try:
|
|
430
|
+
# Run the selected module in a child process to avoid GUI state conflicts.
|
|
431
|
+
if module_name == 'rockmapper':
|
|
432
|
+
prefix = rm_choices[values['rockmapper_env']]
|
|
433
|
+
elif module_name == 'ghostvision':
|
|
434
|
+
prefix = gv_choices[values['ghostvision_env']]
|
|
435
|
+
else:
|
|
436
|
+
prefix = pm_choices[values['pingmapper_env']]
|
|
437
|
+
cmd = command(conda, prefix, module_name, module_args)
|
|
438
|
+
child_env = os.environ.copy()
|
|
439
|
+
child_env.pop('PYTHONPATH', None)
|
|
440
|
+
child_env.pop('PYTHONHOME', None)
|
|
441
|
+
result = subprocess.run(cmd, env=child_env)
|
|
442
|
+
if result.returncode != 0:
|
|
443
|
+
print(f"Warning: {module_name} exited with code {result.returncode}")
|
|
444
|
+
sg.popup_error("{} exited with code {}. See the terminal for details.".format(
|
|
445
|
+
module_name, result.returncode), title="PING Wizard")
|
|
446
|
+
except OSError as exc:
|
|
447
|
+
sg.popup_error("Could not launch {}: {}".format(module_name, exc), title="PING Wizard")
|
|
448
|
+
finally:
|
|
449
|
+
time.sleep(1)
|
|
450
|
+
_restore_wizard(window)
|
|
451
|
+
|
|
452
|
+
window.close()
|
|
453
|
+
|
|
454
|
+
if __name__ == "__main__":
|
|
455
|
+
|
|
456
|
+
wizard()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.1.0'
|