当前位置: 首页>>代码示例>>Python>>正文


Python EUDATHandleClient.instantiate_with_credentials方法代码示例

本文整理汇总了Python中b2handle.handleclient.EUDATHandleClient.instantiate_with_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python EUDATHandleClient.instantiate_with_credentials方法的具体用法?Python EUDATHandleClient.instantiate_with_credentials怎么用?Python EUDATHandleClient.instantiate_with_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在b2handle.handleclient.EUDATHandleClient的用法示例。


在下文中一共展示了EUDATHandleClient.instantiate_with_credentials方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
def read(args):
    """perform read action"""

    try:
        # load credentials
        credentials = PIDClientCredentials.load_from_JSON(args.credpath)
    except CredentialsFormatError:
        sys.stdout.write('error')
        return
    except HandleSyntaxError:
        sys.stdout.write('error')
        return

    # retrieve and set extra values
    extra_config = {}

    try:
        # setup connection to handle server
        client = EUDATHandleClient.instantiate_with_credentials(
            credentials,
            **extra_config)
    except HandleNotFoundException:
        sys.stdout.write('error')
        return

    if args.key is None:
        result =  read_execution(client, args.handle)
    else:
        result =  read_execution(client, args.handle, args.key)

    sys.stdout.write(result)
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-core,代码行数:33,代码来源:epicclient2.py

示例2: test_instantiate_with_credentials_config_override

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials_config_override(self):
        """Test instantiation of client: No exception if password wrong."""

        # Test variables
        credentials = MagicMock()
        config_from_cred = {}
        valuefoo = 'foo/foo/foo/'
        config_from_cred['REST_API_url_extension'] = valuefoo
        credentials.get_config = MagicMock(return_value=config_from_cred)
        credentials.get_username = MagicMock(return_value=self.user)
        credentials.get_password = MagicMock(return_value=self.randompassword)
        credentials.get_server_URL = MagicMock(return_value=self.url)

        self.assertEqual(credentials.get_config()['REST_API_url_extension'],valuefoo,
            'Config: '+str(credentials.get_config()))

        # Run code to be tested
        # Create instance with credentials
        inst = EUDATHandleClient.instantiate_with_credentials(
            credentials,
            HTTPS_verify=self.https_verify,
            REST_API_url_extension='api/handles')

        # If this raises an exception, it is because /foo/foo from the
        # credentials config was used as path. /foo/foo should be overridden
        # by the standard stuff.

        # Check desired outcomes
        self.assertIsInstance(inst, EUDATHandleClient)
        val = self.inst.get_value_from_handle(self.handle, 'test1')
        self.assertEqual(val, 'val1',
            'Retrieving "test1" should lead to "val1", but it lead to: '+str(val))
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:34,代码来源:handleclient_readaccess_test.py

示例3: create

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
def create(args):
    """perform create action"""

    try:
        # load credentials
        credentials = PIDClientCredentials.load_from_JSON(args.credpath)
    except CredentialsFormatError:
        sys.stdout.write('error')
        return
    except HandleSyntaxError:
        sys.stdout.write('error')
        return

    # retrieve and set extra values
    extra_config = {}

    # create a handle to put. Concate the prefix with a new generated suffix
    prefix = str(credentials.get_prefix())
    uid = uuid.uuid1()
    suffix = str(uid)
    handle = prefix+"/"+suffix

    try:
        # setup connection to handle server
        client = EUDATHandleClient.instantiate_with_credentials(
            credentials,
            **extra_config)
    except HandleNotFoundException:
        sys.stdout.write('error')
        return

    overwrite=False
    result = create_execution(client, handle, args.location, overwrite, args.checksum, args.loc10320, args.extratype)

    sys.stdout.write(result)
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-core,代码行数:37,代码来源:epicclient2.py

示例4: test_instantiate_with_credentials_config

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials_config(self):
        """Test instantiation of client: No exception if password wrong."""

        # Test variables
        credentials = MagicMock()
        config_from_cred = {}
        valuefoo = "foo/foo/foo/"
        config_from_cred["REST_API_url_extension"] = valuefoo
        credentials.get_config = MagicMock(return_value=config_from_cred)
        credentials.get_username = MagicMock(return_value=self.user)
        credentials.get_password = MagicMock(return_value=self.randompassword)
        credentials.get_server_URL = MagicMock(return_value=self.url)
        credentials.get_handleowner = MagicMock(return_value=None)
        credentials.get_path_to_private_key = MagicMock(return_value=None)
        credentials.get_path_to_file_certificate_only = MagicMock(return_value=None)
        credentials.get_path_to_file_certificate_and_key = MagicMock(return_value=None)

        self.assertEqual(
            credentials.get_config()["REST_API_url_extension"], valuefoo, "Config: " + str(credentials.get_config())
        )

        # Run code to be tested
        # Create instance with credentials
        with self.assertRaises(GenericHandleError):
            inst = EUDATHandleClient.instantiate_with_credentials(credentials, HTTPS_verify=self.https_verify)
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:27,代码来源:handleclient_readaccess_test.py

示例5: test_instantiate_with_credentials_inexistentuser

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials_inexistentuser(self):
        """Test instantiation of client: Exception if username does not exist."""

        # Test variables
        testusername_inexistent = "100:" + self.inexistent_handle
        credentials = b2handle.clientcredentials.PIDClientCredentials(
            handle_server_url=self.url, username=testusername_inexistent, password=self.randompassword
        )

        # Run code to be tested + check exception:
        # Create instance with credentials
        with self.assertRaises(HandleNotFoundException):
            inst = EUDATHandleClient.instantiate_with_credentials(credentials, HTTPS_verify=self.https_verify)
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:15,代码来源:handleclient_readaccess_test.py

示例6: test_instantiate_with_credentials

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials(self):
        """Test instantiation of client: No exception if password wrong."""

        # Test variables
        credentials = b2handle.clientcredentials.PIDClientCredentials(
            handle_server_url=self.url, username=self.user, password=self.randompassword
        )

        # Run code to be tested
        # Create instance with credentials
        inst = EUDATHandleClient.instantiate_with_credentials(credentials, HTTPS_verify=self.https_verify)

        # Check desired outcomes
        self.assertIsInstance(inst, EUDATHandleClient)
开发者ID:NicolasLiampotis,项目名称:B2HANDLE,代码行数:16,代码来源:handleclient_readaccess_test.py

示例7: test_instantiate_with_credentials_config

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials_config(self, checkpatch):
        """Test instantiation of client: No exception if password wrong."""

        # Define the replacement for the patched method:
        mock_response = MockResponse(success=True)
        checkpatch.return_value = mock_response

        # Test variables
        credentials = MockCredentials(restapi='foobar')

        self.assertEqual(credentials.get_config()['REST_API_url_extension'],'foobar',
            'Config: '+str(credentials.get_config()))

        # Run code to be tested
        # Create instance with credentials
        inst = EUDATHandleClient.instantiate_with_credentials(credentials)
        self.assertIsInstance(inst, EUDATHandleClient)
开发者ID:EUDAT-B2SAFE,项目名称:B2HANDLE,代码行数:19,代码来源:handleclient_2_read_patched_unit_test.py

示例8: test_instantiate_with_credentials_inexistentuser

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials_inexistentuser(self, getpatch):
        """Test instantiation of client: Exception if username does not exist."""

        # Define the replacement for the patched method:
        mock_response = MockResponse(notfound=True)
        getpatch.return_value = mock_response

        # Test variables
        testusername_inexistent = "100:john/doe"
        credentials = b2handle.clientcredentials.PIDClientCredentials(
            "some/url", testusername_inexistent, "some_password"
        )

        # Run code to be tested + check exception:
        # Create instance with credentials
        with self.assertRaises(HandleNotFoundException):
            inst = EUDATHandleClient.instantiate_with_credentials(credentials)
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:19,代码来源:handleclient_readaccess_patched_test.py

示例9: test_instantiate_with_credentials

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials(self, getpatch):
        """Test instantiation of client: No exception if password wrong."""

        # Define the replacement for the patched method:
        mock_response = MockResponse(success=True)
        getpatch.return_value = mock_response

        # Test variables
        credentials = b2handle.clientcredentials.PIDClientCredentials(
            "some/url", "100:my/testhandle", "some_password_123"
        )

        # Run code to be tested
        # Create instance with credentials
        inst = EUDATHandleClient.instantiate_with_credentials(credentials)

        # Check desired outcomes
        self.assertIsInstance(inst, EUDATHandleClient)
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:20,代码来源:handleclient_readaccess_patched_test.py

示例10: main

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
def main():
    # parse command line options and arguments:
    modes=['x','xmlfiles','j','jsonfiles','c','ckandatasets','p','pids','x-p', 'x-j', 'j-c','j-p']
    p = options_parser(modes)
    options,arguments = p.parse_args()
    # check option 'mode' and generate process list:
    (mode, pstat) = pstat_init(p,modes,options.mode,options.source,options.host)

    # check for quiet mode
    if (options.quiet):
      qmsg='would be'
      mainmode='check'
    else:
      qmsg='is'   
      mainmode='deletion'

    if options.host :
       print "\tCKAN HOST:\t%s" % (options.host)
    if options.handle_check :
       print "\tCREDENTIAL:\t%s" % (options.handle_check)
    print '='*90

    # make jobdir
    now = time.strftime("%Y-%m-%d %H:%M:%S")
    jid = os.getpid()
    print "\tStart of processing:\t%s" % (now)

    global logger
    OUT = Output(pstat,now,jid,options)
    ##HEW-D logger = log.getLogger()
    ## logger
    logger = OUT.setup_custom_logger('root',options.verbose)

    # create credentials if required
    if (options.handle_check):
       try:
           cred = PIDClientCredentials.load_from_JSON('credentials_11098')
       except Exception, err:
           logger.critical("[CRITICAL] %s Could not create credentials from credstore %s" % (err,options.handle_check))
           p.print_help()
           sys.exit(-1)
       else:
           logger.debug("Create EUDATHandleClient instance")
           HandleClient = EUDATHandleClient.instantiate_with_credentials(cred,HTTPS_verify=True)
开发者ID:EUDAT-B2FIND,项目名称:md-ingestion,代码行数:46,代码来源:cleaner.py

示例11: test_instantiate_with_credentials_config_override

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials_config_override(self, getpatch, checkpatch):
        """Test instantiation of client: We pass a config value in the credentials
        and also as an arg in the instantiation. We want the latter to override the
        first one.
        """

        # Define the replacement for the patched method:
        # We pretend the username exists!
        mock_response = MockResponse(success=True)
        checkpatch.return_value = mock_response

        # Define the replacement for the patched GET:
        cont = {"responseCode":1,"handle":"my/testhandle","values":[{"index":111,"type":"TEST1","data":{"format":"string","value":"val1"},"ttl":86400,"timestamp":"2015-09-30T15:08:49Z"},{"index":2222,"type":"TEST2","data":{"format":"string","value":"val2"},"ttl":86400,"timestamp":"2015-09-30T15:08:49Z"},{"index":333,"type":"TEST3","data":{"format":"string","value":"val3"},"ttl":86400,"timestamp":"2015-09-30T15:08:49Z"},{"index":4,"type":"TEST4","data":{"format":"string","value":"val4"},"ttl":86400,"timestamp":"2015-09-30T15:08:49Z"}]}
        mock_response = MockResponse(success=True, content=json.dumps(cont))
        getpatch.return_value = mock_response

        # Test variables
        # Passing mock credentials, give them the value "foobar", which
        # should be overridden!
        credentials = MockCredentials(restapi='foobar')
        self.assertEqual(credentials.get_config()['REST_API_url_extension'],'foobar',
            'Config: '+str(credentials.get_config()))

        # Run code to be tested
        # Create instance with credentials. It gets the "REST_API_url_extention"
        # from both the credentials and as a param.
        inst = EUDATHandleClient.instantiate_with_credentials(
            credentials,
            REST_API_url_extension='bar/bar/bar')
        self.assertIsInstance(inst, EUDATHandleClient)

        # How to know now which one was used?
        # Call a read and check its url! Did it get foobar or barbarbar appended?
        inst.get_value_from_handle('my/testhandle', 'key')
        positional_args_passed = getpatch.call_args_list[len(getpatch.call_args_list)-1][0]
        passed_url = positional_args_passed[0]

        # Compare with expected URL:
        self.assertIn('bar/bar/bar',passed_url,
            'bar/bar/bar is not specified in the URL '+passed_url)
开发者ID:EUDAT-B2SAFE,项目名称:B2HANDLE,代码行数:42,代码来源:handleclient_2_read_patched_unit_test.py

示例12: test_instantiate_with_credentials_config

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
    def test_instantiate_with_credentials_config(self):
        """Test instantiation of client: No exception if password wrong."""

        # Test variables
        credentials = MagicMock()
        config_from_cred = {}
        valuefoo = 'foo/foo/foo/'
        config_from_cred['REST_API_url_extension'] = valuefoo
        credentials.get_config = MagicMock(return_value=config_from_cred)
        credentials.get_username = MagicMock(return_value=self.user)
        credentials.get_password = MagicMock(return_value=self.randompassword)
        credentials.get_server_URL = MagicMock(return_value=self.url)

        self.assertEqual(credentials.get_config()['REST_API_url_extension'],valuefoo,
            'Config: '+str(credentials.get_config()))

        # Run code to be tested
        # Create instance with credentials
        with self.assertRaises(GenericHandleError):
            inst = EUDATHandleClient.instantiate_with_credentials(
                credentials,
                HTTPS_verify=self.https_verify)
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:24,代码来源:handleclient_readaccess_test.py

示例13: relation

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
def relation(args):
    """perform the relation action"""

    try:
        # load credentials
        credentials = PIDClientCredentials.load_from_JSON(args.credpath)
    except CredentialsFormatError:
        sys.stdout.write('error')
        return
    except HandleSyntaxError:
        sys.stdout.write('error')
        return

    # retrieve and set extra values
    extra_config = {}

    try:
        # setup connection to handle server
        client = EUDATHandleClient.instantiate_with_credentials(
            credentials,
            **extra_config)
    except HandleNotFoundException:
        sys.stdout.write('error')
        return

    result = 'None'

    # add relation to 10320/LOC
    try:
        client.add_additional_URL(args.ppid, args.cpid)
    except HandleAuthenticationError:
        result = 'error'
    except HandleNotFoundException:
        result = 'False'
    except HandleSyntaxError:
        result = 'error'

    sys.stdout.write(result)
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-core,代码行数:40,代码来源:epicclient2.py

示例14: process

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
def process(options,pstat,OUT):
    ## process (options,pstat,OUT) - function
    # Starts processing as specified in pstat['tbd'] and 
    #  according the request list given bey the options
    #
    # Parameters:
    # -----------
    # 1. options (OptionsParser object)
    # 2. pstat   (process status dict)  
    #
    
    # set list of request lsits for single or multi mode:
    mode = None
    procOptions=['community','source','verb','mdprefix','mdsubset','target_mdschema']
    if(options.source):
        mode = 'single'
        mandParams=['community','verb','mdprefix'] # mandatory processing params
        for param in mandParams :
            if not getattr(options,param) :
                logger.critical("Processing parameter %s is required in single mode" % param)
                sys.exit(-1)
        reqlist=[[
                options.community,
                options.source,
                options.verb,
                options.mdprefix,
                options.mdsubset,
                options.ckan_check,
                options.handle_check,
                options.target_mdschema
            ]]
    elif(options.list):
        mode = 'multi'
        logger.debug(' |- Joblist:  \t%s' % options.list)
        reqlist=parse_list_file(options)

    logger.debug(' |- Requestlist:  \t%s' % reqlist)

    ## check job request (processing) options
    logger.debug('|- Command line options')
    for opt in procOptions :
        if hasattr(options,opt) : logger.debug(' |- %s:\t%s' % (opt.upper(),getattr(options,opt)))
    
    ## GENERATION mode:    
    if (pstat['status']['g'] == 'tbd'):
        logger.info('\n|- Generation started : %s' % time.strftime("%Y-%m-%d %H:%M:%S"))
        GEN = Generator(OUT,pstat,options.outdir)
        process_generate(GEN,reqlist)

    ## HARVESTING mode:    
    if (pstat['status']['h'] == 'tbd'):
        logger.info('\n|- Harvesting started : %s' % time.strftime("%Y-%m-%d %H:%M:%S"))
        HV = Harvester(OUT,pstat,options.outdir,options.fromdate)
        process_harvest(HV,reqlist)

    ## MAPPINING - Mode:  
    if (pstat['status']['m'] == 'tbd'):
        logger.info('\n|- Mapping started : %s' % time.strftime("%Y-%m-%d %H:%M:%S"))
        MP = Mapper(OUT,options.outdir,options.fromdate)
        process_map(MP,reqlist)

    ## VALIDATING - Mode:
    if (pstat['status']['v'] == 'tbd'):
        logger.info(' |- Validating started : %s' % time.strftime("%Y-%m-%d %H:%M:%S"))
        VD = Validator(OUT,options.outdir,options.fromdate)
        process_validate(VD,reqlist)

    ## CONVERTING - Mode:  
    if (pstat['status']['c'] == 'tbd'):
        logger.info('\n|- Converting started : %s' % time.strftime("%Y-%m-%d %H:%M:%S"))
        CV = Converter(OUT,options.outdir,options.fromdate)
        process_convert(CV, reqlist)

    ## UPLOADING - Mode:  
    if (pstat['status']['u'] == 'tbd'):
        logger.info('\n|- Uploading started : %s' % time.strftime("%Y-%m-%d %H:%M:%S"))
        # create CKAN object                       
        CKAN = CKAN_CLIENT(options.iphost,options.auth)
        # create credentials and handle client if required
        if (options.handle_check):
          try:
              cred = PIDClientCredentials.load_from_JSON('credentials_11098')
          except Exception as err:
              logger.critical("%s : Could not create credentials from credstore %s" % (err,options.handle_check))
              ##p.print_help()
              sys.exit(-1)
          else:
              logger.debug("Create EUDATHandleClient instance")
              HandleClient = EUDATHandleClient.instantiate_with_credentials(cred)
        else:
            cred=None
            HandleClient=None

        UP = Uploader(CKAN,options.ckan_check,HandleClient,cred,OUT,options.outdir,options.fromdate,options.iphost)
        logger.info(' |- Host:  \t%s' % CKAN.ip_host )
        process_upload(UP, reqlist)

    ## DELETING - Mode:
    if (pstat['status']['d'] == 'tbd'):
        # start the process deleting:
#.........这里部分代码省略.........
开发者ID:EUDAT-B2FIND,项目名称:md-ingestion,代码行数:103,代码来源:manager.py

示例15: bulk

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_with_credentials [as 别名]
def bulk(args):
    """perform the bulk actions"""

    try:
        # open input file
        bulk_input_file = open(args.input, "r") 
    except:
        sys.stdout.write('error opening: '+args.input)
        return

    try:
        # open result file
        bulk_result_file = open(args.result, "w") 
    except:
        sys.stdout.write('error opening: '+args.result)
        return

    try:
        # load credentials
        credentials = PIDClientCredentials.load_from_JSON(args.credpath)
    except CredentialsFormatError:
        sys.stdout.write('error')
        return
    except HandleSyntaxError:
        sys.stdout.write('error')
        return

    # retrieve and set extra values
    extra_config = {}

    try:
        # setup connection to handle server
        client = EUDATHandleClient.instantiate_with_credentials(
            credentials,
            **extra_config)
    except HandleNotFoundException:
        sys.stdout.write('error')
        return

    for line in bulk_input_file:
        bulk_array = line.split()

        if bulk_array[0] == 'SEARCH':
            # search key value  # search handle which matches criteria

            search_key = bulk_array[1] 
            search_value = bulk_array[2]
            result = search_execution(client, search_key, search_value)
            bulk_result_file.write('search handle key: '+search_key+' value: '+search_value+' result: '+result+'\n')

        if bulk_array[0] == 'READ':
            # READ handle       # read whole handle
            # READ handle key   # read key/value pair from handle

            read_handle = bulk_array[1] 
            if len(bulk_array) >= 3:
                read_key = bulk_array[2]
                result = read_execution(client, read_handle, read_key)
                bulk_result_file.write('read handle: '+read_handle+' key: '+read_key+' result: '+result+'\n')
            else: 
                result = read_execution(client, read_handle)
                bulk_result_file.write('read handle: '+read_handle+' result: '+result+'\n')

        if bulk_array[0] == 'CREATE':
            # CREATE prefix/uuid URL                       # create handle, use uuid for suffix
            # CREATE prefix/suffix URL                     # create handle, use suffix for handle, no check before if handle exists
            # CREATE prefix/uuid URL CHECKSUM              # create handle, use uuid for suffix, add checksum
            # CREATE prefix/uuid URL CHECKSUM 10320/LOC    # create handle, use uuid for suffix, add checksum, add 10320/LOC
            # CREATE prefix/uuid URL CHECKSUM 10320/LOC EXTRATYPE # create handle, use uuid for suffix, add checksum, add 10320/LOC, add extratypes

            overwrite=False
            checksum = None
            loc10320 = None
            extratype = None

            # create a handle to put. 
            prefix = str(credentials.get_prefix())
            create_prefix = bulk_array[1].split("/")[0]
            create_suffix = bulk_array[1].split("/")[1] 
            if create_suffix == 'uuid':
                uid = uuid.uuid1()
                suffix = str(uid)
                handle = prefix+"/"+suffix
            else:
                handle = prefix+"/"+create_suffix
                overwrite=True

            if len(bulk_array) == 3:
                result = create_execution(client, handle, bulk_array[2], overwrite)
            else:
                if len(bulk_array) >= 4 and bulk_array[3].lower() != 'none':
                    checksum = bulk_array[3]
                if len(bulk_array) >= 5 and bulk_array[4].lower() != 'none':
                    loc10320 = bulk_array[4]
                if len(bulk_array) >= 6 and bulk_array[5].lower() != 'none':
                    extratype = bulk_array[5]
                result = create_execution(client, handle, bulk_array[2], overwrite, checksum, loc10320, extratype)

            bulk_result_file.write('create handle: '+bulk_array[1]+' result: '+result+'\n')

#.........这里部分代码省略.........
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-core,代码行数:103,代码来源:epicclient2.py


注:本文中的b2handle.handleclient.EUDATHandleClient.instantiate_with_credentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。