def _setup_getter_vars(): """ Returns logger, and required parameters after setting and checking them. """ ( COLLECTION_PID, MEMBERSHIP_URL, QUEUE_NAME ) = ( unicode( os.environ.get('BELL_UTILS__COLLECTION_PID') ), unicode( os.environ.get('BELL_UTILS__FEDORA_RISEARCH_URL') ), unicode( os.environ.get('BELL_QUEUE_NAME') ) ) assert 'test' in COLLECTION_PID, Exception( 'in delete_dev_collection_pids(); ERROR: problem validating collection-pid' ) assert 'dev' in MEMBERSHIP_URL, Exception( 'in delete_dev_collection_pids(); ERROR: problem validating membership-url' ) pid_finder = PidFinder() logger = bell_logger.setup_logger() return ( pid_finder, COLLECTION_PID, MEMBERSHIP_URL, QUEUE_NAME, logger )
def _setup_delete_vars( data ): """ Returns logger, and required parameters after setting and checking them. """ ( pid, fedora_url, fedora_username, fedora_password ) = ( data['pid'], unicode( os.environ.get('BELL_UTILS__FEDORA_ADMIN_URL') ), unicode( os.environ.get('BELL_UTILS__FEDORA_ADMIN_USERNAME') ), unicode( os.environ.get('BELL_UTILS__FEDORA_ADMIN_PASSWORD') ) ) check_list = [ pid, fedora_url, fedora_username, fedora_password ] for var in check_list: position = check_list.index(var) assert type( var ) == unicode, Exception( 'var at position `%s` is `%s`, not unicode' % (position, var) ) logger = bell_logger.setup_logger() return ( pid, fedora_url, fedora_username, fedora_password, logger )
def run__add_metadata_and_image(data): """ Takes data-dict; example { item_dict: {title: the-title, acc-num: the-acc-num} }. Instantiates Task() instance & calls add_metadata_and_image(). Called by task_manager.determine_next_task(). """ logger = bell_logger.setup_logger() logger.info("in fedora_metadata_and_image_builder.run__add_metadata_and_image(); starting.") print "- in fedora_metadata_and_image_builder.run__add_metadata_and_image(); acc_num is: %s" % data["item_dict"][ "calc_accession_id" ] FEDORA_ADMIN_URL = unicode(os.environ.get("BELL_FMAIB__FEDORA_ADMIN_URL")) FEDORA_ADMIN_USERNAME = unicode(os.environ.get("BELL_FMAIB__FEDORA_ADMIN_USERNAME")) FEDORA_ADMIN_PASSWORD = unicode(os.environ.get("BELL_FMAIB__FEDORA_ADMIN_PASSWORD")) COLLECTION_PID = unicode(os.environ.get("BELL_FMAIB__COLLECTION_PID")) MASTER_IMAGES_DIR_PATH = unicode(os.environ.get("BELL_FMAIB__MASTER_IMAGES_DIR_PATH")) MASTER_IMAGES_DIR_URL = unicode(os.environ.get("BELL_FMAIB__MASTER_IMAGES_DIR_URL")) JP2_IMAGES_DIR_PATH = unicode(os.environ.get("BELL_FMAIB__JP2_IMAGES_DIR_PATH")) JP2_IMAGES_DIR_URL = unicode(os.environ.get("BELL_FMAIB__JP2_IMAGES_DIR_URL")) mods_schema_path = os.path.abspath("./lib/mods-3-4.xsd") task = Task() task._print_settings( FEDORA_ADMIN_URL, FEDORA_ADMIN_USERNAME, FEDORA_ADMIN_PASSWORD, COLLECTION_PID, MASTER_IMAGES_DIR_PATH, MASTER_IMAGES_DIR_URL, JP2_IMAGES_DIR_PATH, JP2_IMAGES_DIR_URL, ) task.add_metadata_and_image( FEDORA_ADMIN_URL, FEDORA_ADMIN_USERNAME, FEDORA_ADMIN_PASSWORD, COLLECTION_PID, MASTER_IMAGES_DIR_PATH, MASTER_IMAGES_DIR_URL, JP2_IMAGES_DIR_PATH, JP2_IMAGES_DIR_URL, data["item_dict"], mods_schema_path, logger, ) print "- in fedora_metadata_and_image_builder.run__add_metadata_and_image(); acc_num is: %s; item ingested" % data[ "item_dict" ]["calc_accession_id"] return
def run__create_fedora_metadata_object( data ): """ Instantiates Task() instance & calls create_fedora_metadata_object(). Called by task_manager.determine_next_task(). """ logger = bell_logger.setup_logger() logger.info( 'in fedora_metadata_only_builder.run__create_fedora_metadata_object(); starting.' ) print '- in fedora_metadata_only_builder.run__create_fedora_metadata_object(); acc_num is: %s' % data['item_dict']['calc_accession_id'] FEDORA_ADMIN_URL=unicode( os.environ.get('BELL_FMOB__FEDORA_ADMIN_URL') ) FEDORA_ADMIN_USERNAME=unicode( os.environ.get('BELL_FMOB__FEDORA_ADMIN_USERNAME') ) FEDORA_ADMIN_PASSWORD=unicode( os.environ.get('BELL_FMOB__FEDORA_ADMIN_PASSWORD') ) COLLECTION_PID=unicode( os.environ.get('BELL_FMOB__COLLECTION_PID') ) mods_schema_path = os.path.abspath( './lib/mods-3-4.xsd' ) task = Task() task.create_fedora_metadata_object( FEDORA_ADMIN_URL, FEDORA_ADMIN_USERNAME, FEDORA_ADMIN_PASSWORD, COLLECTION_PID, data['item_dict'], mods_schema_path, logger ) print '- in fedora_metadata_only_builder.run__create_fedora_metadata_object(); acc_num is: %s; item ingested' % data['item_dict']['calc_accession_id'] return