_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q248200
TemplateStore.get_stored_hash
train
def get_stored_hash(self, temp_ver): """ Retrieves the hash for the given template version from the store Args: temp_ver (TemplateVersion): template version to retrieve the hash for Returns:
python
{ "resource": "" }
q248201
LagoAnsible.get_inventory
train
def get_inventory(self, keys=None): """ Create an Ansible inventory based on python dicts and lists. The returned value is a dict in which every key represents a group and every value is a list of entries for that group. Args: keys (list of str): Path to the keys tha...
python
{ "resource": "" }
q248202
LagoAnsible.get_key
train
def get_key(key, data_structure): """ Helper method for extracting values from a nested data structure. Args: key (str): The path to the vales (a series of keys and indexes separated by '/') data_structure (dict or list): The data structure from which the...
python
{ "resource": "" }
q248203
LagoAnsible.get_inventory_temp_file
train
def get_inventory_temp_file(self, keys=None): """ Context manager which returns the inventory written on a tempfile. The tempfile will be deleted as soon as this context manger ends. Args: keys (list of str): Path to the keys that will be used to create group...
python
{ "resource": "" }
q248204
exit_handler
train
def exit_handler(signum, frame): """ Catch SIGTERM and SIGHUP and call "sys.exit" which raises "SystemExit" exception. This will trigger all the cleanup code defined in ContextManagers and "finally" statements. For more details about the arguments see "signal" documentation. Args: ...
python
{ "resource": "" }
q248205
Network.start
train
def start(self, attempts=5, timeout=2): """ Start the network, will check if the network is active ``attempts`` times, waiting ``timeout`` between each attempt. Args: attempts (int): number of attempts to check the network is active timeout (int): timeout for ea...
python
{ "resource": "" }
q248206
CPU.generate_cpu_xml
train
def generate_cpu_xml(self): """ Get CPU XML Returns: lxml.etree.Element: cpu node """ if self.cpu_custom: return self.generate_custom( cpu=self.cpu,
python
{ "resource": "" }
q248207
CPU.generate_host_passthrough
train
def generate_host_passthrough(self, vcpu_num): """ Generate host-passthrough XML cpu node Args: vcpu_num(str): number of virtual CPUs Returns: lxml.etree.Element: CPU XML node """ cpu =
python
{ "resource": "" }
q248208
CPU.generate_custom
train
def generate_custom(self, cpu, vcpu_num, fill_topology): """ Generate custom CPU model. This method attempts to convert the dict to XML, as defined by ``xmltodict.unparse`` method. Args: cpu(dict): CPU spec vcpu_num(int): number of virtual cpus fill_t...
python
{ "resource": "" }
q248209
CPU.generate_exact
train
def generate_exact(self, model, vcpu_num, host_cpu): """ Generate exact CPU model with nested virtualization CPU feature. Args: model(str): libvirt supported CPU model vcpu_num(int): number of virtual cpus host_cpu(lxml.etree.Element): the host CPU model ...
python
{ "resource": "" }
q248210
CPU.generate_feature
train
def generate_feature(self, name, policy='require'): """ Generate CPU feature element Args: name(str): feature name policy(str): libvirt feature policy Returns:
python
{ "resource": "" }
q248211
LibvirtCPU.get_cpu_vendor
train
def get_cpu_vendor(cls, family, arch='x86'): """ Get CPU vendor, if vendor is not available will return 'generic' Args: family(str): CPU family arch(str): CPU arch Returns: str: CPU vendor if found otherwise 'generic'
python
{ "resource": "" }
q248212
LibvirtCPU.get_cpu_props
train
def get_cpu_props(cls, family, arch='x86'): """ Get CPU info XML Args: family(str): CPU family arch(str): CPU arch Returns: lxml.etree.Element: CPU xml
python
{ "resource": "" }
q248213
LibvirtCPU.get_cpus_by_arch
train
def get_cpus_by_arch(cls, arch): """ Get all CPUs info by arch Args: arch(str): CPU architecture Returns: lxml.etree.element: CPUs by arch XML Raises: :exc:`~LagoException`: If no such ARCH is found """ with open('/usr/share...
python
{ "resource": "" }
q248214
log_task
train
def log_task( task, logger=logging, level='info', propagate_fail=True, uuid=None ): """ Parameterized decorator to wrap a function in a log task Example: >>> @log_task('mytask') ... def do_something(): ... pass """ def decorator(func): @wraps(func) d...
python
{ "resource": "" }
q248215
start_log_task
train
def start_log_task(task, logger=logging, level='info'): """ Starts a log task Args: task (str): name of the log task to start logger (logging.Logger): logger to use
python
{ "resource": "" }
q248216
end_log_task
train
def end_log_task(task, logger=logging, level='info'): """ Ends a log task Args: task (str): name of the log task to end logger (logging.Logger): logger to use
python
{ "resource": "" }
q248217
hide_stevedore_logs
train
def hide_stevedore_logs(): """ Hides the logs of stevedore, this function was added in order to support older versions of stevedore We are using the NullHandler in order to get rid from 'No handlers could be found for logger...' msg Returns: None """
python
{ "resource": "" }
q248218
ColorFormatter.colored
train
def colored(cls, color, message): """ Small function to wrap a string around a color Args: color (str): name of the color to wrap the string with, must be one of the class properties
python
{ "resource": "" }
q248219
ColorFormatter.format
train
def format(self, record): """ Adds colors to a log record and formats it with the default Args: record (logging.LogRecord): log record to format Returns: str: The colored and formatted record string """ level = record.levelno if level >=...
python
{ "resource": "" }
q248220
TaskHandler.handle_new_task
train
def handle_new_task(self, task_name, record): """ Do everything needed when a task is starting Params: task_name (str): name of the task that is starting record (logging.LogRecord): log record with all the info Returns: None
python
{ "resource": "" }
q248221
TaskHandler.mark_parent_tasks_as_failed
train
def mark_parent_tasks_as_failed(self, task_name, flush_logs=False): """ Marks all the parent tasks as failed Args: task_name (str): Name of the child task flush_logs (bool): If ``True`` will discard all the logs form parent tasks Returns: ...
python
{ "resource": "" }
q248222
TaskHandler.close_children_tasks
train
def close_children_tasks(self, parent_task_name): """ Closes all the children tasks that were open Args: parent_task_name (str): Name of the parent task Returns: None """ if parent_task_name not in self.tasks: return while se...
python
{ "resource": "" }
q248223
TaskHandler.handle_closed_task
train
def handle_closed_task(self, task_name, record): """ Do everything needed when a task is closed Params: task_name (str): name of the task that is finishing record (logging.LogRecord): log record with all the info Returns: None """ if ...
python
{ "resource": "" }
q248224
TaskHandler.handle_error
train
def handle_error(self): """ Handles an error log record that should be shown Returns: None """ if not self.tasks: return # All the parents inherit the failure self.mark_parent_tasks_as_failed( self.cur_task, flush_...
python
{ "resource": "" }
q248225
TaskHandler.emit
train
def emit(self, record): """ Handle the given record, this is the entry point from the python logging facility Params: record (logging.LogRecord): log record to handle Returns: None """ record.task = self.cur_task if record.leveln...
python
{ "resource": "" }
q248226
SubnetStore._validate_lease_dir
train
def _validate_lease_dir(self): """ Validate that the directory used by this store exist, otherwise create it. """ try: if not os.path.isdir(self.path): os.makedirs(self.path)
python
{ "resource": "" }
q248227
SubnetStore.acquire
train
def acquire(self, uuid_path, subnet=None): """ Lease a free subnet for the given uuid path. If subnet is given, try to lease that subnet, otherwise try to lease a free subnet. Args: uuid_path (str): Path to the uuid file of a :class:`lago.Prefix` subnet (...
python
{ "resource": "" }
q248228
SubnetStore._acquire
train
def _acquire(self, uuid_path): """ Lease a free network for the given uuid path Args: uuid_path (str): Path to the uuid file of a :class:`lago.Prefix` Returns: netaddr.IPNetwork: Which represents the selected subnet Raises:
python
{ "resource": "" }
q248229
SubnetStore._acquire_given_subnet
train
def _acquire_given_subnet(self, uuid_path, subnet): """ Try to create a lease for subnet Args: uuid_path (str): Path to the uuid file of a :class:`lago.Prefix` subnet (str): dotted ipv4 subnet (for example ```192.168.200.0```)
python
{ "resource": "" }
q248230
SubnetStore._lease_valid
train
def _lease_valid(self, lease): """ Check if the given lease exist and still has a prefix that owns it. If the lease exist but its prefix isn't, remove the lease from this store. Args: lease (lago.subnet_lease.Lease): Object representation of the lease...
python
{ "resource": "" }
q248231
SubnetStore._take_lease
train
def _take_lease(self, lease, uuid_path, safe=True): """ Persist the given lease to the store and make the prefix in uuid_path his owner Args: lease(lago.subnet_lease.Lease): Object representation of the lease uuid_path (str): Path to the prefix uuid s...
python
{ "resource": "" }
q248232
SubnetStore.list_leases
train
def list_leases(self, uuid=None): """ List current subnet leases Args: uuid(str): Filter the leases by uuid Returns: list of :class:~Lease: current leases """ try: lease_files = os.listdir(self.path) except OSError as e: ...
python
{ "resource": "" }
q248233
SubnetStore.release
train
def release(self, subnets): """ Free the lease of the given subnets Args: subnets (list of str or netaddr.IPAddress): dotted ipv4 subnet in CIDR notation (for example ```192.168.200.0/24```) or IPAddress object. Raises: LagoSubnet...
python
{ "resource": "" }
q248234
SubnetStore._release
train
def _release(self, lease): """ Free the given lease Args: lease (lago.subnet_lease.Lease): The lease
python
{ "resource": "" }
q248235
SubnetStore._lease_owned
train
def _lease_owned(self, lease, current_uuid_path): """ Checks if the given lease is owned by the prefix whose uuid is in the given path Note: The prefix must be also in the same path it was when it took the lease Args: path (str): Path to the ...
python
{ "resource": "" }
q248236
_run_command
train
def _run_command( command, input_data=None, stdin=None, out_pipe=subprocess.PIPE, err_pipe=subprocess.PIPE, env=None, uuid=None, **kwargs ): """ Runs a command Args: command(list of str): args of the command to execute, including the command itself as com...
python
{ "resource": "" }
q248237
run_command
train
def run_command( command, input_data=None, out_pipe=subprocess.PIPE, err_pipe=subprocess.PIPE, env=None, **kwargs ): """ Runs a command non-interactively Args: command(list of str): args of the command to execute, including the command itself as command[0] as `['...
python
{ "resource": "" }
q248238
run_interactive_command
train
def run_interactive_command(command, env=None, **kwargs): """ Runs a command interactively, reusing the current stdin, stdout and stderr Args: command(list of str): args of the command to execute, including the command itself as command[0] as `['ls', '-l']` env(dict of str:str):...
python
{ "resource": "" }
q248239
deepcopy
train
def deepcopy(original_obj): """ Creates a deep copy of an object with no crossed referenced lists or dicts, useful when loading from yaml as anchors generate those cross-referenced dicts and lists Args: original_obj(object): Object to deep copy Return: object: deep copy of the ...
python
{ "resource": "" }
q248240
load_virt_stream
train
def load_virt_stream(virt_fd): """ Loads the given conf stream into a dict, trying different formats if needed Args: virt_fd (str): file like objcect with the virt config to load Returns: dict: Loaded virt config """ try:
python
{ "resource": "" }
q248241
get_qemu_info
train
def get_qemu_info(path, backing_chain=False, fail_on_error=True): """ Get info on a given qemu disk Args: path(str): Path to the required disk backing_chain(boo): if true, include also info about the image predecessors. Return: object: if backing_chain == True then a lis...
python
{ "resource": "" }
q248242
get_hash
train
def get_hash(file_path, checksum='sha1'): """ Generate a hash for the given file Args: file_path (str): Path to the file to generate the hash for checksum (str): hash to apply, one of the supported by hashlib, for example sha1 or sha512 Returns: str: hash for that f...
python
{ "resource": "" }
q248243
ver_cmp
train
def ver_cmp(ver1, ver2): """ Compare lago versions Args: ver1(str): version string ver2(str): version string
python
{ "resource": "" }
q248244
Flock.acquire
train
def acquire(self): """Acquire the lock Raises: IOError: if the call to flock fails """
python
{ "resource": "" }
q248245
FlatOutFormatPlugin.format
train
def format(self, info_dict, delimiter='/'): """ This formatter will take a data structure that represent a tree and will print all the paths from the root to the leaves in our case it will print each value and the keys that needed to get to it, for example: vm0:...
python
{ "resource": "" }
q248246
workdir_loaded
train
def workdir_loaded(func): """ Decorator to make sure that the workdir is loaded when calling the decorated function """ @wraps(func) def decorator(workdir, *args, **kwargs):
python
{ "resource": "" }
q248247
Workdir.initialize
train
def initialize(self, prefix_name='default', *args, **kwargs): """ Initializes a workdir by adding a new prefix to the workdir. Args: prefix_name(str): Name of the new prefix to add *args: args to pass along to the prefix constructor *kwargs: kwargs to pass al...
python
{ "resource": "" }
q248248
Workdir.load
train
def load(self): """ Loads the prefixes that are available is the workdir Returns: None Raises: MalformedWorkdir: if the wordir is malformed """ if self.loaded: LOGGER.debug('Already loaded') return try: ...
python
{ "resource": "" }
q248249
Workdir._update_current
train
def _update_current(self): """ Makes sure that a current is set """ if not self.current or self.current not in self.prefixes: if 'default' in self.prefixes: selected_current = 'default' elif self.prefixes: selected_current = sorted(...
python
{ "resource": "" }
q248250
Workdir._set_current
train
def _set_current(self, new_current): """ Change the current default prefix, for internal usage Args: new_current(str): Name of the new current prefix, it must already exist Returns: None Raises: PrefixNotFound: if the given p...
python
{ "resource": "" }
q248251
Workdir.add_prefix
train
def add_prefix(self, name, *args, **kwargs): """ Adds a new prefix to the workdir. Args: name(str): Name of the new prefix to add *args: args to pass along to the prefix constructor *kwargs: kwargs to pass along to the prefix constructor Returns: ...
python
{ "resource": "" }
q248252
Workdir.get_prefix
train
def get_prefix(self, name): """ Retrieve a prefix, resolving the current one if needed Args: name(str): name of the prefix to retrieve, or current to get the current one Returns: self.prefix_class: instance of the prefix with the given name ...
python
{ "resource": "" }
q248253
Workdir.destroy
train
def destroy(self, prefix_names=None): """ Destroy all the given prefixes and remove any left files if no more prefixes are left Args: prefix_names(list of str): list of prefix names to destroy, if None passed (default) will destroy all of them """ ...
python
{ "resource": "" }
q248254
Workdir.is_workdir
train
def is_workdir(cls, path): """ Check if the given path is a workdir Args: path(str): Path to check Return: bool: True if the given path is a workdir
python
{ "resource": "" }
q248255
Workdir.cleanup
train
def cleanup(self): """ Attempt to set a new current symlink if it is broken. If no other prefixes exist and the workdir is empty, try to delete the entire workdir. Raises: :exc:`~MalformedWorkdir`: if no prefixes were found, but the workdir is not emp...
python
{ "resource": "" }
q248256
_load_plugins
train
def _load_plugins(namespace, instantiate=True): """ Loads all the plugins for the given namespace Args: namespace(str): Namespace string, as in the setuptools entry_points instantiate(bool): If true, will instantiate the plugins too Returns: dict of str, object: Returns the lis...
python
{ "resource": "" }
q248257
Prefix.metadata
train
def metadata(self): """ Retrieve the metadata info for this prefix Returns: dict: metadata info """ if self._metadata is None: try: with open(self.paths.metadata()) as metadata_fd:
python
{ "resource": "" }
q248258
Prefix._save_metadata
train
def _save_metadata(self): """ Write this prefix metadata to disk Returns:
python
{ "resource": "" }
q248259
Prefix.save
train
def save(self): """ Save this prefix to persistent storage Returns: None
python
{ "resource": "" }
q248260
Prefix._create_ssh_keys
train
def _create_ssh_keys(self): """ Generate a pair of ssh keys for this prefix Returns: None Raises: RuntimeError: if it fails to create the keys """ ret, _, _ = utils.run_command( [ 'ssh-keygen', '-t', ...
python
{ "resource": "" }
q248261
Prefix.cleanup
train
def cleanup(self): """ Stops any running entities in the prefix and uninitializes it, usually you want to do this if you are going to remove the prefix afterwards Returns: None """
python
{ "resource": "" }
q248262
Prefix._init_net_specs
train
def _init_net_specs(conf): """ Given a configuration specification, initializes all the net definitions in it so they can be used comfortably Args: conf (dict): Configuration specification Returns: dict: the adapted new conf
python
{ "resource": "" }
q248263
Prefix._allocate_subnets
train
def _allocate_subnets(self, conf): """ Allocate all the subnets needed by the given configuration spec Args: conf (dict): Configuration spec where to get the nets definitions from Returns: tuple(list, dict): allocated subnets and modified conf ...
python
{ "resource": "" }
q248264
Prefix._select_mgmt_networks
train
def _select_mgmt_networks(self, conf): """ Select management networks. If no management network is found, it will mark the first network found by sorted the network lists. Also adding default DNS domain, if none is set. Args: conf(spec): spec """ ne...
python
{ "resource": "" }
q248265
Prefix._register_preallocated_ips
train
def _register_preallocated_ips(self, conf): """ Parse all the domains in the given conf and preallocate all their ips into the networks mappings, raising exception on duplicated ips or ips out of the allowed ranges See Also: :mod:`lago.subnet_lease` Args: ...
python
{ "resource": "" }
q248266
Prefix._allocate_ips_to_nics
train
def _allocate_ips_to_nics(self, conf): """ For all the nics of all the domains in the conf that have dynamic ip, allocate one and addit to the network mapping Args: conf (dict): Configuration spec to extract the domains from Returns: None """ ...
python
{ "resource": "" }
q248267
Prefix._set_mtu_to_nics
train
def _set_mtu_to_nics(self, conf): """ For all the nics of all the domains in the conf that have MTU set, save the MTU on the NIC definition. Args: conf (dict): Configuration spec to extract the domains from
python
{ "resource": "" }
q248268
Prefix._config_net_topology
train
def _config_net_topology(self, conf): """ Initialize and populate all the network related elements, like reserving ips and populating network specs of the given confiiguration spec Args: conf (dict): Configuration spec to initalize Returns: None ...
python
{ "resource": "" }
q248269
Prefix._validate_netconfig
train
def _validate_netconfig(self, conf): """ Validate network configuration Args: conf(dict): spec Returns: None Raises: :exc:`~lago.utils.LagoInitException`: If a VM has more than one management network configured, or a network whi...
python
{ "resource": "" }
q248270
Prefix._create_disk
train
def _create_disk( self, name, spec, template_repo=None, template_store=None, ): """ Creates a disc with the given name from the given repo or store Args: name (str): Name of the domain to create the disk for spec (dict): Specif...
python
{ "resource": "" }
q248271
Prefix._ova_to_spec
train
def _ova_to_spec(self, filename): """ Retrieve the given ova and makes a template of it. Creates a disk from network provided ova. Calculates the needed memory from the ovf. The disk will be cached in the template repo Args: filename(str): the url to retrive ...
python
{ "resource": "" }
q248272
Prefix._use_prototype
train
def _use_prototype(self, spec, prototypes): """ Populates the given spec with the values of it's declared prototype Args: spec (dict): spec to update prototypes (dict): Configuration spec containing the prototypes Returns: dict: updated spec
python
{ "resource": "" }
q248273
Prefix.fetch_url
train
def fetch_url(self, url): """ Retrieves the given url to the prefix Args: url(str): Url to retrieve Returns: str: path to the downloaded file """ url_path = urlparse.urlsplit(url).path dst_path = os.path.basename(url_path)
python
{ "resource": "" }
q248274
Prefix.export_vms
train
def export_vms( self, vms_names=None, standalone=False, export_dir='.', compress=False, init_file_name='LagoInitFile', out_format=YAMLOutFormatPlugin(), collect_only=False, with_threads=True, ): """ Export vm images disks and in...
python
{ "resource": "" }
q248275
Prefix.shutdown
train
def shutdown(self, vm_names=None, reboot=False): """ Shutdown this prefix Args: vm_names(list of str): List of the vms to shutdown
python
{ "resource": "" }
q248276
Prefix.virt_env
train
def virt_env(self): """ Getter for this instance's virt env, creates it if needed Returns: lago.virt.VirtEnv: virt env instance used by this prefix
python
{ "resource": "" }
q248277
Prefix.destroy
train
def destroy(self): """ Destroy this prefix, running any cleanups and removing any files inside it. """ subnets = ( str(net.gw()) for net in self.virt_env.get_nets().itervalues() )
python
{ "resource": "" }
q248278
Prefix.is_prefix
train
def is_prefix(cls, path): """ Check if a path is a valid prefix Args: path(str): path to be checked Returns: bool: True if the given path is a prefix
python
{ "resource": "" }
q248279
Prefix._get_scripts
train
def _get_scripts(self, host_metadata): """ Temporary method to retrieve the host scripts TODO: remove once the "ovirt-scripts" option gets deprecated Args: host_metadata(dict): host metadata to retrieve the scripts for Returns: list: deploy ...
python
{ "resource": "" }
q248280
Prefix._set_scripts
train
def _set_scripts(self, host_metadata, scripts): """ Temporary method to set the host scripts TODO: remove once the "ovirt-scripts" option gets deprecated Args: host_metadata(dict): host metadata to set scripts in Returns: dict: the updated m...
python
{ "resource": "" }
q248281
Prefix._copy_deploy_scripts_for_hosts
train
def _copy_deploy_scripts_for_hosts(self, domains): """ Copy the deploy scripts for all the domains into the prefix scripts dir Args: domains(dict): spec with the domains info as when loaded from the initfile Returns: None """ with...
python
{ "resource": "" }
q248282
Prefix._copy_delpoy_scripts
train
def _copy_delpoy_scripts(self, scripts): """ Copy the given deploy scripts to the scripts dir in the prefix Args: scripts(list of str): list of paths of the scripts to copy to the prefix Returns: list of str: list with the paths to the copied scr...
python
{ "resource": "" }
q248283
ConfigLoad.update_args
train
def update_args(self, args): """Update config dictionary with parsed args, as resolved by argparse. Only root positional arguments that already exist will overridden. Args: args (namespace): args parsed by argparse
python
{ "resource": "" }
q248284
ConfigLoad.update_parser
train
def update_parser(self, parser): """Update config dictionary with declared arguments in an argparse.parser New variables will be created, and existing ones overridden. Args: parser (argparse.ArgumentParser): parser to read variables from """ self._parser = parser ...
python
{ "resource": "" }
q248285
Client._request_submit
train
def _request_submit(self, func, **kwargs): """A helper function that will wrap any requests we make. :param func: a function reference to the requests method to invoke :param kwargs: any extra arguments that requests.request takes :type func: (url: Any, data: Any, json: Any, kwargs: Di...
python
{ "resource": "" }
q248286
Client.add_records
train
def add_records(self, domain, records): """Adds the specified DNS records to a domain. :param domain: the domain to add the records to :param records: the records to add """ url = self.API_TEMPLATE + self.RECORDS.format(domain=domain) self._patch(url, json=records)
python
{ "resource": "" }
q248287
Client.get_domain_info
train
def get_domain_info(self, domain): """Get the GoDaddy supplied information about a specific domain. :param domain: The domain to obtain info about. :type domain: str :return A JSON string representing the domain information
python
{ "resource": "" }
q248288
Client.get_domains
train
def get_domains(self): """Returns a list of domains for the authenticated user. """ url = self.API_TEMPLATE + self.DOMAINS data = self._get_json_from_response(url) domains = list() for item in data:
python
{ "resource": "" }
q248289
Client.replace_records
train
def replace_records(self, domain, records, record_type=None, name=None): """This will replace all records at the domain. Record type and record name can be provided to filter which records to replace. :param domain: the domain to replace records at :param records: the records you will ...
python
{ "resource": "" }
q248290
Client.update_record
train
def update_record(self, domain, record, record_type=None, name=None): """Call to GoDaddy API to update a single DNS record :param name: only required if the record is None (deletion) :param record_type: only required if the record is None (deletion) :param domain: the domain where the D...
python
{ "resource": "" }
q248291
parse_ports
train
def parse_ports(ports_text): """Parse ports text e.g. ports_text = "12345,13000-15000,20000-30000" """ ports_set = set() for bit in ports_text.split(','): if '-' in bit: low, high = bit.split('-', 1)
python
{ "resource": "" }
q248292
make_server
train
def make_server( server_class, handler_class, authorizer_class, filesystem_class, host_port, file_access_user=None, **handler_options): """make server instance :host_port: (host, port) :file_access_user: 'spam' handler_options: * timeout * passive_ports * masquerade_...
python
{ "resource": "" }
q248293
StoragePatch.apply
train
def apply(cls, fs): """replace bound methods of fs. """ logger.debug( 'Patching %s with %s.', fs.__class__.__name__, cls.__name__) fs._patch = cls for method_name in cls.patch_methods: # if fs hasn't method, raise AttributeError. origin = getat...
python
{ "resource": "" }
q248294
S3Boto3StoragePatch._exists
train
def _exists(self, path): """S3 directory is not S3Ojbect. """ if path.endswith('/'):
python
{ "resource": "" }
q248295
StorageFS.apply_patch
train
def apply_patch(self): """apply adjustment patch for storage """ patch
python
{ "resource": "" }
q248296
FTPAccountAuthorizer.has_user
train
def has_user(self, username): """return True if exists user. """ return self.model.objects.filter(
python
{ "resource": "" }
q248297
FTPAccountAuthorizer.get_account
train
def get_account(self, username): """return user by username. """ try: account = self.model.objects.get(
python
{ "resource": "" }
q248298
FTPAccountAuthorizer.validate_authentication
train
def validate_authentication(self, username, password, handler): """authenticate user with password """ user = authenticate(
python
{ "resource": "" }
q248299
FTPAccountAuthorizer.get_msg_login
train
def get_msg_login(self, username): """message for welcome. """ account = self.get_account(username) if account:
python
{ "resource": "" }