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


Python GirderClient.authenticate方法代码示例

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


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

示例1: main

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
def main(config):
    client = GirderClient(apiUrl=config.girder_api_url)
    client.authenticate(config.girder_user,
                        config.girder_password)

    # Load any parameters
    params = {}
    if config.taskflow_start_params is not None:
        with open(config.taskflow_start_params) as fp:
            params = json.load(fp)

    print params

    try:
        print ('Running %s taskflow ...' % config.taskflow_start_params)
        taskflow_id = create_taskflow(
            client, config.taskflow_class)

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url, data=json.dumps(params))

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

    except HttpError as ex:
        print( ex.responseText)
开发者ID:Kitware,项目名称:HPCCloud,代码行数:29,代码来源:runner.py

示例2: import_calc

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
def import_calc(config):
    try:
        target_port = None
        if config.port:
            target_port = config.port
        target_scheme = None
        if config.scheme:
            target_scheme = config.scheme
        target_apiroot = None
        if config.apiroot:
            target_apiroot = config.apiroot

        client = GirderClient(host=config.host, port=target_port,
                              scheme=target_scheme, apiRoot=target_apiroot)
        client.authenticate(apiKey=config.apiKey)

        me = client.get('/user/me')
        if not me:
            print('Error: Girder token invalid, please verify')
            return

        folderParams = {
            'parentId': me['_id'],
            'parentType': 'user',
            'name': 'Private'
        }

        # Get the private folder id first
        folder = next(client.listResource('folder', folderParams))
        folder = next(client.listFolder(me['_id'], 'user', 'Private'))

        for file_name in config.datafile:
            print ('\nUploading ' + file_name)
            file_id = {}
            with open(file_name, 'r') as fp:
                fileNameBase = os.path.basename(file_name)
                size = os.path.getsize(file_name)
                file_id = client.uploadFile(folder['_id'], fp, fileNameBase,
                                            size, 'folder')

            body = {
                'fileId': file_id['_id']
            }

            if config.public:
                body['public'] = True


            mol = client.sendRestRequest('POST', 'molecules', data=json.dumps(body))

            if mol and '_id' in mol:
                config.moleculeId = mol['_id']
                print('Molecule ID: ' + mol['_id'])
            else:
                print(mol)

    except HttpError as error:
        print(error.responseText, file=sys.stderr)
开发者ID:OpenChemistry,项目名称:mongochemserver,代码行数:60,代码来源:bulk_import.py

示例3: _importAnalysis

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
    def _importAnalysis(self):
        """Setup and import analyses for bsve tests."""
        if self._import_done:
            return

        path = "/minerva_analysis/folder"
        response = self.request(path=path, method="POST", user=self._user)
        self.assertStatusOk(response)
        analyses_folder = response.json["folder"]

        # import the bsve analysis
        client = GirderClient("localhost", girder_port)
        client.authenticate("minervauser", "password")

        bsve_analysis_path = os.path.abspath(
            os.path.join(os.path.dirname(os.path.realpath(__file__)), "../analyses/bsve")
        )
        import_analyses.import_analyses(client, bsve_analysis_path)

        path = "/item"
        params = {"folderId": analyses_folder["_id"]}
        response = self.request(path=path, method="GET", params=params, user=self._user)
        self.assertStatusOk(response)
        self.assertEquals(len(response.json), 2, "Expecting only one analysis")
        for analysis in response.json:
            if analysis["name"] == "bsve search":
                search_analysis = analysis
            elif analysis["name"] == "MMWR data import":
                soda_analysis = analysis
            else:
                self.fail('Unexpected analysis found "%s".' % analysis["name"])
        expected_meta = {
            u"minerva": {
                u"analysis_type": u"bsve_search",
                u"analysis_name": u"bsve search",
                u"analysis_id": search_analysis["_id"],
            }
        }
        self.assertEquals(search_analysis["meta"], expected_meta, "Unexpected value for search meta data")
        expected_meta = {
            u"minerva": {
                u"analysis_type": u"mmwr_import_data",
                u"analysis_name": u"MMWR data import",
                u"analysis_id": soda_analysis["_id"],
            }
        }
        self.assertEquals(soda_analysis["meta"], expected_meta, "Unexpected value for soda meta data")

        # create the dataset folder
        path = "/minerva_dataset/folder"
        params = {"userId": self._user["_id"]}
        response = self.request(path=path, method="POST", params=params, user=self._user)
        self.assertStatusOk(response)
        self._importDone = True
开发者ID:Kitware,项目名称:minerva,代码行数:56,代码来源:analysis_test.py

示例4: upload_benchmark_results

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
def upload_benchmark_results(benchmark_bin, api_key=None):
    hostname = socket.gethostname().lower()
    results_dir = os.path.join(benchmark_bin, 'BenchmarkResults',
            hostname)
    if not os.path.exists(results_dir):
        sys.stderr.write('Expected results directory does not exist: ' + results_dir)
        sys.exit(1)
    from girder_client import GirderClient
    gc = GirderClient(apiUrl='https://data.kitware.com/api/v1')
    gc.authenticate(apiKey=api_key)
    # ITK/PerformanceBenchmarkingResults
    folder_id = '5af50c818d777f06857985e3'
    hostname_folder = gc.loadOrCreateFolder(hostname, folder_id, 'folder')
    gc.upload(os.path.join(results_dir, '*.json'), hostname_folder['_id'],
            leafFoldersAsItems=False, reuseExisting=True)
开发者ID:InsightSoftwareConsortium,项目名称:ITKPerformanceBenchmarking,代码行数:17,代码来源:evaluate-itk-performance.py

示例5: main

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Import analyses into minerva')
    parser.add_argument('--username', required=False, default=None)
    parser.add_argument('--password', required=False, default=None)
    parser.add_argument('--scheme', required=False, default='http')
    parser.add_argument('--host', required=False, default='localhost')
    parser.add_argument('--port', required=False, default='8080')
    parser.add_argument('--api-root', required=False, default='/api/v1',
                        help='path to the Girder REST API')
    parser.add_argument('--path', required=True, help='the path to import the analyses from')

    config = parser.parse_args()

    client = GirderClient(host=config.host, port=config.port,
                          apiRoot=config.api_root, scheme=config.scheme)
    client.authenticate(config.username, config.password)

    import_analyses(client, config.path)
开发者ID:justincampbell,项目名称:minerva,代码行数:20,代码来源:import_analyses.py

示例6: testClientMetadataExtractor

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
    def testClientMetadataExtractor(self):
        item = self.model('item').load(self.item['_id'], user=self.user)
        self.assertEqual(item['name'], self.name)
        self.assertNotHasKeys(item, ['meta'])
        clientPath = os.path.join(ROOT_DIR, 'clients', 'python')
        sys.path.insert(0, clientPath)

        from girder_client import GirderClient

        client = GirderClient('localhost', int(os.environ['GIRDER_PORT']))
        client.authenticate(self.user['login'], self.password)
        extractor = ClientMetadataExtractor(client, self.path, self.item['_id'])
        extractor.extractMetadata()
        sys.path.remove(clientPath)
        item = self.model('item').load(self.item['_id'], user=self.user)
        self.assertEqual(item['name'], self.name)
        self.assertHasKeys(item, ['meta'])
        self.assertEqual(item['meta']['MIME type'], self.mimeType)
开发者ID:jbeezley,项目名称:girder,代码行数:20,代码来源:client_metadata_extractor_test.py

示例7: main

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
def main(args=None):
    parser = argparse.ArgumentParser(
        description='Mount Girder filesystem assetstore.')
    parser.add_argument('--api-url', required=True, default=None,
                        help='full URL to the RESTful API of Girder server')
    parser.add_argument('--username', required=False, default=None)
    parser.add_argument('--password', required=False, default=None)
    parser.add_argument('--api-key', required=False, default=None)
    parser.add_argument('--token', required=False, default=None)
    parser.add_argument('-c', default='remote', choices=['remote', 'direct'],
                        help='command to run')
    parser.add_argument('--foreground', dest='foreground',
                        action='store_true')
    parser.add_argument('--hostns', dest='hostns', action='store_true')
    parser.add_argument('local_folder', help='path to local target folder')
    parser.add_argument('remote_folder', help='Girder\'s folder id')

    args = parser.parse_args()

    gc = GirderClient(apiUrl=args.api_url)
    if args.token:
        gc.token = args.token
    elif args.api_key:
        gc.authenticate(apiKey=args.api_key)
    elif args.username and args.password:
        gc.authenticate(username=args.username, password=args.password)
    else:
        raise RuntimeError("You need to specify apiKey or user/pass")

    if args.hostns:
        targetns = os.path.join(os.environ.get('HOSTDIR', '/'),
                                'proc/1/ns/mnt')
        with open(targetns) as fd:
            setns(fd, CLONE_NEWNS)

    if args.c == 'remote':
        FUSE(RESTGirderFS(args.remote_folder, gc), args.local_folder,
             foreground=args.foreground, ro=True, allow_other=True)
    elif args.c == 'direct':
        FUSE(LocalGirderFS(args.remote_folder, gc), args.local_folder,
             foreground=args.foreground, ro=True, allow_other=True)
    else:
        print('No implementation for command %s' % args.c)
开发者ID:data-exp-lab,项目名称:girder_fs,代码行数:45,代码来源:__main__.py

示例8: main

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
def main():
    """Create the folder hierarchy with metadata in a Girder instance."""
    args = parser.parse_args()
    g = GirderClient(host=args.host, port=args.port, scheme=args.scheme)
    g.authenticate(args.username, args.password)

    def create_folder_on_demand(parent_folder_id, folder_name):
        existing_folders = list(
            g.listFolder(parent_folder_id, name=folder_name))
        if not len(existing_folders):
            sought_folder = g.createFolder(parent_folder_id, name=folder_name)
        else:
            sought_folder = existing_folders[0]
        return sought_folder

    metadata_file = 'metadata.json'
    with open(metadata_file) as json_file:
        metadata = json.load(json_file)
    parent_folder_id = args.parent_folder_id

    for subject_id, subject_metadata in metadata.items():
        subject_folder = create_folder_on_demand(parent_folder_id, subject_id)
        for (scan_time, scan_date, scan_weight) in subject_metadata['scans']:
            create_folder_on_demand(subject_folder['_id'], scan_time)
开发者ID:girder,项目名称:monkeybrains,代码行数:26,代码来源:create_tree_from_metadata.py

示例9: GirderClient

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
parser.add_argument('--admin', help='name:pass for the admin user')
parser.add_argument('--host', help='host to connect to')
parser.add_argument('--port', type=int, help='port to connect to')
parser.add_argument('--broker', help='girder worker broker URI')
parser.add_argument('--s3', help='name of S3 bucket')
parser.add_argument('--aws-key-id', help='aws key id')
parser.add_argument('--aws-secret-key', help='aws secret key')

args = parser.parse_args()

client = GirderClient(host=args.host, port=args.port)

user, password = args.admin.split(":", 1)

if find_user('girder'):
    client.authenticate('girder', 'girder')

ensure_user(client,
            login=user,
            password=password,
            email='[email protected]',
            firstName='Girder',
            lastName='Admin')

client.authenticate(user, password)

s3_assetstore_name = 's3'

if find_assetstore(s3_assetstore_name) is None:
    client.post('assetstore',
                parameters=dict(name=s3_assetstore_name,
开发者ID:osumo,项目名称:sumobot,代码行数:33,代码来源:girder-post-install.py

示例10: testBsveSearchAnalysis

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
    def testBsveSearchAnalysis(self):
        # create the analysis folder
        path = '/minerva_analysis/folder'
        response = self.request(path=path, method='POST', user=self._user)
        self.assertStatusOk(response)
        analyses_folder = response.json['folder']

        # import the bsve analysis
        client = GirderClient('localhost', girder_port)
        client.authenticate('minervauser', 'password')

        bsve_analysis_path = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../analyses/bsve'))
        import_analyses.import_analyses(client, bsve_analysis_path)

        path = '/item'
        params = {
            'folderId': analyses_folder['_id']
        }
        response = self.request(path=path, method='GET', params=params, user=self._user)
        self.assertStatusOk(response)
        self.assertEquals(len(response.json), 1, 'Expecting only one analysis')
        analysis = response.json[0]
        self.assertEquals(analysis['name'], 'bsve search', 'Expecting analysis name to be "bsve search"')
        expected_meta = {
            u'minerva': {
                u'analysis_type': u'bsve_search',
                u'analysis_name': u'bsve search',
                u'analysis_id': analysis['_id']
            }
        }
        self.assertEquals(analysis['meta'], expected_meta, 'Unexpected value for meta data')

        # create the dataset folder
        path = '/minerva_dataset/folder'
        params = {
            'userId': self._user['_id'],
        }
        response = self.request(path=path, method='POST', params=params, user=self._user)
        self.assertStatusOk(response)

        # mock the calls to bsve search
        @urlmatch(netloc=r'(.*\.)?beta-search.bsvecosystem.net(.*)$')
        def bsve_mock(url, request):
            if url.path.split('/')[-1] == 'request':
                return httmock.response(200, '12345')
            else:
                pluginTestDir = os.path.dirname(os.path.realpath(__file__))
                filepath = os.path.join(pluginTestDir, 'data', 'bsve_search.json')
                with open(filepath) as bsve_search_file:
                    content = {
                        'status': 1,
                        'results': json.load(bsve_search_file)
                    }
                    headers = {
                        'content-length': len(content),
                        'content-type': 'application/json'
                    }
                    return httmock.response(200, content, headers, request=request)

        with HTTMock(bsve_mock):
            response = self.request(
                path='/minerva_analysis/bsve_search',
                method='POST',
                params={
                    'datasetName': 'test dataset',
                    'bsveSearchParams': '{}'
                },
                user=self._user
            )

            # wait for the async job to complete
            searchResultsFinished = False
            count = 0
            while not searchResultsFinished and count < 5:
                # get the dataset and check if it has been updated
                path = '/minerva_dataset/%s/dataset' % str(response.json['dataset_id'])
                response = self.request(
                    path=path,
                    method='GET',
                    user=self._user
                )
                dataset = response.json
                if 'json_row' in dataset:
                    searchResultsFinished = True
                else:
                    time.sleep(2)
                    count += 1

            # ensure the first row of results was added to the dataset
            self.assertTrue('json_row' in dataset, 'json_row expected in dataset')
            self.assertTrue('data' in dataset['json_row'], 'data should be in json_row')
            self.assertTrue('Longitude' in dataset['json_row']['data'], 'data.Longitude should be in json_row')

            # ensure that we can map the Lat/Long to geojson, as this json has
            # unicode values for Lat/Long

            # update the minerva metadata with coordinate mapping
            metadata = {'minerva': dataset}
            metadata['minerva']['mapper'] = {
                "latitudeKeypath": "data.Latitude",
#.........这里部分代码省略.........
开发者ID:justincampbell,项目名称:minerva,代码行数:103,代码来源:analysis_test.py

示例11: GirderClient

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]

parser = argparse.ArgumentParser()
parser.add_argument("path", type=str,
                    help="path to Arbor web apps")
parser.add_argument("-g", "--girder-host", type=str, default='localhost',
                    help="host to Girder instance")
parser.add_argument("-p", "--girder-port", type=int, default=9000,
                    help="port to Girder instance")

args = parser.parse_args()


# Get the ID for our Analyses folder.
c = GirderClient(host=args.girder_host, port=args.girder_port)
c.authenticate('girder', 'girder')
folderSearch = c.get('resource/search', parameters={
    'q': 'Analyses',
    'types': '["folder"]'
})
folderId = folderSearch['folder'][0]['_id']

# Disable authorization requirements for running romanesco tasks
c.put('system/setting', parameters={
    'key': 'flow.require_auth',
    'value': 'false'
})

# Check if these analyses already exist.  If so, we won't re-upload them.
uploadACR = False
uploadPGS = False
开发者ID:Kitware,项目名称:flow,代码行数:32,代码来源:easymode-setup.py

示例12: main

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
def main(config):
    client = GirderClient(apiUrl=config.girder_api_url)
    client.authenticate(config.girder_user,
                        config.girder_password)

    try:
        # First run the simple flow
        print ('Running simple taskflow ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.SimpleTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

        # First run the simple flow
        print ('Running linked taskflow ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.LinkTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

        # Test terminating a simple flow
        print ('Running simple taskflow ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.SimpleTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        time.sleep(4)

        print ('Terminate the taskflow')
        url = 'taskflows/%s/terminate' % (taskflow_id)
        client.put(url)

        # Wait for it to terminate
        wait_for_terminated(client, taskflow_id)

        # Now delete it
        print ('Delete the taskflow')
        url = 'taskflows/%s' % (taskflow_id)
        try:
            client.delete(url)
        except HttpError as ex:
            if ex.status != 202:
                raise

        # Wait for it to terminate
        wait_for_deletion(client, taskflow_id)


        # Now try something with a chord
        print ('Running taskflow containing a chord ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.ChordTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

        # Now try a workflow that is the two connected together
        print ('Running taskflow that connects to parts together ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.ConnectTwoTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

#      # Now try a composite workflow approach ...
#        print ('Running taskflow that is a composite ...')
#        taskflow_id = create_taskflow(
#            client, 'cumulus.taskflow.core.test.mytaskflows.MyCompositeTaskFlow')
#
#        # Start the task flow
#        url = 'taskflows/%s/start' % (taskflow_id)
#        client.put(url)
#
#        # Wait for it to complete
#        wait_for_complete(client, taskflow_id)

    except HttpError as ex:
        print( ex.responseText)
开发者ID:Kitware,项目名称:cumulus,代码行数:101,代码来源:taskflow_runner.py

示例13: BaseIntegrationTest

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
class BaseIntegrationTest(unittest.TestCase):
    def __init__(self, name, girder_url, girder_user, girder_password, job_timeout=60, cleanup=True):
        super(BaseIntegrationTest, self).__init__(name)
        self._job_id = None
        self._script_id = None
        self._output_folder_id = None
        self._input_folder_id = None
        self._girder_url = girder_url
        self._girder_user = girder_user
        self._girder_password = girder_password
        self._job_timeout = job_timeout
        self._data = 'Need more input!'
        self._cleanup = cleanup

    def setUp(self):
        url = '%s/api/v1' % self._girder_url
        self._client = GirderClient(apiUrl=url)
        self._client.authenticate(self._girder_user,
                                  self._girder_password)

        user = self._client.get('user/me')
        self._user_id = user['_id']
        r = list(self._client.listFolder(self._user_id, 'user', name='Private'))
        self.assertEqual(len(r), 1)
        self._private_folder_id = r[0]['_id']

    def tearDown(self):

        if not self._cleanup:
            return

        if self._job_id:
            try:
                url = 'jobs/%s' % self._job_id
                self._client.delete(url)
            except Exception as e:
                traceback.print_exc()

        if self._script_id:
            try:
                url = 'scripts/%s' % self._script_id
                self._client.delete(url)
            except Exception:
                traceback.print_exc()

        if self._output_folder_id:
            try:
                url = 'folder/%s' % self._output_folder_id
                self._client.delete(url)
            except Exception:
                traceback.print_exc()

        if self._input_folder_id:
            try:
                url = 'folder/%s' % self._input_folder_id
                self._client.delete(url)
            except Exception:
                traceback.print_exc()

    def create_script(self, commands=[
                'sleep 10', 'cat CumulusIntegrationTestInput'
            ]):
        body = {
            'commands': commands,
            'name': 'CumulusIntegrationTestLob'
        }

        r = self._client.post('scripts', data=json.dumps(body))
        self._script_id = r['_id']

    def create_input(self, folder_name='CumulusInput'):

        r = self._client.createFolder(self._private_folder_id, folder_name)
        self._input_folder_id = r['_id']
        size = len(self._data)

        item = self._client.uploadFile(self._input_folder_id,
                    StringIO(self._data), 'CumulusIntegrationTestInput', size,
                    parentType='folder')

        self._item_id = item['itemId']

    def create_output_folder(self, folder_name='CumulusOutput'):
        r = self._client.createFolder(self._private_folder_id, folder_name)
        self._output_folder_id = r['_id']

    def create_job(self, job_name='CumulusIntegrationTestJob', tail=None):
        body = {
            'name': job_name,
            'scriptId': self._script_id,
            'output': [{
              'folderId': self._output_folder_id,
              'path': '.'
            }],
            'input': [
              {
                'folderId': self._input_folder_id,
                'path': '.'
              }
            ]
#.........这里部分代码省略.........
开发者ID:Kitware,项目名称:cumulus,代码行数:103,代码来源:base_integration_test.py

示例14: testImportAnalyses

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
    def testImportAnalyses(self):
        """
        Test importing a romanesco analysis
        """
        client = GirderClient('localhost', girder_port)
        client.authenticate(self._username, self._password)

        path = os.path.dirname(os.path.realpath(__file__))
        analyses_path = os.path.join(path, 'analyses')

        import_analyses.import_analyses(client, analyses_path)

        # Get the analysis folder
        path = '/minerva_analysis/folder'
        response = self.request(path=path, method='GET', params={}, user=self._user)
        self.assertStatusOk(response)
        analyses_folder = response.json['folder']

        path = '/item'
        params = {
            'folderId': analyses_folder['_id']
        }
        response = self.request(path=path, method='GET', params=params, user=self._user)
        self.assertStatusOk(response)
        self.assertEquals(len(response.json), 2, 'Expecting two analyses')
        analysis = response.json[0]
        self.assertEquals(analysis['name'], 'add', 'Expecting analysis one name to be "add"')
        expected_meta = {
            u'minerva': {
                u'analysis_type': u'add',
                u'analysis_name': u'add',
                u'analysis_id': analysis['_id']
            },
            u'analysis': {
                u'inputs': [{
                    u'default': {
                        u'data': u'0',
                        u'format': u'json'
                    },
                    u'type': u'number',
                    u'name': u'a',
                    u'format': u'number'
                },
                {
                    u'type': u'number',
                    u'name': u'b',
                    u'format':
                    u'number'
                }],
                u'script': u'c = a + b',
                u'mode': u'python',
                u'outputs': [{
                    u'type': u'number',
                    u'name': u'c',
                    u'format': u'number'
                }],
                u'name': u'add'
            }
        }
        self.assertEquals(analysis['meta'], expected_meta, 'Unexpected value for meta data')

        analysis = response.json[1]
        self.assertEquals(analysis['name'], 'local', 'Expecting analysis two name to be "local"')
        expected_meta = {
            u'minerva': {
                u'analysis_type': u'local type',
                u'analysis_name': u'local',
                u'analysis_id': analysis['_id']
            }
        }
        self.assertEquals(analysis['meta'], expected_meta, 'Unexpected value for meta data')
开发者ID:justincampbell,项目名称:minerva,代码行数:73,代码来源:import_analyses_test.py

示例15: GirderClient

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import authenticate [as 别名]
from girder_client import GirderClient

c = GirderClient(host="localhost", port=9000)

# Create an admin user if there isn't one
try:
    c.authenticate("girder", "girder")
except:
    c.sendRestRequest(
        "POST",
        "user",
        {
            "login": "girder",
            "password": "girder",
            "email": "[email protected]",
            "firstName": "Girder",
            "lastName": "Admin",
        },
    )
    c.authenticate("girder", "girder")

# Create a tangelo hub collection if there isn't one
coll_search = c.get("resource/search", parameters={"q": "Default", "types": '["collection"]'})
if len(coll_search["collection"]) == 0:
    collection = c.post(
        "collection", parameters={"name": "Default", "description": "Default workspace", "public": "true"}
    )
    c.post(
        "folder",
        parameters={
            "parentType": "collection",
开发者ID:Kitware,项目名称:flow,代码行数:33,代码来源:girder-setup.py


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