From f8f50309760ff6347696b009c8543138a24e599f Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Sat, 7 Oct 2023 12:22:40 +0800 Subject: [PATCH] change imports --- app/base.py | 2 +- app/build_containers.py | 6 +++--- app/build_npms.py | 6 +++--- app/cli.py | 16 ++++++++-------- .../stacks/mainnet-laconic/deploy/commands.py | 10 +++++----- app/data/stacks/test/deploy/commands.py | 8 ++++---- app/deploy.py | 12 ++++++------ app/deploy_types.py | 2 +- app/deploy_util.py | 4 ++-- app/deployment.py | 4 ++-- app/deployment_create.py | 6 +++--- app/setup_repositories.py | 4 ++-- app/update.py | 2 +- app/version.py | 2 +- 14 files changed, 42 insertions(+), 42 deletions(-) diff --git a/app/base.py b/app/base.py index cc20da1b..6802ad48 100644 --- a/app/base.py +++ b/app/base.py @@ -15,8 +15,8 @@ import os from abc import ABC, abstractmethod -from app.deploy import get_stack_status from decouple import config +from .deploy import get_stack_status def get_stack(config, stack): diff --git a/app/build_containers.py b/app/build_containers.py index 0187bb5e..f067203b 100644 --- a/app/build_containers.py +++ b/app/build_containers.py @@ -27,8 +27,8 @@ import subprocess import click import importlib.resources from pathlib import Path -from app.util import include_exclude_check, get_parsed_stack_config -from app.base import get_npm_registry_url +from .util import include_exclude_check, get_parsed_stack_config +from .base import get_npm_registry_url # TODO: find a place for this # epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)" @@ -67,7 +67,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args): print('Dev root directory doesn\'t exist, creating') # See: https://stackoverflow.com/a/20885799/1701505 - from app import data + from . import data with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file: all_containers = container_list_file.read().splitlines() diff --git a/app/build_npms.py b/app/build_npms.py index 2ffbea1b..bd48a318 100644 --- a/app/build_npms.py +++ b/app/build_npms.py @@ -25,8 +25,8 @@ from decouple import config import click import importlib.resources from python_on_whales import docker, DockerException -from app.base import get_stack -from app.util import include_exclude_check, get_parsed_stack_config +from .base import get_stack +from .util import include_exclude_check, get_parsed_stack_config builder_js_image_name = "cerc/builder-js:local" @@ -83,7 +83,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args): os.makedirs(build_root_path) # See: https://stackoverflow.com/a/20885799/1701505 - from app import data + from . import data with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file: all_packages = package_list_file.read().splitlines() diff --git a/app/cli.py b/app/cli.py index 63823715..60159a07 100644 --- a/app/cli.py +++ b/app/cli.py @@ -15,14 +15,14 @@ import click -from app.command_types import CommandOptions -from app import setup_repositories -from app import build_containers -from app import build_npms -from app import deploy -from app import version -from app import deployment -from app import update +from .command_types import CommandOptions +from . import setup_repositories +from . import build_containers +from . import build_npms +from . import deploy +from . import version +from . import deployment +from . import update CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) diff --git a/app/data/stacks/mainnet-laconic/deploy/commands.py b/app/data/stacks/mainnet-laconic/deploy/commands.py index 3a62b42d..c0a73c7a 100644 --- a/app/data/stacks/mainnet-laconic/deploy/commands.py +++ b/app/data/stacks/mainnet-laconic/deploy/commands.py @@ -13,11 +13,11 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from app.util import get_yaml -from app.deploy_types import DeployCommandContext, LaconicStackSetupCommand, DeploymentContext -from app.stack_state import State -from app.deploy_util import VolumeMapping, run_container_command -from app.command_types import CommandOptions +from laconic_stack_orchestrator.util import get_yaml +from laconic_stack_orchestrator.deploy_types import DeployCommandContext, LaconicStackSetupCommand, DeploymentContext +from laconic_stack_orchestrator.stack_state import State +from laconic_stack_orchestrator.deploy_util import VolumeMapping, run_container_command +from laconic_stack_orchestrator.command_types import CommandOptions from enum import Enum from pathlib import Path from shutil import copyfile, copytree diff --git a/app/data/stacks/test/deploy/commands.py b/app/data/stacks/test/deploy/commands.py index fbb9a8ea..9e7c32ec 100644 --- a/app/data/stacks/test/deploy/commands.py +++ b/app/data/stacks/test/deploy/commands.py @@ -13,10 +13,10 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from app.util import get_yaml -from app.deploy_types import DeployCommandContext -from app.stack_state import State -from app.deploy_util import VolumeMapping, run_container_command +from laconic_stack_orchestrator.util import get_yaml +from laconic_stack_orchestrator.deploy_types import DeployCommandContext +from laconic_stack_orchestrator.stack_state import State +from laconic_stack_orchestrator.deploy_util import VolumeMapping, run_container_command from pathlib import Path default_spec_file_content = """config: diff --git a/app/deploy.py b/app/deploy.py index 51749ff9..e7ae24ce 100644 --- a/app/deploy.py +++ b/app/deploy.py @@ -26,11 +26,11 @@ import subprocess from python_on_whales import DockerClient, DockerException import click from pathlib import Path -from app.util import include_exclude_check, get_parsed_stack_config, global_options2 -from app.deploy_types import ClusterContext, DeployCommandContext -from app.deployment_create import create as deployment_create -from app.deployment_create import init as deployment_init -from app.deployment_create import setup as deployment_setup +from .util import include_exclude_check, get_parsed_stack_config, global_options2 +from .deploy_types import ClusterContext, DeployCommandContext +from .deployment_create import create as deployment_create +from .deployment_create import init as deployment_init +from .deployment_create import setup as deployment_setup @click.group() @@ -263,7 +263,7 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file): print(f"Using cluster name: {cluster}") # See: https://stackoverflow.com/a/20885799/1701505 - from app import data + from . import data with resources.open_text(data, "pod-list.txt") as pod_list_file: all_pods = pod_list_file.read().splitlines() diff --git a/app/deploy_types.py b/app/deploy_types.py index 63f32762..4791bbe3 100644 --- a/app/deploy_types.py +++ b/app/deploy_types.py @@ -17,7 +17,7 @@ from typing import List from dataclasses import dataclass from pathlib import Path from python_on_whales import DockerClient -from app.command_types import CommandOptions +from .command_types import CommandOptions @dataclass diff --git a/app/deploy_util.py b/app/deploy_util.py index 2f5f0188..69070147 100644 --- a/app/deploy_util.py +++ b/app/deploy_util.py @@ -15,8 +15,8 @@ import os from typing import List -from app.deploy_types import DeployCommandContext, VolumeMapping -from app.util import get_parsed_stack_config, get_yaml, get_compose_file_dir +from .deploy_types import DeployCommandContext, VolumeMapping +from .util import get_parsed_stack_config, get_yaml, get_compose_file_dir def _container_image_from_service(stack: str, service: str): diff --git a/app/deployment.py b/app/deployment.py index aeabf61c..0abafe39 100644 --- a/app/deployment.py +++ b/app/deployment.py @@ -17,8 +17,8 @@ import click from dataclasses import dataclass from pathlib import Path import sys -from app.deploy import up_operation, down_operation, ps_operation, port_operation -from app.deploy import exec_operation, logs_operation, create_deploy_context +from .deploy import up_operation, down_operation, ps_operation, port_operation +from .deploy import exec_operation, logs_operation, create_deploy_context @dataclass diff --git a/app/deployment_create.py b/app/deployment_create.py index 76016262..c4f57f3b 100644 --- a/app/deployment_create.py +++ b/app/deployment_create.py @@ -20,9 +20,9 @@ from pathlib import Path import random from shutil import copyfile, copytree import sys -from app.util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml -from app.util import get_compose_file_dir -from app.deploy_types import DeploymentContext, LaconicStackSetupCommand +from .util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml +from .util import get_compose_file_dir +from .deploy_types import DeploymentContext, LaconicStackSetupCommand def _make_default_deployment_dir(): diff --git a/app/setup_repositories.py b/app/setup_repositories.py index c14dccb4..f41cce9c 100644 --- a/app/setup_repositories.py +++ b/app/setup_repositories.py @@ -25,7 +25,7 @@ import click import importlib.resources from pathlib import Path import yaml -from app.util import include_exclude_check +from .util import include_exclude_check class GitProgress(git.RemoteProgress): @@ -232,7 +232,7 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches os.makedirs(dev_root_path) # See: https://stackoverflow.com/a/20885799/1701505 - from app import data + from . import data with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file: all_repos = repository_list_file.read().splitlines() diff --git a/app/update.py b/app/update.py index 9f70b06e..0eeaa803 100644 --- a/app/update.py +++ b/app/update.py @@ -23,7 +23,7 @@ import sys import stat import shutil import validators -from app.util import get_yaml +from .util import get_yaml def _download_url(url: str, file_path: Path): diff --git a/app/version.py b/app/version.py index 5a5c33d4..eb28bae7 100644 --- a/app/version.py +++ b/app/version.py @@ -23,7 +23,7 @@ def command(ctx): '''print tool version''' # See: https://stackoverflow.com/a/20885799/1701505 - from app import data + from . import data with importlib.resources.open_text(data, "build_tag.txt") as version_file: # TODO: code better version that skips comment lines version_string = version_file.read().splitlines()[1]