Pack project: Raise exception with reasonable message (#5145)

* raise exception with reasonable message

* raise errors at better places
This commit is contained in:
Jakub Trllo 2023-06-15 14:32:53 +02:00 committed by GitHub
parent 59b7e265da
commit 22296aeb6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -113,6 +113,12 @@ def pack_project(
project_name
))
if only_documents and not destination_dir:
raise ValueError((
"Destination directory must be defined"
" when only documents should be packed."
))
root_path = None
source_root = {}
project_source_path = None
@ -141,6 +147,11 @@ def pack_project(
if not destination_dir:
destination_dir = root_path
if not destination_dir:
raise ValueError(
"Project {} does not have any roots.".format(project_name)
)
destination_dir = os.path.normpath(destination_dir)
if not os.path.exists(destination_dir):
os.makedirs(destination_dir)

View file

@ -356,6 +356,13 @@ class PypeCommands:
def pack_project(self, project_name, dirpath, database_only):
from openpype.lib.project_backpack import pack_project
if database_only and not dirpath:
raise ValueError((
"Destination dir must be defined when using --dbonly."
" Use '--dirpath {output dir path}' flag"
" to specify directory."
))
pack_project(project_name, dirpath, database_only)
def unpack_project(self, zip_filepath, new_root, database_only):