Skip to content

Commit

Permalink
add detail
Browse files Browse the repository at this point in the history
  • Loading branch information
ZihengSun committed Jun 30, 2024
1 parent b348c02 commit 33b9e98
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 34 deletions.
91 changes: 58 additions & 33 deletions pygeoweaver/commands/pgw_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Detail subcommand
"""

import logging
import subprocess

import requests
Expand All @@ -12,8 +13,11 @@
get_geoweaver_jar_path,
get_java_bin_path,
get_root_dir,
get_spinner,
)

logger = logging.getLogger(__name__)


def detail_workflow(workflow_id):
"""
Expand All @@ -24,17 +28,25 @@ def detail_workflow(workflow_id):
"""
if not workflow_id:
raise RuntimeError("Workflow id is missing")
download_geoweaver_jar()
subprocess.run(
[
get_java_bin_path(),
"-jar",
get_geoweaver_jar_path(),
"detail",
f"--workflow-id={workflow_id}",
],
cwd=f"{get_root_dir()}/",
)
with get_spinner(text="Getting host details..", spinner="dots"):
download_geoweaver_jar()
process = subprocess.run(
[
get_java_bin_path(),
"-jar",
get_geoweaver_jar_path(),
"detail",
f"--workflow-id={workflow_id}",
],
cwd=f"{get_root_dir()}/",
)

print(process.stdout)
if process.stderr:
print("=== Error ===")
print(process.stderr)
logger.error(process.stderr)


def detail_process(process_id):
"""
Expand All @@ -45,17 +57,23 @@ def detail_process(process_id):
"""
if not process_id:
raise RuntimeError("Process id is missing")
download_geoweaver_jar()
subprocess.run(
[
get_java_bin_path(),
"-jar",
get_geoweaver_jar_path(),
"detail",
f"--process-id={process_id}",
],
cwd=f"{get_root_dir()}/",
)
with get_spinner(text="Getting host details..", spinner="dots"):
download_geoweaver_jar()
process = subprocess.run(
[
get_java_bin_path(),
"-jar",
get_geoweaver_jar_path(),
"detail",
f"--process-id={process_id}",
],
cwd=f"{get_root_dir()}/",
)
print(process.stdout)
if process.stderr:
print("=== Error ===")
print(process.stderr)
logger.error(process.stderr)

def detail_host(host_id):
"""
Expand All @@ -66,17 +84,24 @@ def detail_host(host_id):
"""
if not host_id:
raise RuntimeError("Host id is missing")
download_geoweaver_jar()
subprocess.run(
[
get_java_bin_path(),
"-jar",
get_geoweaver_jar_path(),
"detail",
f"--host-id={host_id}",
],
cwd=f"{get_root_dir()}/",
)
with get_spinner(text="Getting host details..", spinner="dots"):
download_geoweaver_jar()
process = subprocess.run(
[
get_java_bin_path(),
"-jar",
get_geoweaver_jar_path(),
"detail",
f"--host-id={host_id}",
],
cwd=f"{get_root_dir()}/",
)

print(process.stdout)
if process.stderr:
print("=== Error ===")
print(process.stderr)
logger.error(process.stderr)

def get_process_code(process_id):
"""
Expand Down
2 changes: 1 addition & 1 deletion pygeoweaver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def is_interactive():
return False # Probably standard Python interpreter


def get_spinner(text: str, spinner: str):
def get_spinner(text: str, spinner: str = "dots"):
if is_interactive():
return Spinner(text=text, style=spinner)
else:
Expand Down

0 comments on commit 33b9e98

Please sign in to comment.