Skip to content

Commit

Permalink
fix: bug added in v0.0.3 which caused Exception if server wasn't goin…
Browse files Browse the repository at this point in the history
…g to restart
  • Loading branch information
jpagh committed Aug 19, 2024
1 parent e01332c commit 1899fb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docassemblecli3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# docassemblecli3/__init__.py
from .docassemblecli3 import cli

__version__ = "0.0.3"
__version__ = "0.0.4"
__all__ = ["cli"]
10 changes: 7 additions & 3 deletions docassemblecli3/docassemblecli3.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def select_env(cfg: str = None, env: list = None, apiurl: str = None, apikey: st

def wait_for_server(playground:bool, task_id: str, apikey: str, apiurl: str, server_version_da: str = "0"):
click.secho("Waiting for package to install...", fg="cyan")
if version.parse(server_version_da) >= version.parse("1.5.3"):
if server_version_da == "norestart" or version.parse(server_version_da) >= version.parse("1.5.3"):
manually_wait_for_background_processes = False
else:
manually_wait_for_background_processes = True
Expand Down Expand Up @@ -284,7 +284,6 @@ def wait_for_server(playground:bool, task_id: str, apikey: str, apiurl: str, ser
if DEBUG:
click.echo(f"""Package install duration: {(after_wait_for_server - before_wait_for_server):.2f}s""")
if manually_wait_for_background_processes:
click.secho("Waiting for server...", fg="cyan")
time.sleep(after_wait_for_server - before_wait_for_server)
if success:
return True
Expand Down Expand Up @@ -387,14 +386,14 @@ def package_installer(directory, apiurl, apikey, playground, restart):
try:
server_packages = requests.get(apiurl + "/api/package", headers={"X-API-Key": apikey})
installed_packages = server_packages.json()
server_version_da = "0"
for package in installed_packages:
if package.get("name", "") == "docassemble":
server_version_da = package.get("version", "0")
except Exception as err:
click.secho(f"""\n{err.__class__.__name__}""", fg="red")
raise click.ClickException(f"""{err}\n""")
if not should_restart:
server_version_da = "norestart"
data["restart"] = "0"
if playground:
if playground != "default":
Expand Down Expand Up @@ -489,6 +488,11 @@ def install(directory, config, api, server, playground, restart):
`install` tries to get API info from the --api option first (if used), then from the first server listed in the ~/.docassemblecli file if it exists (unless the --config option is used), then it tries to use environmental variables, and finally it prompts the user directly.
"""
selected_server = select_server(*config, *api, server)
click.echo(f"""Server: {selected_server["name"]}""")
if not playground:
click.echo("Location: Package")
else:
click.echo(f"""Location: Playground "{playground}" """)
click.secho(f"""[{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}] Installing...""", fg="yellow")
package_installer(directory=directory, apiurl=selected_server["apiurl"], apikey=selected_server["apikey"], playground=playground, restart=restart)
return 0
Expand Down

0 comments on commit 1899fb2

Please sign in to comment.