Skip to content

Commit

Permalink
feature: 提供 Agent 包管理后台基础接口 (closed #1683)
Browse files Browse the repository at this point in the history
  • Loading branch information
ping15 committed Jan 26, 2024
1 parent 70572a4 commit 6e2de4b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
9 changes: 3 additions & 6 deletions apps/backend/agent/artifact_builder/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ class AgentArtifactBuilder(base.BaseArtifactBuilder):
]

def extract_initial_artifact(self, initial_artifact_local_path: str, extract_dir: str):
if not self.extract_dir:
self.extract_dir = extract_dir
with tarfile.open(name=initial_artifact_local_path) as tf:
tf.extractall(path=extract_dir)
extract_dir: str = os.path.join(self.extract_dir, self.BASE_PKG_DIR)
self._inject_dependencies(extract_dir)
with tarfile.open(name=initial_artifact_local_path) as tf:
tf.extractall(path=extract_dir)
extract_dir: str = os.path.join(extract_dir, self.BASE_PKG_DIR)
return extract_dir

def _get_support_files_info(self, extract_dir: str) -> typing.Dict[str, typing.Any]:
Expand Down
8 changes: 4 additions & 4 deletions apps/backend/agent/artifact_builder/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class ProxyArtifactBuilder(base.BaseArtifactBuilder):
PROXY_SVR_EXES: typing.List[str] = ["gse_data", "gse_file"]

def extract_initial_artifact(self, initial_artifact_local_path: str, extract_dir: str):
if not self.extract_dir:
self.extract_dir = extract_dir
Archive(initial_artifact_local_path).extractall(extract_dir, auto_create_dir=True)
# todo: 是否使用Archive(initial_artifact_local_path).extractall(extract_dir, auto_create_dir=True)
with tarfile.open(name=initial_artifact_local_path) as tf:
tf.extractall(path=extract_dir)

extract_dir: str = os.path.join(self.extract_dir, self.BASE_PKG_DIR)
extract_dir: str = os.path.join(extract_dir, self.BASE_PKG_DIR)
if not os.path.exists(extract_dir):
raise FileExistsError(_("Proxy 包解压后不存在 {base_pkg_dir} 目录").format(base_pkg_dir=self.BASE_PKG_DIR))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from apps.backend.tests.agent import utils
from apps.mock_data import utils as mock_data_utils
from apps.node_man import models
from apps.node_man.models import GsePackageDesc

from . import test_agent

Expand Down

0 comments on commit 6e2de4b

Please sign in to comment.