diff --git a/README.md b/README.md index 98ca8ce..5add4d2 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ work. The full set of parameters that can be changed are: * `--hide`: If set, hides the Transfer and SIP once completed. * `--delete-on-complete`: If set, delete transfer source files from watched directory once completed. +* `--transfer_delete_path`: Text path watched directory if "--delete-on-complete" is set, example /mnt/transferSource/. * `-c FILE, --config-file FILE`: config file containing file paths for log/database/PID files. Default: log/database/PID files stored in the same directory as the script (not recommended for production) diff --git a/transfers/examples/example-transfer-script.sh b/transfers/examples/example-transfer-script.sh new file mode 100755 index 0000000..0c0f636 --- /dev/null +++ b/transfers/examples/example-transfer-script.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# transfer script example +# /etc/archivematica/automation-tools/transfer-script.sh +cd /usr/lib/archivematica/automation-tools/ +/usr/share/python/automation-tools/venv38/bin/python -m transfers.transfer \ + --am-url http://archmatica:80 \ + --ss-url http://archmatica:8000 \ + --user xxxxx \ + --api-key xxxxxx \ + --ss-user support \ + --ss-api-key xxxxxxx \ + --transfer-source xxxxxxxx \ + --delete-on-complete \ + --hide \ + --transfer_delete_path '/mnt/transferSource/BatchTransfer/' \ + --config-file transfers.conf \ + --transfer-type 'unzipped bag' diff --git a/transfers/transfer.py b/transfers/transfer.py index 9faff2f..9616a45 100755 --- a/transfers/transfer.py +++ b/transfers/transfer.py @@ -82,6 +82,7 @@ def get_status( ss_api_key, unit_uuid, unit_type, + transfer_delete_path, hide_on_complete=False, delete_on_complete=False, ): @@ -155,7 +156,9 @@ def get_status( unit.uuid, ) try: - shutil.rmtree(unit.path) + # Use the transfer_delete_path provided by user ex: /transferSource/ + deletePath = transfer_delete_path + unit.path.decode("UTF-8") + shutil.rmtree(deletePath) LOGGER.info("Source files deleted for SIP %s deleted", unit.uuid) except OSError as e: LOGGER.warning( @@ -330,7 +333,7 @@ def get_next_transfer( LOGGER.debug("New transfer candidates: %s", entries) LOGGER.info("Unprocessed entries to choose from: %s", len(entries)) # Sort, take the first - entries = sorted(entries) + entries = sorted(list(entries)) if not entries: LOGGER.info("All potential transfers in %s have been created.", path_prefix) return None @@ -563,6 +566,7 @@ def main( ss_url, transfer_type, see_files, + transfer_delete_path, hide_on_complete=False, delete_on_complete=False, config_file=None, @@ -623,6 +627,7 @@ def main( ss_api_key, unit_uuid, unit_type, + transfer_delete_path, hide_on_complete, delete_on_complete, ) @@ -701,6 +706,7 @@ def main( ss_url=args.ss_url, transfer_type=args.transfer_type, see_files=args.files, + transfer_delete_path=args.transfer_delete_path, hide_on_complete=args.hide, delete_on_complete=args.delete_on_complete, config_file=args.config_file, diff --git a/transfers/transferargs.py b/transfers/transferargs.py old mode 100644 new mode 100755 index 168b52b..af5029d --- a/transfers/transferargs.py +++ b/transfers/transferargs.py @@ -105,6 +105,14 @@ def get_parser(doc): help="If set, delete transfer source files after " "ingest successfully completes.", ) + + parser.add_argument( + "--transfer_delete_path", + metavar="PATH", + help="Plain text path to Transfer Source", + type=str, + default=None, + ) parser.add_argument( "-c", "--config-file",