Add option to checkout all deps (even unused-indirect deps)
eg: bam checkout path/ --all-deps
This commit is contained in:
@@ -361,7 +361,12 @@ class bam_commands:
|
|||||||
print("Session %r created" % session_name)
|
print("Session %r created" % session_name)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def checkout(path, output_dir=None, session_rootdir_partial=None):
|
def checkout(
|
||||||
|
path,
|
||||||
|
output_dir=None,
|
||||||
|
session_rootdir_partial=None,
|
||||||
|
all_deps=False,
|
||||||
|
):
|
||||||
|
|
||||||
cfg = bam_config.load(abort=True)
|
cfg = bam_config.load(abort=True)
|
||||||
|
|
||||||
@@ -386,6 +391,9 @@ class bam_commands:
|
|||||||
payload = {
|
payload = {
|
||||||
"filepath": path,
|
"filepath": path,
|
||||||
"command": "checkout",
|
"command": "checkout",
|
||||||
|
"arguments": json.dumps({
|
||||||
|
"all_deps": all_deps,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@@ -657,24 +665,23 @@ class bam_commands:
|
|||||||
|
|
||||||
# --------------
|
# --------------
|
||||||
# Commit Request
|
# Commit Request
|
||||||
args = {
|
|
||||||
'message': message,
|
|
||||||
}
|
|
||||||
payload = {
|
payload = {
|
||||||
'command': 'commit',
|
"command": "commit",
|
||||||
'arguments': json.dumps(args),
|
"arguments": json.dumps({
|
||||||
|
'message': message,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
files = {
|
files = {
|
||||||
'file': open(temp_zip, 'rb'),
|
"file": open(temp_zip, 'rb'),
|
||||||
}
|
}
|
||||||
|
|
||||||
r = requests.put(
|
r = requests.put(
|
||||||
bam_session.request_url("file"),
|
bam_session.request_url("file"),
|
||||||
params=payload,
|
params=payload,
|
||||||
auth=(cfg['user'], cfg['password']),
|
auth=(cfg["user"], cfg["password"]),
|
||||||
files=files)
|
files=files)
|
||||||
|
|
||||||
files['file'].close()
|
files["file"].close()
|
||||||
os.remove(temp_zip)
|
os.remove(temp_zip)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -944,9 +951,13 @@ def create_argparse_checkout(subparsers):
|
|||||||
"-o", "--output", dest="output", type=str, metavar='DIRNAME',
|
"-o", "--output", dest="output", type=str, metavar='DIRNAME',
|
||||||
help="Local name to checkout the session into (optional, falls back to path name)",
|
help="Local name to checkout the session into (optional, falls back to path name)",
|
||||||
)
|
)
|
||||||
|
subparse.add_argument(
|
||||||
|
"-a", "--all-deps", dest="all_deps", action='store_true',
|
||||||
|
help="Checkout all dependencies (unused indirect dependencies too)",
|
||||||
|
)
|
||||||
subparse.set_defaults(
|
subparse.set_defaults(
|
||||||
func=lambda args:
|
func=lambda args:
|
||||||
bam_commands.checkout(args.path, args.output),
|
bam_commands.checkout(args.path, args.output, args.all_deps),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -94,6 +94,8 @@ def pack(
|
|||||||
blendfile_src, blendfile_dst, mode='FILE',
|
blendfile_src, blendfile_dst, mode='FILE',
|
||||||
paths_remap_relbase=None,
|
paths_remap_relbase=None,
|
||||||
deps_remap=None, paths_remap=None, paths_uuid=None,
|
deps_remap=None, paths_remap=None, paths_uuid=None,
|
||||||
|
# load every libs dep, not just used deps.
|
||||||
|
all_deps=False,
|
||||||
# yield reports
|
# yield reports
|
||||||
report=None,
|
report=None,
|
||||||
|
|
||||||
@@ -190,6 +192,7 @@ def pack(
|
|||||||
readonly=False,
|
readonly=False,
|
||||||
temp_remap_cb=temp_remap_cb,
|
temp_remap_cb=temp_remap_cb,
|
||||||
recursive=True,
|
recursive=True,
|
||||||
|
recursive_all=all_deps,
|
||||||
lib_visit=lib_visit,
|
lib_visit=lib_visit,
|
||||||
):
|
):
|
||||||
|
|
||||||
|
@@ -170,6 +170,9 @@ class FileAPI(Resource):
|
|||||||
def get(self, project_name):
|
def get(self, project_name):
|
||||||
filepath = request.args['filepath']
|
filepath = request.args['filepath']
|
||||||
command = request.args['command']
|
command = request.args['command']
|
||||||
|
command_args = request.args.get('arguments')
|
||||||
|
if command_args is not None:
|
||||||
|
command_args = json.loads(command_args)
|
||||||
|
|
||||||
project = Project.query.filter_by(name=project_name).first()
|
project = Project.query.filter_by(name=project_name).first()
|
||||||
|
|
||||||
@@ -210,7 +213,12 @@ class FileAPI(Resource):
|
|||||||
os.close(filepath_zip[0])
|
os.close(filepath_zip[0])
|
||||||
filepath_zip = filepath_zip[1]
|
filepath_zip = filepath_zip[1]
|
||||||
|
|
||||||
yield from self.pack_fn(filepath, filepath_zip, project.repository_path, report)
|
yield from self.pack_fn(
|
||||||
|
filepath, filepath_zip,
|
||||||
|
project.repository_path,
|
||||||
|
command_args['all_deps'],
|
||||||
|
report,
|
||||||
|
)
|
||||||
|
|
||||||
# TODO, handle fail
|
# TODO, handle fail
|
||||||
if not os.path.exists(filepath_zip):
|
if not os.path.exists(filepath_zip):
|
||||||
@@ -340,7 +348,7 @@ class FileAPI(Resource):
|
|||||||
return jsonify(message='File not allowed')
|
return jsonify(message='File not allowed')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def pack_fn(filepath, filepath_zip, paths_remap_relbase, report):
|
def pack_fn(filepath, filepath_zip, paths_remap_relbase, all_deps, report):
|
||||||
"""
|
"""
|
||||||
'paths_remap_relbase' is the project path,
|
'paths_remap_relbase' is the project path,
|
||||||
we want all paths to be relative to this so we don't get server path included.
|
we want all paths to be relative to this so we don't get server path included.
|
||||||
@@ -367,6 +375,7 @@ class FileAPI(Resource):
|
|||||||
paths_remap_relbase=paths_remap_relbase.encode('utf-8'),
|
paths_remap_relbase=paths_remap_relbase.encode('utf-8'),
|
||||||
# TODO(cam) this just means the json is written in the zip
|
# TODO(cam) this just means the json is written in the zip
|
||||||
deps_remap=deps_remap, paths_remap=paths_remap, paths_uuid=paths_uuid,
|
deps_remap=deps_remap, paths_remap=paths_remap, paths_uuid=paths_uuid,
|
||||||
|
all_deps=all_deps,
|
||||||
report=report,
|
report=report,
|
||||||
blendfile_src_dir_fakeroot=blendfile_src_dir_fakeroot.encode('utf-8'),
|
blendfile_src_dir_fakeroot=blendfile_src_dir_fakeroot.encode('utf-8'),
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user