_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q272400
check_call
test
def check_call(state, callstr, argstr=None, expand_msg=None): """When checking a function definition of lambda function, prepare has_equal_x for checking the call of a user-defined function. Args: callstr (str): call string that specifies how the function should be called, e.g. `f(1, a = 2)`. ...
python
{ "resource": "" }
q272401
TransitModel.get_true_anomaly
test
def get_true_anomaly(self): """ Return the true anomaly at each time """ self.f = _rsky._getf(self.t_supersample, self.t0, self.per, self.a, self.inc*pi/180., self.ecc, self.w*pi/180., self.transittype, self.nthreads) return self.f
python
{ "resource": "" }
q272402
LDAP3LoginManager.init_app
test
def init_app(self, app): ''' Configures this extension with the given app. This registers an ``teardown_appcontext`` call, and attaches this ``LDAP3LoginManager`` to it as ``app.ldap3_login_manager``. Args: app (flask.Flask): The flask app to initialise with ...
python
{ "resource": "" }
q272403
LDAP3LoginManager.init_config
test
def init_config(self, config): ''' Configures this extension with a given configuration dictionary. This allows use of this extension without a flask app. Args: config (dict): A dictionary with configuration keys ''' self.config.update(config) self....
python
{ "resource": "" }
q272404
LDAP3LoginManager.add_server
test
def add_server(self, hostname, port, use_ssl, tls_ctx=None): """ Add an additional server to the server pool and return the freshly created server. Args: hostname (str): Hostname of the server port (int): Port of the server use_ssl (bool): True if SSL...
python
{ "resource": "" }
q272405
LDAP3LoginManager._decontextualise_connection
test
def _decontextualise_connection(self, connection): """ Remove a connection from the appcontext. Args: connection (ldap3.Connection): connection to remove from the appcontext """ ctx = stack.top if ctx is not None and connection in ctx.ldap3_...
python
{ "resource": "" }
q272406
LDAP3LoginManager.teardown
test
def teardown(self, exception): """ Cleanup after a request. Close any open connections. """ ctx = stack.top if ctx is not None: if hasattr(ctx, 'ldap3_manager_connections'): for connection in ctx.ldap3_manager_connections: self.des...
python
{ "resource": "" }
q272407
LDAP3LoginManager.authenticate
test
def authenticate(self, username, password): """ An abstracted authentication method. Decides whether to perform a direct bind or a search bind based upon the login attribute configured in the config. Args: username (str): Username of the user to bind pass...
python
{ "resource": "" }
q272408
LDAP3LoginManager.authenticate_direct_bind
test
def authenticate_direct_bind(self, username, password): """ Performs a direct bind. We can do this since the RDN is the same as the login attribute. Hence we just string together a dn to find this user with. Args: username (str): Username of the user to bind (the fie...
python
{ "resource": "" }
q272409
LDAP3LoginManager.authenticate_search_bind
test
def authenticate_search_bind(self, username, password): """ Performs a search bind to authenticate a user. This is required when a the login attribute is not the same as the RDN, since we cannot string together their DN on the fly, instead we have to find it in the LDAP, then att...
python
{ "resource": "" }
q272410
LDAP3LoginManager.get_user_groups
test
def get_user_groups(self, dn, group_search_dn=None, _connection=None): """ Gets a list of groups a user at dn is a member of Args: dn (str): The dn of the user to find memberships for. _connection (ldap3.Connection): A connection object to use when search...
python
{ "resource": "" }
q272411
LDAP3LoginManager.get_user_info
test
def get_user_info(self, dn, _connection=None): """ Gets info about a user specified at dn. Args: dn (str): The dn of the user to find _connection (ldap3.Connection): A connection object to use when searching. If not given, a temporary connection will be ...
python
{ "resource": "" }
q272412
LDAP3LoginManager.get_user_info_for_username
test
def get_user_info_for_username(self, username, _connection=None): """ Gets info about a user at a specified username by searching the Users DN. Username attribute is the same as specified as LDAP_USER_LOGIN_ATTR. Args: username (str): Username of the user to search ...
python
{ "resource": "" }
q272413
LDAP3LoginManager.get_object
test
def get_object(self, dn, filter, attributes, _connection=None): """ Gets an object at the specified dn and returns it. Args: dn (str): The dn of the object to find. filter (str): The LDAP syntax search filter. attributes (list): A list of LDAP attributes to g...
python
{ "resource": "" }
q272414
LDAP3LoginManager.connection
test
def connection(self): """ Convenience property for externally accessing an authenticated connection to the server. This connection is automatically handled by the appcontext, so you do not have to perform an unbind. Returns: ldap3.Connection: A bound ldap3.Connection...
python
{ "resource": "" }
q272415
LDAP3LoginManager.make_connection
test
def make_connection(self, bind_user=None, bind_password=None, **kwargs): """ Make a connection to the LDAP Directory. Args: bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is used, otherwise authentication specified with config['LDAP_BIN...
python
{ "resource": "" }
q272416
LDAP3LoginManager._make_connection
test
def _make_connection(self, bind_user=None, bind_password=None, contextualise=True, **kwargs): """ Make a connection. Args: bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is used, otherwise authentication specified with ...
python
{ "resource": "" }
q272417
LDAP3LoginManager.destroy_connection
test
def destroy_connection(self, connection): """ Destroys a connection. Removes the connection from the appcontext, and unbinds it. Args: connection (ldap3.Connection): The connnection to destroy """ log.debug("Destroying connection at <{0}>".format(hex(id(con...
python
{ "resource": "" }
q272418
search
test
def search(self, query=None, args=None): '''query a s3 endpoint for an image based on a string EXAMPLE QUERIES: [empty] list all container collections vsoch/dinosaur look for containers with name vsoch/dinosaur ''' if query is not None: return self._container_se...
python
{ "resource": "" }
q272419
label_search
test
def label_search(self, key=None, value=None): '''search across labels''' if key is not None: key = key.lower() if value is not None: value = value.lower() show_details = True if key is None and value is None: url = '%s/labels/search' % (self.base) show_details = Fa...
python
{ "resource": "" }
q272420
search
test
def search(self, query=None, args=None): '''query a GitLab artifacts folder for a list of images. If query is None, collections are listed. ''' if query is None: bot.exit('You must include a collection query, <collection>/<repo>') # or default to listing (searching) all things. retur...
python
{ "resource": "" }
q272421
search_all
test
def search_all(self, collection, job_id=None): '''a "show all" search that doesn't require a query the user is shown URLs to ''' results = [['job_id', 'browser']] url = "%s/projects/%s/jobs" %(self.api_base, quote_plus(collection.strip('/'))) response =...
python
{ "resource": "" }
q272422
ApiConnection.speak
test
def speak(self): ''' a function for the client to announce him or herself, depending on the level specified. If you want your client to have additional announced things here, then implement the class `_speak` for your client. ''' if self.quiet is Fals...
python
{ "resource": "" }
q272423
ApiConnection.announce
test
def announce(self, command=None): '''the client will announce itself given that a command is not in a particular predefined list. ''' if command is not None: if command not in ['get'] and self.quiet is False: self.speak()
python
{ "resource": "" }
q272424
Client._update_secrets
test
def _update_secrets(self): '''The user is required to have an application secrets file in his or her environment. The client exists with error if the variable isn't found. ''' env = 'SREGISTRY_GOOGLE_DRIVE_CREDENTIALS' self._secrets = self._get_and_update_setting(e...
python
{ "resource": "" }
q272425
update_headers
test
def update_headers(self,fields=None): '''update headers with a token & other fields ''' do_reset = True if hasattr(self, 'headers'): if self.headers is not None: do_reset = False if do_reset is True: self._reset_headers() if fields is not None: for key,value...
python
{ "resource": "" }
q272426
require_secrets
test
def require_secrets(self, params=None): '''require secrets ensures that the client has the secrets file, and specifically has one or more parameters defined. If params is None, only a check is done for the file. Parameters ========== params: a list of keys to lookup in the client...
python
{ "resource": "" }
q272427
download
test
def download(url, file_name, headers=None, show_progress=True): '''stream to a temporary file, rename on successful completion Parameters ========== file_name: the file name to stream to url: the url to stream from headers: additional headers to add ''' fd, tmp_file...
python
{ "resource": "" }
q272428
stream
test
def stream(url, headers, stream_to=None, retry=True): '''stream is a get that will stream to file_name. Since this is a worker task, it differs from the client provided version in that it requires headers. ''' bot.debug("GET %s" % url) if DISABLE_SSL_CHECK is True: bot.warning('Ve...
python
{ "resource": "" }
q272429
update_token
test
def update_token(headers): '''update_token uses HTTP basic authentication to attempt to authenticate given a 401 response. We take as input previous headers, and update them. Parameters ========== response: the http request response to parse for the challenge. ''' try: fro...
python
{ "resource": "" }
q272430
get_or_create_folder
test
def get_or_create_folder(self, folder): '''create a folder at the drive root. If the folder already exists, it is simply returned. folder = self._get_or_create_folder(self._base) $ folder {'id': '1pXR5S8wufELh9Q-jDkhCoYu-BL1NqN9y'} ''' q = "mimeType='application/v...
python
{ "resource": "" }
q272431
Client._read_response
test
def _read_response(self,response, field="detail"): '''attempt to read the detail provided by the response. If none, default to using the reason''' try: message = json.loads(response._content.decode('utf-8'))[field] except: message = response.reason retur...
python
{ "resource": "" }
q272432
Client.get_bucket
test
def get_bucket(self): '''given a bucket name and a client that is initialized, get or create the bucket. ''' for attr in ['bucket_name', 's3']: if not hasattr(self, attr): bot.exit('client is missing attribute %s' %(attr)) # See if the bucket is al...
python
{ "resource": "" }
q272433
Client._update_secrets
test
def _update_secrets(self): '''update secrets will take a secrets credential file either located at .sregistry or the environment variable SREGISTRY_CLIENT_SECRETS and update the current client secrets as well as the associated API base. ''' self.secrets = read_client_sec...
python
{ "resource": "" }
q272434
Client._init_clients
test
def _init_clients(self): '''init_ cliends will obtain the tranfer and access tokens, and then use them to create a transfer client. ''' self._client = globus_sdk.NativeAppAuthClient(self._client_id) self._load_secrets()
python
{ "resource": "" }
q272435
Client._load_secrets
test
def _load_secrets(self): '''load the secrets credentials file with the Globus OAuthTokenResponse ''' # Second priority: load from cache self.auth = self._get_and_update_setting('GLOBUS_AUTH_RESPONSE') self.transfer = self._get_and_update_setting('GLOBUS_TRANSFER_RESPONSE...
python
{ "resource": "" }
q272436
logs
test
def logs(self, name=None): '''return logs for a particular container. The logs file is equivalent to the name, but with extension .log. If there is no name, the most recent log is returned. Parameters ========== name: the container name to print logs for. ''' content = N...
python
{ "resource": "" }
q272437
list_logs
test
def list_logs(self): '''return a list of logs. We return any file that ends in .log ''' results = [] for image in self._bucket.list_blobs(): if image.name.endswith('log'): results.append(image) if len(results) == 0: bot.info("No containers found, based on extension .log"...
python
{ "resource": "" }
q272438
create_endpoint_folder
test
def create_endpoint_folder(self, endpoint_id, folder): '''create an endpoint folder, catching the error if it exists. Parameters ========== endpoint_id: the endpoint id parameters folder: the relative path of the folder to create ''' try: res = self.transfer_client.oper...
python
{ "resource": "" }
q272439
init_transfer_client
test
def init_transfer_client(self): '''return a transfer client for the user''' if self._tokens_need_update(): self._update_tokens() access_token = self.transfer['access_token'] # Createe Refresh Token Authorizer authorizer = globus_sdk.RefreshTokenAuthorizer( ...
python
{ "resource": "" }
q272440
search_all
test
def search_all(self): '''a "list all" search that doesn't require a query. Here we return to the user all objects that have custom properties value type set to container, which is set when the image is pushed. IMPORTANT: the upload function adds this metadata. For a container to be fou...
python
{ "resource": "" }
q272441
status
test
def status(backend): '''print the status for all or one of the backends. ''' print('[backend status]') settings = read_client_secrets() print('There are %s clients found in secrets.' %len(settings)) if 'SREGISTRY_CLIENT' in settings: print('active: %s' %settings['SREGISTRY_CLIENT']) ...
python
{ "resource": "" }
q272442
add
test
def add(backend, variable, value, force=False): '''add the variable to the config ''' print('[add]') settings = read_client_secrets() # If the variable begins with the SREGISTRY_<CLIENT> don't add it prefix = 'SREGISTRY_%s_' %backend.upper() if not variable.startswith(prefix): varia...
python
{ "resource": "" }
q272443
remove
test
def remove(backend, variable): '''remove a variable from the config, if found. ''' print('[remove]') settings = read_client_secrets() # If the variable begins with the SREGISTRY_<CLIENT> don't add it prefixed = variable prefix = 'SREGISTRY_%s_' %backend.upper() if not variable.startswit...
python
{ "resource": "" }
q272444
activate
test
def activate(backend): '''activate a backend by adding it to the .sregistry configuration file. ''' settings = read_client_secrets() if backend is not None: settings['SREGISTRY_CLIENT'] = backend update_secrets(settings) print('[activate] %s' %backend)
python
{ "resource": "" }
q272445
delete_backend
test
def delete_backend(backend): '''delete a backend, and update the secrets file ''' settings = read_client_secrets() if backend in settings: del settings[backend] # If the backend was the active client, remove too if 'SREGISTRY_CLIENT' in settings: if settings['SREGIST...
python
{ "resource": "" }
q272446
Client._update_base
test
def _update_base(self, image): ''' update a base based on an image name, meaning detecting a particular registry and if necessary, updating the self.base. When the image name is parsed, the base will be given to remove the registry. ''' base = None # Google Conta...
python
{ "resource": "" }
q272447
basic_auth_header
test
def basic_auth_header(username, password): '''generate a base64 encoded header to ask for a token. This means base64 encoding a username and password and adding to the Authorization header to identify the client. Parameters ========== username: the username password:...
python
{ "resource": "" }
q272448
generate_signature
test
def generate_signature(payload, secret): '''use an endpoint specific payload and client secret to generate a signature for the request''' payload = _encode(payload) secret = _encode(secret) return hmac.new(secret, digestmod=hashlib.sha256, msg=payload).hexdigest()
python
{ "resource": "" }
q272449
generate_header_signature
test
def generate_header_signature(secret, payload, request_type): '''Authorize a client based on encrypting the payload with the client secret, timestamp, and other metadata ''' # Use the payload to generate a digest push|collection|name|tag|user timestamp = generate_timestamp() credential = ...
python
{ "resource": "" }
q272450
delete
test
def delete(self, url, headers=None, return_json=True, default_headers=True): '''delete request, use with caution ''' bot.debug('DELETE %s' %url) return self._call(url, headers=headers, func=requests.delete, ...
python
{ "resource": "" }
q272451
head
test
def head(self, url): '''head request, typically used for status code retrieval, etc. ''' bot.debug('HEAD %s' %url) return self._call(url, func=requests.head)
python
{ "resource": "" }
q272452
paginate_get
test
def paginate_get(self, url, headers=None, return_json=True, start_page=None): '''paginate_call is a wrapper for get to paginate results ''' geturl = '%s&page=1' %(url) if start_page is not None: geturl = '%s&page=%s' %(url,start_page) re...
python
{ "resource": "" }
q272453
verify
test
def verify(self): ''' verify will return a True or False to determine to verify the requests call or not. If False, we should the user a warning message, as this should not be done in production! ''' from sregistry.defaults import DISABLE_SSL_CHECK if DISABLE_SSL_CHECK is True: ...
python
{ "resource": "" }
q272454
remove
test
def remove(self, image, force=False): '''delete an image to Singularity Registry''' q = parse_image_name(remove_uri(image)) # If the registry is provided in the uri, use it if q['registry'] == None: q['registry'] = self.base # If the base doesn't start with http or https, add it q = s...
python
{ "resource": "" }
q272455
get_lookup
test
def get_lookup(): '''get version by way of sregistry.version, returns a lookup dictionary with several global variables without needing to import singularity ''' lookup = dict() version_file = os.path.join('sregistry', 'version.py') with open(version_file) as filey: exec(filey.read(...
python
{ "resource": "" }
q272456
get_reqs
test
def get_reqs(lookup=None, key='INSTALL_REQUIRES'): '''get requirements, mean reading in requirements and versions from the lookup obtained with get_lookup''' if lookup == None: lookup = get_lookup() install_requires = [] for module in lookup[key]: module_name = module[0] mo...
python
{ "resource": "" }
q272457
get_singularity_version
test
def get_singularity_version(singularity_version=None): '''get_singularity_version will determine the singularity version for a build first, an environmental variable is looked at, followed by using the system version. Parameters ========== singularity_version: if not defined, lo...
python
{ "resource": "" }
q272458
check_install
test
def check_install(software=None, quiet=True): '''check_install will attempt to run the singularity command, and return True if installed. The command line utils will not run without this check. Parameters ========== software: the software to check if installed quiet: shou...
python
{ "resource": "" }
q272459
get_installdir
test
def get_installdir(): '''get_installdir returns the installation directory of the application ''' return os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
python
{ "resource": "" }
q272460
get_thumbnail
test
def get_thumbnail(): '''return the robot.png thumbnail from the database folder. if the user has exported a different image, use that instead. ''' from sregistry.defaults import SREGISTRY_THUMBNAIL if SREGISTRY_THUMBNAIL is not None: if os.path.exists(SREGISTRY_THUMBNAIL): ret...
python
{ "resource": "" }
q272461
run_command
test
def run_command(cmd, sudo=False): '''run_command uses subprocess to send a command to the terminal. Parameters ========== cmd: the command to send, should be a list for subprocess error_message: the error message to give to user if fails, if none specified, will alert that command failed. ...
python
{ "resource": "" }
q272462
Client._get_metadata
test
def _get_metadata(self, image_file=None, dbx_metadata=None): '''this is a wrapper around the main client.get_metadata to first parse a Dropbox FileMetadata into a dicionary, then pass it on to the primary get_metadata function. Parameters ========== image...
python
{ "resource": "" }
q272463
Client._update_secrets
test
def _update_secrets(self): '''update secrets will look for a dropbox token in the environment at SREGISTRY_DROPBOX_TOKEN and if found, create a client. If not, an error message is returned and the client exits. ''' # Retrieve the user token. Exit if not found toke...
python
{ "resource": "" }
q272464
print_output
test
def print_output(response, output_file=None): '''print the output to the console for the user. If the user wants the content also printed to an output file, do that. Parameters ========== response: the response from the builder, with metadata added output_file: if defined, write ...
python
{ "resource": "" }
q272465
kill
test
def kill(args): '''kill is a helper function to call the "kill" function of the client, meaning we bring down an instance. ''' from sregistry.main import Client as cli if len(args.commands) > 0: for name in args.commands: cli.destroy(name) sys.exit(0)
python
{ "resource": "" }
q272466
list_logs
test
def list_logs(args, container_name=None): '''list a specific log for a builder, or the latest log if none provided Parameters ========== args: the argparse object to look for a container name container_name: a default container name set to be None (show latest log) ''' from sre...
python
{ "resource": "" }
q272467
Client.get_collections
test
def get_collections(self): '''get a listing of collections that the user has access to. ''' collections = [] for container in self.conn.get_account()[1]: collections.append(container['name']) return collections
python
{ "resource": "" }
q272468
Client._update_secrets
test
def _update_secrets(self): '''update secrets will look for a user and token in the environment If we find the values, cache and continue. Otherwise, exit with error ''' # Get the swift authentication type first. That will determine what we # will need to collect for proper a...
python
{ "resource": "" }
q272469
Client._update_secrets
test
def _update_secrets(self): '''The user is required to have an application secrets file in his or her environment. The information isn't saved to the secrets file, but the client exists with error if the variable isn't found. ''' env = 'GOOGLE_APPLICATION_CREDENTIALS' ...
python
{ "resource": "" }
q272470
get_client
test
def get_client(image=None, quiet=False, **kwargs): ''' get the correct client depending on the driver of interest. The selected client can be chosen based on the environment variable SREGISTRY_CLIENT, and later changed based on the image uri parsed If there is no preference, the default ...
python
{ "resource": "" }
q272471
ipython
test
def ipython(args): '''give the user an ipython shell, optionally with an endpoint of choice. ''' # The client will announce itself (backend/database) unless it's get from sregistry.main import get_client client = get_client(args.endpoint) client.announce(args.command) from IPython import em...
python
{ "resource": "" }
q272472
get_manifests
test
def get_manifests(self, repo_name, digest=None): '''get_manifests calls get_manifest for each of the schema versions, including v2 and v1. Version 1 includes image layers and metadata, and version 2 must be parsed for a specific manifest, and the 2nd call includes the layers. If a digest is not...
python
{ "resource": "" }
q272473
get_manifest
test
def get_manifest(self, repo_name, digest=None, version="v1"): ''' get_manifest should return an image manifest for a particular repo and tag. The image details are extracted when the client is generated. Parameters ========== repo_name: reference to the <username>/<reposi...
python
{ "resource": "" }
q272474
get_download_cache
test
def get_download_cache(self, destination, subfolder='docker'): '''determine the user preference for atomic download of layers. If the user has set a singularity cache directory, honor it. Otherwise, use the Singularity default. ''' # First priority after user specification is Singularity Cache...
python
{ "resource": "" }
q272475
extract_env
test
def extract_env(self): '''extract the environment from the manifest, or return None. Used by functions env_extract_image, and env_extract_tar ''' environ = self._get_config('Env') if environ is not None: if not isinstance(environ, list): environ = [environ] lines = []...
python
{ "resource": "" }
q272476
Client._update_base
test
def _update_base(self): '''update the base, including the URL for GitLab and the API endpoint. ''' self.base = self._get_and_update_setting('SREGISTRY_GITLAB_BASE', "https://gitlab.com/") self.api_base = "%s/api/v4" % self.base.strip('/') ...
python
{ "resource": "" }
q272477
Client._update_secrets
test
def _update_secrets(self): '''update secrets will update metadata needed for pull and search ''' self.token = self._required_get_and_update('SREGISTRY_GITLAB_TOKEN') self.headers["Private-Token"] = self.token
python
{ "resource": "" }
q272478
Client._get_metadata
test
def _get_metadata(self): '''since the user needs a job id and other parameters, save this for them. ''' metadata = {'SREGISTRY_GITLAB_FOLDER': self.artifacts, 'api_base': self.api_base, 'SREGISTRY_GITLAB_BASE': self.base, 'SR...
python
{ "resource": "" }
q272479
get_settings
test
def get_settings(self, client_name=None): '''get all settings, either for a particular client if a name is provided, or across clients. Parameters ========== client_name: the client name to return settings for (optional) ''' settings = read_client_secrets() if client_name i...
python
{ "resource": "" }
q272480
required_get_and_update
test
def required_get_and_update(self, name, default=None): '''a wrapper to get_and_update, but if not successful, will print an error and exit. ''' setting = self._get_and_update_setting(name, default=None) if setting in [None, ""]: bot.exit('You must export %s' % name) return setting
python
{ "resource": "" }
q272481
update_setting
test
def update_setting(self, name, value): '''Just update a setting, doesn't need to be returned. ''' if value is not None: updates = {name : value} update_client_secrets(backend=self.client_name, updates=updates)
python
{ "resource": "" }
q272482
authorize
test
def authorize(self, names, payload=None, request_type="push"): '''Authorize a client based on encrypting the payload with the client token, which should be matched on the receiving server''' if self.secrets is not None: if "registry" in self.secrets: # Use the payload to generate a...
python
{ "resource": "" }
q272483
list_builders
test
def list_builders(self, project=None, zone='us-west1-a'): '''list builders, or instances for the project. They should start with sregistry-builder Parameters ========== project: specify a project, will default to environment first zone: the zone to use, defaults to us-west1-a if ...
python
{ "resource": "" }
q272484
load_templates
test
def load_templates(self, name): '''load a particular template based on a name. We look for a name IN data, so the query name can be a partial string of the full name. Parameters ========== name: the name of a template to look up ''' configs = self._get_templates() templates ...
python
{ "resource": "" }
q272485
get_ipaddress
test
def get_ipaddress(self, name, retries=3, delay=3): '''get the ip_address of an inserted instance. Will try three times with delay to give the instance time to start up. Parameters ========== name: the name of the instance to get the ip address for. retries: the number of retries ...
python
{ "resource": "" }
q272486
run_build
test
def run_build(self, config): '''run a build, meaning inserting an instance. Retry if there is failure Parameters ========== config: the configuration dictionary generated by setup_build ''' project = self._get_project() zone = self._get_zone() bot.custom(prefix='INSTANCE', me...
python
{ "resource": "" }
q272487
list_containers
test
def list_containers(self): '''return a list of containers, determined by finding the metadata field "type" with value "container." We alert the user to no containers if results is empty, and exit {'metadata': {'items': [ {'key': 't...
python
{ "resource": "" }
q272488
search_all
test
def search_all(self): '''a "list all" search that doesn't require a query. Here we return to the user all objects that have custom metadata value of "container" IMPORTANT: the upload function adds this metadata. For a container to be found by the client, it must have the type as container in m...
python
{ "resource": "" }
q272489
main
test
def main(args,parser,subparser): '''the list command corresponds with listing images for an external resource. This is different from listing images that are local to the database, which should be done with "images" ''' from sregistry.main import get_client cli = get_client(quiet=args.quie...
python
{ "resource": "" }
q272490
main
test
def main(args, parser, subparser): '''sharing an image means sending a remote share from an image you control to a contact, usually an email. ''' from sregistry.main import get_client images = args.image if not isinstance(images,list): images = [images] for image in images: ...
python
{ "resource": "" }
q272491
init_db
test
def init_db(self, db_path): '''initialize the database, with the default database path or custom of the format sqlite:////scif/data/expfactory.db The custom path can be set with the environment variable SREGISTRY_DATABASE when a user creates the client, we must initialize this db the database s...
python
{ "resource": "" }
q272492
get_build_template
test
def get_build_template(): '''get default build template. ''' base = get_installdir() name = "%s/main/templates/build/singularity-cloudbuild.json" % base if os.path.exists(name): bot.debug("Found template %s" %name) return read_json(name) bot.warning("Template %s not found." % n...
python
{ "resource": "" }
q272493
search
test
def search(self, query=None, args=None): '''query will show images determined by the extension of img or simg. Parameters ========== query: the container name (path) or uri to search for args.endpoint: can be an endpoint id and optional path, e.g.: --endpoint 6881a...
python
{ "resource": "" }
q272494
list_endpoints
test
def list_endpoints(self, query=None): '''list all endpoints, providing a list of endpoints to the user to better filter the search. This function takes no arguments, as the user has not provided an endpoint id or query. ''' bot.info('Please select an endpoint id to query from') endpoints...
python
{ "resource": "" }
q272495
list_endpoint
test
def list_endpoint(self, endpoint, query=None): '''An endpoint is required here to list files within. Optionally, we can take a path relative to the endpoint root. Parameters ========== endpoint: a single endpoint ID or an endpoint id and relative path. If no path is pro...
python
{ "resource": "" }
q272496
share
test
def share(self, query, share_to=None): '''share will use the client to get a shareable link for an image of choice. the functions returns a url of choice to send to a recipient. ''' names = parse_image_name(remove_uri(query)) # Dropbox path is the path in storage with a slash dropbox_path =...
python
{ "resource": "" }
q272497
read_client_secrets
test
def read_client_secrets(): '''for private or protected registries, a client secrets file is required to be located at .sregistry. If no secrets are found, we use default of Singularity Hub, and return a dummy secrets. ''' client_secrets = _default_client_secrets() # If token file not prov...
python
{ "resource": "" }
q272498
Client._get_services
test
def _get_services(self, version='v1'): '''get version 1 of the google compute and storage service Parameters ========== version: version to use (default is v1) ''' self._bucket_service = storage.Client() creds = GoogleCredentials.get_application_default() ...
python
{ "resource": "" }
q272499
delete_object
test
def delete_object(service, bucket_name, object_name): '''delete object will delete a file from a bucket Parameters ========== storage_service: the service obtained with get_storage_service bucket_name: the name of the bucket object_name: the "name" parameter of the object. '...
python
{ "resource": "" }