Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Add --domain argument support
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan Harbison committed Oct 7, 2020
1 parent 49af90b commit 50525a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
23 changes: 18 additions & 5 deletions dp_file_uploader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,23 @@ def get_port(args):
return port


def normalize_directory(directory):
if directory.endswith('/'):
return directory
def get_domain(args):
if args.domain is not None:
domain = args.domain[0]
else:
return directory + '/'
domain = None
return domain


def normalize_directory(directory, domain):
prefix, suffix = directory.split(":")
_, subpath = suffix.split("///")
if not subpath.endswith('/'):
subpath = subpath + '/'
if domain is not None:
return prefix + ":///" + domain + "/" + subpath
else:
return prefix + ":///" + subpath


def build_url(hostname, port):
Expand Down Expand Up @@ -121,6 +133,7 @@ def run_with_args(args):
url = build_url(hostname, port)
user = get_user(args)
password = get_password(args)
directory = normalize_directory(args.directory[0])
domain = get_domain(args)
directory = normalize_directory(args.directory[0], domain)
for filename in args.fileName:
process_file(filename, directory, url, user, password)
1 change: 1 addition & 0 deletions dp_file_uploader/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def process_args():
argparser.add_argument('-P', '--port', type=int, nargs=1, help='xml-mgmt port, default: 5550')
argparser.add_argument('-u', '--user', type=str, nargs=1, help='username, default: admin')
argparser.add_argument('-p', '--password', type=str, nargs=1, help='password, default: admin')
argparser.add_argument('-d', '--domain', type=str, nargs=1, help='application domain')
argparser.add_argument('-V', '--verbose', action='store_true', help='verbose output')
argparser.add_argument('-v', '--version', action='version', version=get_version())
argparser.add_argument('fileName', type=str, nargs='+', help='file(s) to push')
Expand Down

0 comments on commit 50525a0

Please sign in to comment.