Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new variable to process delete #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions transfers/examples/example-transfer-script.sh
Original file line number Diff line number Diff line change
@@ -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'
10 changes: 8 additions & 2 deletions transfers/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -623,6 +627,7 @@ def main(
ss_api_key,
unit_uuid,
unit_type,
transfer_delete_path,
hide_on_complete,
delete_on_complete,
)
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions transfers/transferargs.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading