_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q56200
_add_get_tracking_url
train
def _add_get_tracking_url(cls): """ Add a method to get the tracking url of an object. """ def get_tracking_url(self): """ return url to tracking view in admin panel """ url = reverse('admin:tracking_fields_trackingevent_changelist') object_id = '{0}%3A{1}'.format( ContentTyp...
python
{ "resource": "" }
q56201
track
train
def track(*fields): """ Decorator used to track changes on Model's fields. :Example: >>> @track('name') ... class Human(models.Model): ... name = models.CharField(max_length=30) """ def inner(cls): _track_class(cls, fields) _add_get_tracking_url(cls) ...
python
{ "resource": "" }
q56202
indent
train
def indent(value, n=2, character=' '): """ Indent a value by `n` `character`s :param value: string to indent :param n: number of characters to indent by :param character: character to indent with """ prefix = n * character return '\n'.join(prefix + line for line in value.splitlines())
python
{ "resource": "" }
q56203
Jaide.check_instance
train
def check_instance(function): """ Wrapper that tests the type of _session. Purpose: This decorator function is used by all functions within | the Jaide class that interact with a device to ensure the | proper session type is in use. If it is not, it will | atte...
python
{ "resource": "" }
q56204
Jaide.commit
train
def commit(self, commands="", confirmed=None, comment=None, at_time=None, synchronize=False, req_format='text'): """ Perform a commit operation. Purpose: Executes a commit operation. All parameters are optional. | commit confirm and commit at are mutually exclusive. All ...
python
{ "resource": "" }
q56205
Jaide.commit_check
train
def commit_check(self, commands="", req_format="text"): """ Execute a commit check operation. Purpose: This method will take in string of multiple commands, | and perform and 'commit check' on the device to ensure | the commands are syntactically correct. The response can ...
python
{ "resource": "" }
q56206
Jaide.compare_config
train
def compare_config(self, commands="", req_format="text"): """ Execute a 'show | compare' against the specified commands. Purpose: This method will take in string of multiple commands, | and perform and 'show | compare' on the device to show the | differences between the ac...
python
{ "resource": "" }
q56207
Jaide.connect
train
def connect(self): """ Establish a connection to the device. Purpose: This method is used to make a connection to the junos | device. The internal property conn_type is what | determines the type of connection we make to the device. | - 'paramiko' is used fo...
python
{ "resource": "" }
q56208
Jaide._copy_status
train
def _copy_status(self, filename, size, sent): """ Echo status of an SCP operation. Purpose: Callback function for an SCP operation. Used to show | the progress of an actively running copy. This directly | prints to stdout, one line for each file as it's copied. ...
python
{ "resource": "" }
q56209
Jaide.device_info
train
def device_info(self): """ Pull basic device information. Purpose: This function grabs the hostname, model, running version, and | serial number of the device. @returns: The output that should be shown to the user. @rtype: str """ # get hostname, model, a...
python
{ "resource": "" }
q56210
Jaide.diff_config
train
def diff_config(self, second_host, mode='stanza'): """ Generate configuration differences with a second device. Purpose: Open a second ncclient.manager.Manager with second_host, and | and pull the configuration from it. We then use difflib to | get the delta between the tw...
python
{ "resource": "" }
q56211
Jaide._error_parse
train
def _error_parse(self, interface, face): """ Parse the extensive xml output of an interface and yield errors. Purpose: Takes the xml output of 'show interfaces extensive' for a | given interface and yields the error types that have a | significant number of errors. ...
python
{ "resource": "" }
q56212
Jaide.health_check
train
def health_check(self): """ Pull health and alarm information from the device. Purpose: Grab the cpu/mem usage, system/chassis alarms, top 5 | processes, and states if the primary/backup partitions are on | different versions. @returns: The output that should be s...
python
{ "resource": "" }
q56213
Jaide.interface_errors
train
def interface_errors(self): """ Parse 'show interfaces extensive' and return interfaces with errors. Purpose: This function is called for the -e flag. It will let the user | know if there are any interfaces with errors, and what those | interfaces are. @returns: T...
python
{ "resource": "" }
q56214
Jaide.lock
train
def lock(self): """ Lock the candidate config. Requires ncclient.manager.Manager. """ if isinstance(self._session, manager.Manager): self._session.lock()
python
{ "resource": "" }
q56215
Jaide.op_cmd
train
def op_cmd(self, command, req_format='text', xpath_expr=""): """ Execute an operational mode command. Purpose: Used to send an operational mode command to the connected | device. This requires and uses a paramiko.SSHClient() as | the handler so that we can easily pass and ...
python
{ "resource": "" }
q56216
Jaide.unlock
train
def unlock(self): """ Unlock the candidate config. Purpose: Unlocks the candidate configuration, so that other people can | edit the device. Requires the _session private variable to be | a type of a ncclient.manager.Manager. """ if isinstance(self._session...
python
{ "resource": "" }
q56217
intercept
train
def intercept(obj, methodname, wrapper): """ Wraps an existing method on an object with the provided generator, which will be "sent" the value when it yields control. :: >>> def ensure_primary_key_is_set(): ... assert model.pk is None ... saved = yield ... a...
python
{ "resource": "" }
q56218
_Weave.next
train
def next(self): """ Returns the next element or raises ``StopIteration`` if stopped. """ # need new iterable? if self.r == self.repeats: self.i = (self.i + 1) % self.lenght self.r = 0 self.r += 1 if self.stopping and self.i == 0 and self.r...
python
{ "resource": "" }
q56219
_NuMapTask.next
train
def next(self): """ Returns a result if availble within "timeout" else raises a ``TimeoutError`` exception. See documentation for ``NuMap.next``. """ return self.iterator.next(task=self.task, timeout=self.timeout, block=self.bl...
python
{ "resource": "" }
q56220
write_template
train
def write_template(fn, lang="python"): """ Write language-specific script template to file. Arguments: - fn(``string``) path to save the template to - lang('python', 'bash') which programming language """ with open(fn, "wb") as fh: if lang == "python": fh.wri...
python
{ "resource": "" }
q56221
script
train
def script(inbox, cfg): """ Execute arbitrary scripts. Arguments: - cfg(``dict``) script configuartion dictionary """ script_name = cfg["id"] script_id = str(abs(hash((cfg["id"],) + tuple(inbox[0].values()))))[0:8] # LOG.log(mp.DEFAULT, "@papy;script %s:%s started" % (script_na...
python
{ "resource": "" }
q56222
JobsService.edit
train
def edit(self, resource): """Edit a job. :param resource: :class:`jobs.Job <jobs.Job>` object :return: :class:`jobs.Job <jobs.Job>` object :rtype: jobs.Job """ schema = JobSchema(exclude=('id', 'status', 'options', 'package_name', 'config_name', 'device_name', 'result_id...
python
{ "resource": "" }
q56223
JobsService.launch
train
def launch(self, resource): """Launch a new job. :param resource: :class:`jobs.Job <jobs.Job>` object :return: :class:`jobs.Job <jobs.Job>` object :rtype: jobs.Job """ schema = JobSchema(exclude=('id', 'status', 'package_name', 'config_name', 'device_name', 'result_id', ...
python
{ "resource": "" }
q56224
JobsService.bulk_launch
train
def bulk_launch(self, jobs=None, filter=None, all=False): # pylint: disable=redefined-builtin """Bulk launch a set of jobs. :param jobs: :class:`jobs.Job <jobs.Job>` list :param filter: (optional) Filters to apply as a string list. :param all: (optional) Apply to all if bool `True`. ...
python
{ "resource": "" }
q56225
HighlightsService.get
train
def get(self, id, seq, line): # pylint: disable=invalid-name,redefined-builtin """Get a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param line: Line number in TestResult's logfile as an int. :return: :class:`highlights.Highlight <hig...
python
{ "resource": "" }
q56226
HighlightsService.create_or_edit
train
def create_or_edit(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Create or edit a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object ...
python
{ "resource": "" }
q56227
HighlightsService.create
train
def create(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Create a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class...
python
{ "resource": "" }
q56228
HighlightsService.edit
train
def edit(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Edit a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class:`hi...
python
{ "resource": "" }
q56229
HighlightsService.delete
train
def delete(self, id, seq, line): # pylint: disable=invalid-name,redefined-builtin """Delete a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param line: Line number in TestResult's logfile as an int. """ return self.service.dele...
python
{ "resource": "" }
q56230
post_ext_init
train
def post_ext_init(state): """Setup blueprint.""" app = state.app app.config.setdefault( 'OAUTHCLIENT_SITENAME', app.config.get('THEME_SITENAME', 'Invenio')) app.config.setdefault( 'OAUTHCLIENT_BASE_TEMPLATE', app.config.get('BASE_TEMPLATE', 'inveni...
python
{ "resource": "" }
q56231
login
train
def login(remote_app): """Send user to remote application for authentication.""" oauth = current_app.extensions['oauthlib.client'] if remote_app not in oauth.remote_apps: return abort(404) # Get redirect target in safe manner. next_param = get_safe_redirect_target(arg='next') # Redire...
python
{ "resource": "" }
q56232
authorized
train
def authorized(remote_app=None): """Authorized handler callback.""" if remote_app not in current_oauthclient.handlers: return abort(404) state_token = request.args.get('state') # Verify state parameter try: assert state_token # Checks authenticity and integrity of state and...
python
{ "resource": "" }
q56233
signup
train
def signup(remote_app): """Extra signup step.""" if remote_app not in current_oauthclient.signup_handlers: return abort(404) res = current_oauthclient.signup_handlers[remote_app]['view']() return abort(404) if res is None else res
python
{ "resource": "" }
q56234
disconnect
train
def disconnect(remote_app): """Disconnect user from remote application. Removes application as well as associated information. """ if remote_app not in current_oauthclient.disconnect_handlers: return abort(404) ret = current_oauthclient.disconnect_handlers[remote_app]() db.session.comm...
python
{ "resource": "" }
q56235
address_checksum
train
def address_checksum(address): """ Returns the checksum in bytes for an address in bytes """ address_bytes = address h = blake2b(digest_size=5) h.update(address_bytes) checksum = bytearray(h.digest()) checksum.reverse() return checksum
python
{ "resource": "" }
q56236
keypair_from_seed
train
def keypair_from_seed(seed, index=0): """ Generates a deterministic keypair from `seed` based on `index` :param seed: bytes value of seed :type seed: bytes :param index: offset from seed :type index: int :return: dict of the form: { 'private': private_key 'public': public_...
python
{ "resource": "" }
q56237
verify_signature
train
def verify_signature(message, signature, public_key): """ Verifies `signature` is correct for a `message` signed with `public_key` :param message: message to check :type message: bytes :param signature: signature to check :type signature: bytes :param public_key: public_key to check :...
python
{ "resource": "" }
q56238
sign_message
train
def sign_message(message, private_key, public_key=None): """ Signs a `message` using `private_key` and `public_key` .. warning:: Not safe to use with secret keys or secret data. See module docstring. This function should be used for testing only. :param message: the message to sign ...
python
{ "resource": "" }
q56239
SystemService.check_for_lounge_upgrade
train
def check_for_lounge_upgrade(self, email, password): """Check the CDRouter Support Lounge for eligible upgrades using your Support Lounge email & password. :param email: CDRouter Support Lounge email as a string. :param password: CDRouter Support Lounge password as a string. :re...
python
{ "resource": "" }
q56240
SystemService.lounge_upgrade
train
def lounge_upgrade(self, email, password, release_id): """Download & install an upgrade from the CDRouter Support Lounge using your Support Lounge email & password. Please note that any running tests will be stopped. :param email: CDRouter Support Lounge email as a string. :para...
python
{ "resource": "" }
q56241
SystemService.lounge_update_license
train
def lounge_update_license(self): """Download & install a license for your CDRouter system from the CDRouter Support Lounge. :return: :class:`system.Upgrade <system.Upgrade>` object :rtype: system.Upgrade """ schema = UpgradeSchema() resp = self.service.post(self....
python
{ "resource": "" }
q56242
SystemService.manual_update_license
train
def manual_update_license(self, fd, filename='cdrouter.lic'): """Update the license on your CDRouter system manually by uploading a .lic license from the CDRouter Support Lounge. :param fd: File-like object to upload. :param filename: (optional) Filename to use for license as string. ...
python
{ "resource": "" }
q56243
SystemService.space
train
def space(self): """Get system disk space usage. :return: :class:`system.Space <system.Space>` object :rtype: system.Space """ schema = SpaceSchema() resp = self.service.get(self.base+'space/') return self.service.decode(schema, resp)
python
{ "resource": "" }
q56244
SystemService.interfaces
train
def interfaces(self, addresses=False): """Get system interfaces. :param addresses: (optional) If bool `True`, include interface addresses. :return: :class:`system.Interface <system.Interface>` list """ schema = InterfaceSchema() resp = self.service.get(self.base+'interfa...
python
{ "resource": "" }
q56245
_set_original_fields
train
def _set_original_fields(instance): """ Save fields value, only for non-m2m fields. """ original_fields = {} def _set_original_field(instance, field): if instance.pk is None: original_fields[field] = None else: if isinstance(instance._meta.get_field(field), F...
python
{ "resource": "" }
q56246
_has_changed
train
def _has_changed(instance): """ Check if some tracked fields have changed """ for field, value in instance._original_fields.items(): if field != 'pk' and \ not isinstance(instance._meta.get_field(field), ManyToManyField): try: if field in getattr(instance, ...
python
{ "resource": "" }
q56247
_has_changed_related
train
def _has_changed_related(instance): """ Check if some related tracked fields have changed """ tracked_related_fields = getattr( instance, '_tracked_related_fields', {} ).keys() for field, value in instance._original_fields.items(): if field != 'pk' and \ ...
python
{ "resource": "" }
q56248
_create_event
train
def _create_event(instance, action): """ Create a new event, getting the use if django-cuser is available. """ user = None user_repr = repr(user) if CUSER: user = CuserMiddleware.get_user() user_repr = repr(user) if user is not None and user.is_anonymous: user...
python
{ "resource": "" }
q56249
_create_tracked_field
train
def _create_tracked_field(event, instance, field, fieldname=None): """ Create a TrackedFieldModification for the instance. :param event: The TrackingEvent on which to add TrackingField :param instance: The instance on which the field is :param field: The field name to track :param fieldname: Th...
python
{ "resource": "" }
q56250
_create_create_tracking_event
train
def _create_create_tracking_event(instance): """ Create a TrackingEvent and TrackedFieldModification for a CREATE event. """ event = _create_event(instance, CREATE) for field in instance._tracked_fields: if not isinstance(instance._meta.get_field(field), ManyToManyField): _create...
python
{ "resource": "" }
q56251
_create_update_tracking_event
train
def _create_update_tracking_event(instance): """ Create a TrackingEvent and TrackedFieldModification for an UPDATE event. """ event = _create_event(instance, UPDATE) for field in instance._tracked_fields: if not isinstance(instance._meta.get_field(field), ManyToManyField): try: ...
python
{ "resource": "" }
q56252
_create_update_tracking_related_event
train
def _create_update_tracking_related_event(instance): """ Create a TrackingEvent and TrackedFieldModification for an UPDATE event for each related model. """ events = {} # Create a dict mapping related model field to modified fields for field, related_fields in instance._tracked_related_field...
python
{ "resource": "" }
q56253
_get_m2m_field
train
def _get_m2m_field(model, sender): """ Get the field name from a model and a sender from m2m_changed signal. """ for field in getattr(model, '_tracked_fields', []): if isinstance(model._meta.get_field(field), ManyToManyField): if getattr(model, field).through == sender: ...
python
{ "resource": "" }
q56254
tracking_save
train
def tracking_save(sender, instance, raw, using, update_fields, **kwargs): """ Post save, detect creation or changes and log them. We need post_save to have the object for a create. """ if _has_changed(instance): if instance._original_fields['pk'] is None: # Create _cr...
python
{ "resource": "" }
q56255
LogEntry.from_entry_dict
train
def from_entry_dict(cls, entry_dict): """ This is a "constructor" for the LogEntry class. :param entry_dict: A dict we get from the REST API :return: An instance of LogEntry. """ # Debug helper # https://circleci.com/gh/andresriancho/w3af-api-docker/30 tr...
python
{ "resource": "" }
q56256
CapturesService.list
train
def list(self, id, seq): # pylint: disable=invalid-name,redefined-builtin """Get a list of captures. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :return: :class:`captures.Capture <captures.Capture>` list """ schema = CaptureSchema(exclud...
python
{ "resource": "" }
q56257
CapturesService.get
train
def get(self, id, seq, intf): # pylint: disable=invalid-name,redefined-builtin """Get a capture. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :return: :class:`captures.Capture <captures.Capture>` object ...
python
{ "resource": "" }
q56258
CapturesService.download
train
def download(self, id, seq, intf, inline=False): # pylint: disable=invalid-name,redefined-builtin """Download a capture as a PCAP file. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param inline: (optional) ...
python
{ "resource": "" }
q56259
CapturesService.summary
train
def summary(self, id, seq, intf, filter=None, inline=False): # pylint: disable=invalid-name,redefined-builtin """Get a capture's summary. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param filter: (optional...
python
{ "resource": "" }
q56260
CapturesService.decode
train
def decode(self, id, seq, intf, filter=None, frame=None, inline=False): # pylint: disable=invalid-name,redefined-builtin """Get a capture's decode. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param filter:...
python
{ "resource": "" }
q56261
CapturesService.send_to_cloudshark
train
def send_to_cloudshark(self, id, seq, intf, inline=False): # pylint: disable=invalid-name,redefined-builtin """Send a capture to a CloudShark Appliance. Both cloudshark_appliance_url and cloudshark_appliance_token must be properly configured via system preferences. :param id: Result ID ...
python
{ "resource": "" }
q56262
get_dict_from_response
train
def get_dict_from_response(response): """Check for errors in the response and return the resulting JSON.""" if getattr(response, '_resp') and response._resp.code > 400: raise OAuthResponseError( 'Application mis-configuration in Globus', None, response ) return response....
python
{ "resource": "" }
q56263
get_user_info
train
def get_user_info(remote): """Get user information from Globus. See the docs here for v2/oauth/userinfo: https://docs.globus.org/api/auth/reference/ """ response = remote.get(GLOBUS_USER_INFO_URL) user_info = get_dict_from_response(response) response.data['username'] = response.data['prefer...
python
{ "resource": "" }
q56264
get_user_id
train
def get_user_id(remote, email): """Get the Globus identity for a users given email. A Globus ID is a UUID that can uniquely identify a Globus user. See the docs here for v2/api/identities https://docs.globus.org/api/auth/reference/ """ try: url = '{}?usernames={}'.format(GLOBUS_USER_ID_...
python
{ "resource": "" }
q56265
get_function_signature
train
def get_function_signature(func): """ Return the signature string of the specified function. >>> def foo(name): pass >>> get_function_signature(foo) 'foo(name)' >>> something = 'Hello' >>> get_function_signature(something) Traceback (most recent call last): ... TypeError: Th...
python
{ "resource": "" }
q56266
RWLock.acquire_reader
train
def acquire_reader(self): """ Acquire a read lock, several threads can hold this type of lock. """ with self.mutex: while self.rwlock < 0 or self.rwlock == self.max_reader_concurrency or self.writers_waiting: self.readers_ok.wait() self.rwlock += 1
python
{ "resource": "" }
q56267
RWLock.acquire_writer
train
def acquire_writer(self): """ Acquire a write lock, only one thread can hold this lock and only when no read locks are also held. """ with self.mutex: while self.rwlock != 0: self._writer_wait() self.rwlock = -1
python
{ "resource": "" }
q56268
PackagesService.list
train
def list(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of packages. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields...
python
{ "resource": "" }
q56269
PackagesService.get
train
def get(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a package. :param id: Package ID as an int. :return: :class:`packages.Package <packages.Package>` object :rtype: packages.Package """ schema = PackageSchema() resp = self.service.get_id(se...
python
{ "resource": "" }
q56270
PackagesService.create
train
def create(self, resource): """Create a new package. :param resource: :class:`packages.Package <packages.Package>` object :return: :class:`packages.Package <packages.Package>` object :rtype: packages.Package """ schema = PackageSchema(exclude=('id', 'created', 'updated',...
python
{ "resource": "" }
q56271
PackagesService.analyze
train
def analyze(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a list of tests that will be skipped for a package. :param id: Package ID as an int. :return: :class:`packages.Analysis <packages.Analysis>` object :rtype: packages.Analysis """ schema = Analy...
python
{ "resource": "" }
q56272
PackagesService.bulk_copy
train
def bulk_copy(self, ids): """Bulk copy a set of packages. :param ids: Int list of package IDs. :return: :class:`packages.Package <packages.Package>` list """ schema = PackageSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
python
{ "resource": "" }
q56273
PackagesService.bulk_edit
train
def bulk_edit(self, _fields, ids=None, filter=None, type=None, all=False): # pylint: disable=redefined-builtin """Bulk edit a set of packages. :param _fields: :class:`packages.Package <packages.Package>` object :param ids: (optional) Int list of package IDs. :param filter: (optional) St...
python
{ "resource": "" }
q56274
clean_lines
train
def clean_lines(commands): """ Generate strings that are not comments or lines with only whitespace. Purpose: This function is a generator that will read in either a | plain text file of strings(IP list, command list, etc), a | comma separated string of strings, or a list of strings. It ...
python
{ "resource": "" }
q56275
xpath
train
def xpath(source_xml, xpath_expr, req_format='string'): """ Filter xml based on an xpath expression. Purpose: This function applies an Xpath expression to the XML | supplied by source_xml. Returns a string subtree or | subtrees that match the Xpath expression. It can also return ...
python
{ "resource": "" }
q56276
Client.set
train
def set(self, key, value, lease=None, return_previous=None, timeout=None): """ Set the value for the key in the key-value store. Setting a value on a key increments the revision of the key-value store and generates one event in the event history. :param key: key is the ...
python
{ "resource": "" }
q56277
Client.watch
train
def watch(self, keys, on_watch, filters=None, start_revision=None, return_previous=None): """ Watch one or more keys or key sets and invoke a callback. Watch watches for events happening or that have happened. The entire event history can be watched starting from the last compaction rev...
python
{ "resource": "" }
q56278
Client.lease
train
def lease(self, time_to_live, lease_id=None, timeout=None): """ Creates a lease which expires if the server does not receive a keep alive within a given time to live period. All keys attached to the lease will be expired and deleted if the lease expires. Each expired ke...
python
{ "resource": "" }
q56279
ImportsService.stage_import_from_file
train
def stage_import_from_file(self, fd, filename='upload.gz'): """Stage an import from a file upload. :param fd: File-like object to upload. :param filename: (optional) Filename to use for import as string. :return: :class:`imports.Import <imports.Import>` object """ schema...
python
{ "resource": "" }
q56280
ImportsService.stage_import_from_filesystem
train
def stage_import_from_filesystem(self, filepath): """Stage an import from a filesystem path. :param filepath: Local filesystem path as string. :return: :class:`imports.Import <imports.Import>` object """ schema = ImportSchema() resp = self.service.post(self.base, ...
python
{ "resource": "" }
q56281
ImportsService.stage_import_from_url
train
def stage_import_from_url(self, url, token=None, username=None, password=None, insecure=False): """Stage an import from a URL to another CDRouter system. :param url: URL to import as string. :param token: (optional) API token to use as string (may be required if importing from a CDRouter 10+ sy...
python
{ "resource": "" }
q56282
ImportsService.get_commit_request
train
def get_commit_request(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a commit request for a staged import. :param id: Staged import ID as an int. :return: :class:`imports.Request <imports.Request>` object :rtype: imports.Request """ schema = RequestS...
python
{ "resource": "" }
q56283
ImportsService.commit
train
def commit(self, id, impreq): # pylint: disable=invalid-name,redefined-builtin """Commit a staged import. :param id: Staged import ID as an int. :param impreq: :class:`imports.Request <imports.Request>` object :return: :class:`imports.Request <imports.Request>` object :rtype: im...
python
{ "resource": "" }
q56284
model_to_dict
train
def model_to_dict(instance, **options): "Takes a model instance and converts it into a dict." options = _defaults(options) attrs = {} if options['prehook']: if isinstance(options['prehook'], collections.Callable): instance = options['prehook'](instance) if instance is N...
python
{ "resource": "" }
q56285
set_save_directory
train
def set_save_directory(base, source): """Sets the root save directory for saving screenshots. Screenshots will be saved in subdirectories under this directory by browser window size. """ root = os.path.join(base, source) if not os.path.isdir(root): os.makedirs(root) world.screensho...
python
{ "resource": "" }
q56286
UsersService.change_password
train
def change_password(self, id, new, old=None, change_token=True): # pylint: disable=invalid-name,redefined-builtin """Change a user's password. :param id: User ID as an int. :param new: New password as string. :param old: (optional) Old password as string (required if performing action a...
python
{ "resource": "" }
q56287
UsersService.change_token
train
def change_token(self, id): # pylint: disable=invalid-name,redefined-builtin """Change a user's token. :param id: User ID as an int. :return: :class:`users.User <users.User>` object :rtype: users.User """ schema = UserSchema(exclude=('password', 'password_confirm')) ...
python
{ "resource": "" }
q56288
UsersService.bulk_copy
train
def bulk_copy(self, ids): """Bulk copy a set of users. :param ids: Int list of user IDs. :return: :class:`users.User <users.User>` list """ schema = UserSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
python
{ "resource": "" }
q56289
AttachmentsService.list
train
def list(self, id, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=invalid-name,redefined-builtin """Get a list of a device's attachments. :param id: Device ID as an int. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `u...
python
{ "resource": "" }
q56290
AttachmentsService.iter_list
train
def iter_list(self, id, *args, **kwargs): """Get a list of attachments. Whereas ``list`` fetches a single page of attachments according to its ``limit`` and ``page`` arguments, ``iter_list`` returns all attachments by internally making successive calls to ``list``. :param id: D...
python
{ "resource": "" }
q56291
AttachmentsService.get
train
def get(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Get a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachment...
python
{ "resource": "" }
q56292
AttachmentsService.create
train
def create(self, id, fd, filename='attachment-name'): # pylint: disable=invalid-name,redefined-builtin """Add an attachment to a device. :param id: Device ID as an int. :param fd: File-like object to upload. :param filename: (optional) Name to use for new attachment as a string. ...
python
{ "resource": "" }
q56293
AttachmentsService.download
train
def download(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Download a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. :rtype: tuple `(io.BytesIO, 'filename')` """ resp = self.service.get_id(self._base(id...
python
{ "resource": "" }
q56294
AttachmentsService.edit
train
def edit(self, resource): # pylint: disable=invalid-name,redefined-builtin """Edit a device's attachment. :param resource: :class:`attachments.Attachment <attachments.Attachment>` object :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachm...
python
{ "resource": "" }
q56295
AttachmentsService.delete
train
def delete(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Delete a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. """ return self.service.edit(self._base(id), attid)
python
{ "resource": "" }
q56296
DevicesService.get_by_name
train
def get_by_name(self, name): # pylint: disable=invalid-name,redefined-builtin """Get a device by name. :param name: Device name as string. :return: :class:`devices.Device <devices.Device>` object :rtype: devices.Device """ rs, _ = self.list(filter=field('name').eq(name),...
python
{ "resource": "" }
q56297
DevicesService.edit
train
def edit(self, resource): """Edit a device. :param resource: :class:`devices.Device <devices.Device>` object :return: :class:`devices.Device <devices.Device>` object :rtype: devices.Device """ schema = DeviceSchema(exclude=('id', 'created', 'updated', 'result_id', 'attac...
python
{ "resource": "" }
q56298
DevicesService.get_connection
train
def get_connection(self, id): # pylint: disable=invalid-name,redefined-builtin """Get information on proxy connection to a device's management interface. :param id: Device ID as an int. :return: :class:`devices.Connection <devices.Connection>` object :rtype: devices.Connection "...
python
{ "resource": "" }
q56299
DevicesService.connect
train
def connect(self, id): # pylint: disable=invalid-name,redefined-builtin """Open proxy connection to a device's management interface. :param id: Device ID as an int. :return: :class:`devices.Connection <devices.Connection>` object :rtype: devices.Connection """ schema = C...
python
{ "resource": "" }