diff --git a/dpdispatcher/contexts/openapi_context.py b/dpdispatcher/contexts/openapi_context.py index 8346fcd5..0fd66486 100644 --- a/dpdispatcher/contexts/openapi_context.py +++ b/dpdispatcher/contexts/openapi_context.py @@ -23,6 +23,37 @@ DP_CLOUD_SERVER_HOME_DIR = os.path.join( os.path.expanduser("~"), ".dpdispatcher/", "dp_cloud_server/" ) +os.makedirs(DP_CLOUD_SERVER_HOME_DIR, exist_ok=True) + + +def unzip_file(zip_file, out_dir="./"): + obj = ZipFile(zip_file, "r") + for item in obj.namelist(): + obj.extract(item, out_dir) + + +def zip_file_list(root_path, zip_filename, file_list=[]): + out_zip_file = os.path.join(root_path, zip_filename) + # print('debug: file_list', file_list) + zip_obj = ZipFile(out_zip_file, "w") + for f in file_list: + matched_files = os.path.join(root_path, f) + for ii in glob.glob(matched_files): + # print('debug: matched_files:ii', ii) + if os.path.isdir(ii): + arcname = os.path.relpath(ii, start=root_path) + zip_obj.write(ii, arcname) + for root, dirs, files in os.walk(ii): + for file in files: + filename = os.path.join(root, file) + arcname = os.path.relpath(filename, start=root_path) + # print('debug: filename:arcname:root_path', filename, arcname, root_path) + zip_obj.write(filename, arcname) + else: + arcname = os.path.relpath(ii, start=root_path) + zip_obj.write(ii, arcname) + zip_obj.close() + return out_zip_file def unzip_file(zip_file, out_dir="./"): diff --git a/pyproject.toml b/pyproject.toml index 9bbec718..e53e312b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,9 @@ dependencies = [ 'typing_extensions; python_version < "3.7"', 'pyyaml', 'tomli >= 1.1.0; python_version < "3.11"', + 'httpx', + 'distro', + 'pyhumps' ] requires-python = ">=3.7" readme = "README.md"