Bug 1307482 - Refactor remote path logic into function; r?ted
We'll call this multiple times in a subsequent commit. I hate DRY
violations.
MozReview-Commit-ID: Khai4EZkPCS
--- a/build/upload.py
+++ b/build/upload.py
@@ -222,23 +222,26 @@ def UploadFiles(user, host, path, files,
if upload_to_temp_dir:
path = DoSSHCommand("mktemp -d", user, host, port=port, ssh_key=ssh_key)
if not path.endswith("/"):
path += "/"
if base_path is not None:
base_path = os.path.abspath(base_path)
remote_files = []
properties = {}
+
+ def get_remote_path(p):
+ return GetBaseRelativePath(path, os.path.abspath(p), base_path)
+
try:
for file in files:
- file = os.path.abspath(file)
if not os.path.isfile(file):
raise IOError("File not found: %s" % file)
# first ensure that path exists remotely
- remote_path = GetBaseRelativePath(path, file, base_path)
+ remote_path = get_remote_path(file)
DoSSHCommand("mkdir -p " + remote_path, user, host, port=port, ssh_key=ssh_key)
if verbose:
print "Uploading " + file
DoSCPFile(file, remote_path, user, host, port=port, ssh_key=ssh_key)
remote_files.append(remote_path + '/' + os.path.basename(file))
if post_upload_command is not None:
if verbose:
print "Running post-upload command: " + post_upload_command