Exemple #1
0
def get_as_system_client():
    config = models.DashboardSetting.objects.get_dict(
        'upload-archivesspace_v0.0')

    return ArchivesSpaceClient(host=config['host'],
                               port=config['port'],
                               user=config['user'],
                               passwd=config['passwd'],
                               repository=config['repository'])
Exemple #2
0
def get_as_system_client():
    repl_dict = models.MicroServiceChoiceReplacementDic.objects.get(description='ArchivesSpace Config')
    config = ast.literal_eval(repl_dict.replacementdic)

    return ArchivesSpaceClient(
        host=config['%host%'],
        port=config['%port%'],
        user=config['%user%'],
        passwd=config['%passwd%'],
        repository=config['%repository%']
    )
Exemple #3
0
def get_as_system_client():
    config = models.DashboardSetting.objects.get_dict(
        'upload-archivesspace_v0.0')

    if not config['host']:
        raise ArchivesSpaceError("ArchivesSpace host string has not been set")

    return ArchivesSpaceClient(host=config['host'],
                               port=config['port'],
                               user=config['user'],
                               passwd=config['passwd'],
                               repository=config['repository'])
Exemple #4
0
def call(jobs):
    RESTRICTIONS_CHOICES = ["yes", "no", "premis"]
    EAD_SHOW_CHOICES = ["embed", "new", "none", "other", "replace"]
    EAD_ACTUATE_CHOICES = ["none", "onLoad", "other", "onRequest"]
    INHERIT_NOTES_CHOICES = ["yes", "y", "true", "1"]

    parser = get_parser(RESTRICTIONS_CHOICES, EAD_ACTUATE_CHOICES, EAD_SHOW_CHOICES)

    with transaction.atomic():
        for job in jobs:
            with job.JobContext(logger=logger):
                args = parser.parse_args(job.args[1:])

                args.inherit_notes = args.inherit_notes.lower() in INHERIT_NOTES_CHOICES

                client = ArchivesSpaceClient(
                    host=args.base_url, user=args.user, passwd=args.passwd
                )

                try:
                    files = get_files_from_dip(args.dip_location)
                except ValueError:
                    job.set_status(2)
                    continue
                except Exception:
                    job.set_status(3)
                    continue
                if upload_to_archivesspace(
                    files,
                    client,
                    args.xlink_show,
                    args.xlink_actuate,
                    args.object_type,
                    args.use_statement,
                    args.uri_prefix,
                    args.dip_uuid,
                    args.access_conditions,
                    args.use_conditions,
                    args.restrictions,
                    args.dip_location,
                    args.inherit_notes,
                ):
                    job.set_status(0)
                else:
                    job.set_status(2)
Exemple #5
0
def get_as_system_client():
    config = models.DashboardSetting.objects.get_dict(
        'upload-archivesspace_v0.0')

    config_err = ArchivesSpaceError(
        "ArchivesSpace has not been configured properly"
        " - base URL is missing")
    try:
        base_url = config['base_url']
    except KeyError:
        raise config_err
    if not base_url:
        raise config_err

    return ArchivesSpaceClient(host=base_url,
                               user=config['user'],
                               passwd=config['passwd'],
                               repository=config['repository'])
Exemple #6
0
def call(jobs):
    RESTRICTIONS_CHOICES = ['yes', 'no', 'premis']
    EAD_SHOW_CHOICES = ['embed', 'new', 'none', 'other', 'replace']
    EAD_ACTUATE_CHOICES = ['none', 'onLoad', 'other', 'onRequest']
    INHERIT_NOTES_CHOICES = ['yes', 'y', 'true', '1']

    parser = argparse.ArgumentParser(description='A program to take digital objects from a DIP and upload them to an ArchivesSpace db')
    parser.add_argument('--base-url', default='http://localhost:8089', dest='base_url', metavar='base_url', help='Hostname of ArchivesSpace')
    parser.add_argument('--user', dest='user', help='Administrative user')
    parser.add_argument('--passwd', dest='passwd', help='Administrative user password')
    parser.add_argument('--dip_location', help='DIP location')
    parser.add_argument('--dip_name', help='DIP name')
    parser.add_argument('--dip_uuid', help='DIP UUID')
    parser.add_argument('--restrictions', help='Restrictions apply', default='premis', choices=RESTRICTIONS_CHOICES)
    parser.add_argument('--object_type', help='object type', default='')
    parser.add_argument('--xlink_actuate', help='XLink actuate', default='onRequest', choices=EAD_ACTUATE_CHOICES)
    parser.add_argument('--xlink_show', help='XLink show', default='new', choices=EAD_SHOW_CHOICES)
    parser.add_argument('--use_statement', help='USE statement')
    parser.add_argument('--uri_prefix', help='URI prefix')
    parser.add_argument('--access_conditions', help='Conditions governing access', default='')
    parser.add_argument('--use_conditions', help='Conditions governing use', default='')
    parser.add_argument('--inherit_notes', help='Inherit digital object notes from the parent component', default='no', type=str)
    parser.add_argument('--version', action='version', version='%(prog)s 0.1.0')

    with transaction.atomic():
        for job in jobs:
            with job.JobContext(logger=logger):
                args = parser.parse_args(job.args[1:])

                args.inherit_notes = args.inherit_notes.lower() in INHERIT_NOTES_CHOICES

                client = ArchivesSpaceClient(host=args.base_url, user=args.user, passwd=args.passwd)

                try:
                    files = get_files_from_dip(args.dip_location, args.dip_name, args.dip_uuid)
                except ValueError:
                    job.set_status(2)
                    continue
                except Exception:
                    job.set_status(3)
                    continue

                upload_to_archivesspace(files, client, args.xlink_show, args.xlink_actuate, args.object_type, args.use_statement, args.uri_prefix, args.dip_uuid, args.access_conditions, args.use_conditions, args.restrictions, args.dip_location, args.inherit_notes)
Exemple #7
0
def call(jobs):
    RESTRICTIONS_CHOICES = ["yes", "no", "premis"]
    EAD_SHOW_CHOICES = ["embed", "new", "none", "other", "replace"]
    EAD_ACTUATE_CHOICES = ["none", "onLoad", "other", "onRequest"]
    INHERIT_NOTES_CHOICES = ["yes", "y", "true", "1"]

    parser = argparse.ArgumentParser(
        description=
        "A program to take digital objects from a DIP and upload them to an ArchivesSpace db"
    )
    parser.add_argument(
        "--base-url",
        default="http://localhost:8089",
        dest="base_url",
        metavar="base_url",
        help="Hostname of ArchivesSpace",
    )
    parser.add_argument("--user", dest="user", help="Administrative user")
    parser.add_argument("--passwd",
                        dest="passwd",
                        help="Administrative user password")
    parser.add_argument("--dip_location", help="DIP location")
    parser.add_argument("--dip_name", help="DIP name")
    parser.add_argument("--dip_uuid", help="DIP UUID")
    parser.add_argument(
        "--restrictions",
        help="Restrictions apply",
        default="premis",
        choices=RESTRICTIONS_CHOICES,
    )
    parser.add_argument("--object_type", help="object type", default="")
    parser.add_argument(
        "--xlink_actuate",
        help="XLink actuate",
        default="onRequest",
        choices=EAD_ACTUATE_CHOICES,
    )
    parser.add_argument("--xlink_show",
                        help="XLink show",
                        default="new",
                        choices=EAD_SHOW_CHOICES)
    parser.add_argument("--use_statement", help="USE statement")
    parser.add_argument("--uri_prefix", help="URI prefix")
    parser.add_argument("--access_conditions",
                        help="Conditions governing access",
                        default="")
    parser.add_argument("--use_conditions",
                        help="Conditions governing use",
                        default="")
    parser.add_argument(
        "--inherit_notes",
        help="Inherit digital object notes from the parent component",
        default="no",
        type=str,
    )
    parser.add_argument("--version",
                        action="version",
                        version="%(prog)s 0.1.0")

    with transaction.atomic():
        for job in jobs:
            with job.JobContext(logger=logger):
                args = parser.parse_args(job.args[1:])

                args.inherit_notes = args.inherit_notes.lower(
                ) in INHERIT_NOTES_CHOICES

                client = ArchivesSpaceClient(host=args.base_url,
                                             user=args.user,
                                             passwd=args.passwd)

                try:
                    files = get_files_from_dip(args.dip_location,
                                               args.dip_name, args.dip_uuid)
                except ValueError:
                    job.set_status(2)
                    continue
                except Exception:
                    job.set_status(3)
                    continue

                upload_to_archivesspace(
                    files,
                    client,
                    args.xlink_show,
                    args.xlink_actuate,
                    args.object_type,
                    args.use_statement,
                    args.uri_prefix,
                    args.dip_uuid,
                    args.access_conditions,
                    args.use_conditions,
                    args.restrictions,
                    args.dip_location,
                    args.inherit_notes,
                )
    parser.add_argument('--uri_prefix', help='URI prefix')
    parser.add_argument('--access_conditions',
                        help='Conditions governing access',
                        default='')
    parser.add_argument('--use_conditions',
                        help='Conditions governing use',
                        default='')
    parser.add_argument(
        '--inherit_notes',
        help='Inherit digital object notes from the parent component',
        default='no',
        type=str)
    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s 0.1.0')
    args = parser.parse_args()

    args.inherit_notes = args.inherit_notes.lower() in INHERIT_NOTES_CHOICES

    client = ArchivesSpaceClient(host=args.host,
                                 port=args.port,
                                 user=args.user,
                                 passwd=args.passwd)
    files = get_files_from_dip(args.dip_location, args.dip_name, args.dip_uuid)
    upload_to_archivesspace(files, client, args.xlink_show, args.xlink_actuate,
                            args.object_type, args.use_statement,
                            args.uri_prefix, args.dip_uuid,
                            args.access_conditions, args.use_conditions,
                            args.restrictions, args.dip_location,
                            args.inherit_notes)