Пример #1
0
    def client(self, address, is_cli=True):
        '''
        Return a client given the address.  Note that this can either be called
        by the CLI (is_cli=True) or the server (is_cli=False).
        If called by the CLI, we don't need to authenticate.
        Cache the Client if necessary.
        '''
        if address in self.clients:
            return self.clients[address]
        # if local force mockauth or if locl server use correct auth
        if is_local_address(address):
            bundle_store = self.bundle_store()
            model = self.model()
            auth_handler = self.auth_handler(mock=is_cli)

            from codalab.client.local_bundle_client import LocalBundleClient
            client = LocalBundleClient(address, bundle_store, model,
                                       auth_handler, self.cli_verbose)
            self.clients[address] = client
            if is_cli:
                # Set current user
                access_token = self._authenticate(client)
                auth_handler.validate_token(access_token)
        else:
            from codalab.client.remote_bundle_client import RemoteBundleClient
            client = RemoteBundleClient(
                address, lambda a_client: self._authenticate(a_client),
                self.cli_verbose())
            self.clients[address] = client
            self._authenticate(client)
        return client
Пример #2
0
 def __init__(self, user=None):
     self.client = RemoteBundleClient(
         settings.BUNDLE_SERVICE_URL,
         lambda command: get_user_token(user),
         verbose=1)
Пример #3
0
 def __init__(self):
     self.client = RemoteBundleClient(settings.BUNDLE_SERVICE_URL)
Пример #4
0
 def __init__(self):
     self.client = RemoteBundleClient(
         self._cli_url(), lambda command: self._get_user_token(), verbose=0)
Пример #5
0
 def __init__(self):
     self.client = RemoteBundleClient(settings.BUNDLE_SERVICE_URL,
                                      lambda command: "")  #TODO