Last active
May 30, 2018 14:01
-
-
Save ross-spencer/9af126dfbe514ef029dd93b39a34558f to your computer and use it in GitHub Desktop.
Microservice_Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. | |
INSERT INTO `MCP`.`StandardTasksConfigs` (`pk`, 'execute', `arguments`, `requiresOutputLock`, `lastModified`) | |
VALUES ('7c17bd71-9683-4598-8662-89ac7e0797b6', 'dataverse_v0.0' ,'\"%SIPDirectory%\"', '0', '2018-10-02 00:25:01.000000'); | |
2. | |
INSERT INTO `MCP`.`TasksConfigs` (`pk`, `taskTypePKReference`, `description`, `lastModified`, `taskType`) | |
VALUES ('1a6b8183-d988-47cb-af23-48cf5dd71cb9', '7c17bd71-9683-4598-8662-89ac7e0797b6', 'Convert Dataverse Structure', '2012-10-02 00:25:11.000000', '36b2e239-4a57-4aa5-8ebc-7a29139baca6'); | |
3. | |
INSERT INTO `MCP`.`MicroServiceChainLinks` (`pk`, `microserviceGroup`, `reloadFileList`, `defaultExitMessage`, `lastModified`, `currentTask`, `defaultNextChainLink`) | |
VALUES ('3e02f395-a030-47a5-b9fb-a32eb46144bc', 'Verify transfer compliance', '1', '4', '2018-10-02 00:25:06.000000', '1a6b8183-d988-47cb-af23-48cf5dd71cb9', '61c316a6-0a50-4f65-8767-1f44b1eeb6dd'); | |
4. | |
INSERT INTO `MCP`.`MicroServiceChainLinksExitCodes` (`pk`, `exitCode`, `exitMessage`, `lastModified`, `microServiceChainLink`, `nextMicroServiceChainLink`) | |
VALUES ('b4760b68-d9d9-4e63-ac50-85caa09eeaaf', '0', '2', '2018-05-08 13:34:24.947332', '3e02f395-a030-47a5-b9fb-a32eb46144bc', '7d0616b2-afed-41a6-819a-495032e86291'); | |
5. | |
UPDATE `MCP`.`MicroServiceChainLinksExitCodes` SET `nextMicroServiceChainLink`='3e02f395-a030-47a5-b9fb-a32eb46144bc' | |
WHERE `pk`='9cb81a5c-a7a1-43a8-8eb6-3e999923e03c'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
# This file is part of Archivematica. | |
# | |
# Copyright 2010-2013 Artefactual Systems Inc. <http://artefactual.com> | |
# | |
# Archivematica is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# Archivematica is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with Archivematica. If not, see <http://www.gnu.org/licenses/>. | |
from __future__ import print_function | |
import argparse | |
import hashlib | |
import os | |
import sys | |
from custom_handlers import get_script_logger | |
logger = get_script_logger("archivematica.mcp.client.dataverse") | |
def md5sum(filename, blocksize=65536): | |
hash = hashlib.md5() | |
with open(filename, "rb") as f: | |
for block in iter(lambda: f.read(blocksize), b""): | |
hash.update(block) | |
return hash.hexdigest() | |
def map_dataverse(sip_dir): | |
flist = [] | |
for root, subdirs, files in os.walk(sip_dir): | |
if files: | |
for f in files: | |
h = md5sum(os.path.join(root, f)) | |
logger.info(h) | |
flist.append(h) | |
if flist: | |
print("{0} duplicates in the transfer " | |
"directory.".format(len(flist) - len(set(flist)))) | |
print("This is stdout") | |
logger.error("This is stderr") | |
return 0 | |
def main(sip_dir): | |
return map_dataverse(sip_dir) | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('sip_dir', | |
type=str, | |
help='The Dataverse SIP folder to process.') | |
args = parser.parse_args() | |
if args.sip_dir == 'None': | |
sys.exit(0) | |
logger.info('dataverse called with args: %s', vars(args)) | |
sys.exit(main(**vars(args))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment