code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
'''Remove a relationship from an object. Wrapper function for `Fedora REST API purgeRelationship <https://wiki.duraspace.org/display/FEDORA34/REST+API#RESTAPI-purgeRelationship>`_ :param pid: object pid :param subject: relationship subject :param predicate: relationship...
def purgeRelationship(self, pid, subject, predicate, object, isLiteral=False, datatype=None)
Remove a relationship from an object. Wrapper function for `Fedora REST API purgeRelationship <https://wiki.duraspace.org/display/FEDORA34/REST+API#RESTAPI-purgeRelationship>`_ :param pid: object pid :param subject: relationship subject :param predicate: relationship predicate ...
3.19187
2.020466
1.579769
'''Update datastream state. :param pid: object pid :param dsID: datastream id :param dsState: datastream state :returns: boolean success ''' # /objects/{pid}/datastreams/{dsID} ? [dsState] http_args = {'dsState' : dsState} url = 'objects/%(pid)s/d...
def setDatastreamState(self, pid, dsID, dsState)
Update datastream state. :param pid: object pid :param dsID: datastream id :param dsState: datastream state :returns: boolean success
3.298265
2.885744
1.142951
'''Update datastream versionable setting. :param pid: object pid :param dsID: datastream id :param versionable: boolean :returns: boolean success ''' # /objects/{pid}/datastreams/{dsID} ? [versionable] http_args = {'versionable': versionable} url ...
def setDatastreamVersionable(self, pid, dsID, versionable)
Update datastream versionable setting. :param pid: object pid :param dsID: datastream id :param versionable: boolean :returns: boolean success
3.246257
2.876068
1.128713
''' Upload a multi-part file for content to ingest. Returns a temporary upload id that can be used as a datstream location. :param data: content string, file-like object, or iterable with content to be uploaded :param callback: optional callback method to monitor th...
def upload(self, data, callback=None, content_type=None, size=None)
Upload a multi-part file for content to ingest. Returns a temporary upload id that can be used as a datstream location. :param data: content string, file-like object, or iterable with content to be uploaded :param callback: optional callback method to monitor the upload; ...
4.928068
3.431628
1.436073
http_args = { 'type': type, 'lang': language, 'query': query, } if type == 'triples': result_format = 'N-Triples' elif type == 'tuples': result_format = 'CSV' if limit is not None: http_args['limit']...
def find_statements(self, query, language='spo', type='triples', flush=None, limit=None)
Run a query in a format supported by the Fedora Resource Index (e.g., SPO or Sparql) and return the results. :param query: query as a string :param language: query language to use; defaults to 'spo' :param type: type of query - tuples or triples; defaults to 'triples' :param flu...
3.973586
4.345622
0.914388
result_format = 'count' http_args = { 'type': type, 'lang': language, 'query': query, 'format': result_format } return self._query(result_format, http_args, flush)
def count_statements(self, query, language='spo', type='triples', flush=None)
Run a query in a format supported by the Fedora Resource Index (e.g., SPO or Sparql) and return the count of the results. :param query: query as a string :param language: query language to use; defaults to 'spo' :param flush: flush results to get recent changes; defaults to False ...
3.777279
4.535071
0.832904
spo_query = '%s %s %s' % \ (self.spoencode(subject), self.spoencode(predicate), self.spoencode(object)) return self.find_statements(spo_query)
def spo_search(self, subject=None, predicate=None, object=None)
Create and run a subject-predicate-object (SPO) search. Any search terms that are not specified will be replaced as a wildcard in the query. :param subject: optional subject to search :param predicate: optional predicate to search :param object: optional object to search :rtype...
3.902465
4.880253
0.799644
for statement in self.spo_search(predicate=predicate, object=object): yield str(statement[0])
def get_subjects(self, predicate, object)
Search for all subjects related to the specified predicate and object. :param predicate: :param object: :rtype: generator of RDF statements
7.169729
7.216218
0.993558
for statement in self.spo_search(subject=subject, object=object): yield str(statement[1])
def get_predicates(self, subject, object)
Search for all subjects related to the specified subject and object. :param subject: :param object: :rtype: generator of RDF statements
8.376331
7.698799
1.088005
for statement in self.spo_search(subject=subject, predicate=predicate): yield str(statement[2])
def get_objects(self, subject, predicate)
Search for all subjects related to the specified subject and predicate. :param subject: :param object: :rtype: generator of RDF statements
8.157704
8.186601
0.99647
return self.find_statements(query, language='sparql', type='tuples', flush=flush, limit=limit)
def sparql_query(self, query, flush=None, limit=None)
Run a Sparql query. :param query: sparql query string :rtype: list of dictionary
9.753129
13.125237
0.743082
return self.count_statements(query, language='sparql', type='tuples', flush=flush)
def sparql_count(self, query, flush=None)
Count results for a Sparql query. :param query: sparql query string :rtype: int
11.412883
15.36642
0.742716
params = {'ContentType': "JSON", 'StackName': stack_name, 'DisableRollback': self.encode_bool(disable_rollback)} if template_body: params['TemplateBody'] = template_body if template_url: params['TemplateURL'] = template_url if template_bod...
def create_stack(self, stack_name, template_body=None, template_url=None, parameters=[], notification_arns=[], disable_rollback=False, timeout_in_minutes=None, capabilities=None)
Creates a CloudFormation Stack as specified by the template. :type stack_name: string :param stack_name: The name of the Stack, must be unique amoung running Stacks :type template_body: string :param template_body: The template body (JSON string) :t...
1.925382
2.03397
0.946613
change = Record(name, type, ttl, alias_hosted_zone_id=alias_hosted_zone_id, alias_dns_name=alias_dns_name, identifier=identifier, weight=weight) self.changes.append([action, change]) return change
def add_change(self, action, name, type, ttl=600, alias_hosted_zone_id=None, alias_dns_name=None, identifier=None, weight=None)
Add a change request
2.166445
2.471435
0.876594
changesXML = "" for change in self.changes: changeParams = {"action": change[0], "record": change[1].to_xml()} changesXML += self.ChangeXML % changeParams params = {"comment": self.comment, "changes": changesXML} return self.ChangeResourceRecordSetsBody %...
def to_xml(self)
Convert this ResourceRecordSet into XML to be saved via the ChangeResourceRecordSetsRequest
6.017141
3.974658
1.513877
if not self.connection: import boto self.connection = boto.connect_route53() return self.connection.change_rrsets(self.hosted_zone_id, self.to_xml())
def commit(self)
Commit this change
5.75855
5.750948
1.001322
if name == 'NextRecordName': self.next_record_name = value elif name == 'NextRecordType': self.next_record_type = value else: return ResultSet.endElement(self, name, value, connection)
def endElement(self, name, value, connection)
Overwritten to also add the NextRecordName and NextRecordType to the base object
2.912735
2.019194
1.442523
self.alias_hosted_zone_id = alias_hosted_zone_id self.alias_dns_name = alias_dns_name
def set_alias(self, alias_hosted_zone_id, alias_dns_name)
Make this an alias resource record set
1.754238
1.63779
1.071101
if self.alias_hosted_zone_id != None and self.alias_dns_name != None: # Use alias body = self.AliasBody % (self.alias_hosted_zone_id, self.alias_dns_name) else: # Use resource record(s) records = "" for r in self.resource_records: ...
def to_xml(self)
Spit this resource record set out as XML
3.256017
3.077132
1.058134
if 'Table' in response: self._dict.update(response['Table']) elif 'TableDescription' in response: self._dict.update(response['TableDescription']) if 'KeySchema' in self._dict: self._schema = Schema(self._dict['KeySchema'])
def update_from_response(self, response)
Update the state of the Table object based on the response data received from Amazon DynamoDB.
2.972211
2.528748
1.175368
done = False while not done: response = self.layer2.describe_table(self.name) self.update_from_response(response) if wait_for_active: if self.status == 'ACTIVE': done = True else: time.sl...
def refresh(self, wait_for_active=False, retry_seconds=5)
Refresh all of the fields of the Table object by calling the underlying DescribeTable request. :type wait_for_active: bool :param wait_for_active: If True, this command will not return until the table status, as returned from Amazon DynamoDB, is 'ACTIVE'. :type ...
2.960853
2.513426
1.178015
self.layer2.update_throughput(self, read_units, write_units)
def update_throughput(self, read_units, write_units)
Update the ProvisionedThroughput for the Amazon DynamoDB Table. :type read_units: int :param read_units: The new value for ReadCapacityUnits. :type write_units: int :param write_units: The new value for WriteCapacityUnits.
5.382191
6.685575
0.805045
return self.layer2.get_item(self, hash_key, range_key, attributes_to_get, consistent_read, item_class)
def get_item(self, hash_key, range_key=None, attributes_to_get=None, consistent_read=False, item_class=Item)
Retrieve an existing item from the table. :type hash_key: int|long|float|str|unicode :param hash_key: The HashKey of the requested item. The type of the value must match the type defined in the schema for the table. :type range_key: int|long|float|str|unicode ...
2.659554
3.448278
0.77127
try: # Attempt to get the key. If it can't be found, it'll raise # an exception. self.get_item(hash_key, range_key=range_key, # This minimizes the size of the response body. attributes_to_get=[hash_key], ...
def has_item(self, hash_key, range_key=None, consistent_read=False)
Checks the table to see if the Item with the specified ``hash_key`` exists. This may save a tiny bit of time/bandwidth over a straight :py:meth:`get_item` if you have no intention to touch the data that is returned, since this method specifically tells Amazon not to return anything but t...
4.090498
4.269671
0.958036
return Item(self, hash_key, range_key, attrs)
def new_item(self, hash_key, range_key=None, attrs=None)
Return an new, unsaved Item which can later be PUT to Amazon DynamoDB.
3.651543
3.738872
0.976643
return self.layer2.query(self, hash_key, range_key_condition, attributes_to_get, request_limit, max_results, consistent_read, scan_index_forward, exclusive_start_key, item...
def query(self, hash_key, range_key_condition=None, attributes_to_get=None, request_limit=None, max_results=None, consistent_read=False, scan_index_forward=True, exclusive_start_key=None, item_class=Item)
Perform a query on the table. :type hash_key: int|long|float|str|unicode :param hash_key: The HashKey of the requested item. The type of the value must match the type defined in the schema for the table. :type range_key_condition: dict :param range_key_...
1.885249
2.312683
0.815178
return self.layer2.scan(self, scan_filter, attributes_to_get, request_limit, max_results, exclusive_start_key, item_class=item_class)
def scan(self, scan_filter=None, attributes_to_get=None, request_limit=None, max_results=None, count=False, exclusive_start_key=None, item_class=Item)
Scan through this table, this is a very long and expensive operation, and should be avoided if at all possible. :type scan_filter: A list of tuples :param scan_filter: A list of tuples where each tuple consists of an attribute name, a comparison operator, and either ...
2.992113
3.780945
0.791366
langs = list(self.culturecode_set.all().as_languages()) langs.extend(self.language_set.exclude(iso_639_1__in=[x.iso_639_1 for x in langs])) if sort in ['name_en', 'name_native']: langs.sort(key=lambda x: getattr(x, sort)) elif sort == 'code': codes = self.languages.split(',') ...
def get_all_languages(self, sort='code')
Retrieve all the language objects for a country. Language objects will be annotated with the country and culturecode attributes when applicable. :param sort: code|name_en|name_native :return:
3.605091
2.977656
1.210714
if any(x in code for x in ('_', '-')): cc = CultureCode.objects.get(code=code.replace('_', '-')) return cc.language elif len(code) == 2: return self.get(iso_639_1=code) elif len(code) == 3: return self.get(Q(iso_639_2T=code) | ...
def get_by_code(self, code)
Retrieve a language by a code. :param code: iso code (any of the three) or its culture code :return: a Language object
3.082784
2.936332
1.049876
if not any(x in code for x in ('_', '-')): raise ValueError("%s is not a valid culture code" % code) cc = CultureCode.objects.get(code=code.replace('_', '-')) return cc.language, cc.country
def get_culture_pair(self, code)
# Return a tuple of the language and country for a given culture code :param code: :return:
4.369615
3.864986
1.130564
lang_codes = [] cc_codes = [] for code in codes: if any(x in code for x in ('_', '-')): cc_codes.append(code.replace('_', '-')) else: lang_codes.append(code) cc_langs = CultureCode.objects.filter(code__in=cc_codes).as_lang...
def filter_by_codes(self, codes, sort='name_en')
Retrieve a list (not queryset) of languages from a list of codes The language objects retrieved by culture code will be annotated with the country and culture code. :param codes: list of strings that can be either iso codes (any of the three) or culture codes. :param sort: str na...
2.381632
2.197935
1.083577
langs = [] for culture_code in self.select_related('language', 'country').all(): lang = culture_code.language lang.country = culture_code.country lang.culturecode = culture_code.code langs.append(lang) return langs
def as_languages(self)
Get the Language objects associated with this queryset of CultureCodes as a list. The Language objects will have country and culturecode set. :return:
3.736064
2.496094
1.496764
sender, recver = self.pipe() self.spawn(f, sender) return recver
def producer(self, f)
Convenience to create a `Pipe`_. *f* is a callable that takes the `Sender`_ end of this Pipe and the corresponding `Recver`_ is returned:: def counter(sender): i = 0 while True: i += 1 sender.send(i) recver...
11.237069
8.737122
1.286129
@self.producer def _(sender): while True: try: self.sleep(ms) except vanilla.exception.Halt: break sender.send(item) sender.close() return _
def pulse(self, ms, item=True)
Convenience to create a `Pipe`_ that will have *item* sent on it every *ms* milliseconds. The `Recver`_ end of the Pipe is returned. Note that since sends to a Pipe block until the Recver is ready, the pulses will be throttled if the Recver is unable to keep up:: recver = h.pulse(5...
10.530436
11.578812
0.909457
sender, recver = self.router() if size > 0: recver = recver.pipe(self.queue(size)) return vanilla.message.Pair(sender, recver.pipe(self.dealer()))
def channel(self, size=-1)
:: send --\ +---------+ /--> recv +-> | Channel | -+ send --/ +---------+ \--> recv A Channel can have many senders and many recvers. By default it is unbuffered, but you can create buffered Channels by specifying a size. They're structurally...
11.467291
7.870941
1.456915
s = self.router() @self.spawn def _(): for f, a, kw, r in s.recver: try: r.send(f(*a, **kw)) except Exception, e: r.send(e) def _(*a, **kw): r = self.pipe() s.send((f, a...
def serialize(self, f)
Decorator to serialize access to a callable *f*
4.909899
4.418117
1.11131
return vanilla.message.State(self, state=state)
def state(self, state=vanilla.message.NoState)
Returns a `State`_ `Pair`_. *state* if supplied sets the intial state.
7.859314
12.301575
0.638887
for end in ends: if end.ready: return end, isinstance( end, vanilla.message.Recver) and end.recv() or None for end in ends: end.select() try: fired, item = self.pause(timeout=timeout) finally: ...
def select(self, ends, timeout=-1)
An end is either a `Sender`_ or a `Recver`_. select takes a list of *ends* and blocks until *one* of them is ready. The select will block either forever, or until the optional *timeout* is reached. *timeout* is in milliseconds. It returns of tuple of (*end*, *value*) where *end* is the ...
7.888702
7.305763
1.079792
self.ready.append((getcurrent(), ())) return target.throw(*a)
def throw_to(self, target, *a)
if len(a) == 1 and isinstance(a[0], preserve_exception): return target.throw(a[0].typ, a[0].val, a[0].tb)
41.588345
20.479874
2.030693
self.scheduled.add(ms, f, *a)
def spawn_later(self, ms, f, *a)
Spawns a callable on a new green thread, scheduled for *ms* milliseconds in the future:: def echo(pipe, s): pipe.send(s) p = h.pipe() h.spawn_later(50, echo, p, 'hi') p.recv() # returns 'hi' after 50ms
8.239598
14.075173
0.585399
self.scheduled.add(ms, getcurrent()) self.loop.switch()
def sleep(self, ms=1)
Pauses the current green thread for *ms* milliseconds:: p = h.pipe() @h.spawn def _(): p.send('1') h.sleep(50) p.send('2') p.recv() # returns '1' p.recv() # returns '2' after 50 ms
26.750494
48.407204
0.552614
while True: while self.ready: task, a = self.ready.popleft() self.run_task(task, *a) if self.scheduled: timeout = self.scheduled.timeout() # run overdue scheduled immediately if timeout < 0: ...
def main(self)
Scheduler steps: - run ready until exhaustion - if there's something scheduled - run overdue scheduled immediately - or if there's nothing registered, sleep until next scheduled and then go back to ready - if there's nothing registe...
4.411754
3.501337
1.26002
if self.material: directory_path = os.path.expanduser(directory_path) file_path = os.path.join(directory_path, '%s.pem' % self.name) if os.path.exists(file_path): raise BotoClientError('%s already exists, it will not be overwritten' % file_path) ...
def save(self, directory_path)
Save the material (the unencrypted PEM encoded RSA private key) of a newly created KeyPair to a local file. :type directory_path: string :param directory_path: The fully qualified path to the directory in which the keypair will be saved. The ...
2.643751
2.247733
1.176185
if region.name == self.region: raise BotoClientError('Unable to copy to the same Region') conn_params = self.connection.get_params() rconn = region.connect(**conn_params) kp = rconn.create_key_pair(self.name) return kp
def copy_to_region(self, region)
Create a new key pair of the same new in another region. Note that the new key pair will use a different ssh cert than the this key pair. After doing the copy, you will need to save the material associated with the new key pair (use the save method) to a local file. :type regio...
5.294323
5.522301
0.958717
l = ServerSet() rs = cls.find() for server in rs: l.append(server) return l
def Inventory(cls)
Returns a list of Server instances, one for each Server object persisted in the db
10.681712
7.010678
1.523635
self._config = config self._config.dump_to_sdb("botoConfigs", self.id)
def set_config(self, config)
Set SDB based config
19.55234
14.141532
1.382618
if hasattr(volume, "id"): volume_id = volume.id else: volume_id = volume return self.ec2.attach_volume(volume_id=volume_id, instance_id=self.instance_id, device=device)
def attach_volume(self, volume, device="/dev/sdp")
Attach an EBS volume to this server :param volume: EBS Volume to attach :type volume: boto.ec2.volume.Volume :param device: Device to attach to (default to /dev/sdp) :type device: string
2.070429
2.716237
0.762242
if hasattr(volume, "id"): volume_id = volume.id else: volume_id = volume return self.ec2.detach_volume(volume_id=volume_id, instance_id=self.instance_id)
def detach_volume(self, volume)
Detach an EBS volume from this server :param volume: EBS Volume to detach :type volume: boto.ec2.volume.Volume
2.163462
2.591279
0.834901
if not self.tracker_file_name: return f = None try: f = open(self.tracker_file_name, 'w') f.write(self.tracker_uri) except IOError, e: raise ResumableUploadException( 'Couldn\'t write URI tracker file (%s): %s.\nThi...
def _save_tracker_uri_to_file(self)
Saves URI to tracker file if one was passed to constructor.
4.11817
3.962722
1.039228
parse_result = urlparse.urlparse(uri) if (parse_result.scheme.lower() not in ['http', 'https'] or not parse_result.netloc or not parse_result.query): raise InvalidUriError('Invalid tracker URI (%s)' % uri) qdict = cgi.parse_qs(parse_result.query) if not q...
def _set_tracker_uri(self, uri)
Called when we start a new resumable upload or get a new tracker URI for the upload. Saves URI and resets upload state. Raises InvalidUriError if URI is syntactically invalid.
2.633042
2.506755
1.050379
# Send an empty PUT so that server replies with this resumable # transfer's state. put_headers = {} put_headers['Content-Range'] = ( self._build_content_range_header('*', file_length)) put_headers['Content-Length'] = '0' return AWSAuthConnection.make_...
def _query_server_state(self, conn, file_length)
Queries server to find out state of given upload. Note that this method really just makes special case use of the fact that the upload server always returns the current start/end state whenever a PUT doesn't complete. Returns HTTP response from sending request. Raises Resumabl...
5.778841
5.330565
1.084095
resp = self._query_server_state(conn, file_length) if resp.status == 200: return (0, file_length) # Completed upload. if resp.status != 308: # This means the server didn't have any state for the given # upload ID, which can happen (for example) if th...
def _query_server_pos(self, conn, file_length)
Queries server to find out what bytes it currently has. Returns (server_start, server_end), where the values are inclusive. For example, (0, 2) would mean that the server has bytes 0, 1, *and* 2. Raises ResumableUploadException if problem querying server.
4.443959
4.026933
1.103559
conn = key.bucket.connection if conn.debug >= 1: print 'Starting new resumable upload.' self.server_has_bytes = 0 # Start a new resumable upload by sending a POST request with an # empty body and the "X-Goog-Resumable: start" header. Include any # ca...
def _start_new_resumable_upload(self, key, headers=None)
Starts a new resumable upload. Raises ResumableUploadException if any errors occur.
4.219698
4.17905
1.009727
buf = fp.read(self.BUFFER_SIZE) if cb: if num_cb > 2: cb_count = file_length / self.BUFFER_SIZE / (num_cb-2) elif num_cb < 0: cb_count = -1 else: cb_count = 0 i = 0 cb(total_bytes_uploade...
def _upload_file_bytes(self, conn, http_conn, fp, file_length, total_bytes_uploaded, cb, num_cb)
Makes one attempt to upload file bytes, using an existing resumable upload connection. Returns etag from server upon success. Raises ResumableUploadException if any problems occur.
3.397768
3.374374
1.006933
(server_start, server_end) = self.SERVER_HAS_NOTHING conn = key.bucket.connection if self.tracker_uri: # Try to resume existing resumable upload. try: (server_start, server_end) = ( self._query_server_pos(conn, file_length)) ...
def _attempt_resumable_upload(self, key, fp, file_length, headers, cb, num_cb)
Attempts a resumable upload. Returns etag from server upon success. Raises ResumableUploadException if any problems occur.
5.365998
5.407991
0.992235
if key.bucket.connection.debug >= 1: print 'Checking md5 against etag.' if key.md5 != etag.strip('"\''): # Call key.open_read() before attempting to delete the # (incorrect-content) key, so we perform that request on a # different HTTP connection....
def _check_final_md5(self, key, etag)
Checks that etag from server agrees with md5 computed before upload. This is important, since the upload could have spanned a number of hours and multiple processes (e.g., gsutil runs), and the user could change some of the file and not realize they have inconsistent data.
10.553782
10.151454
1.039633
new_config = DistributionConfig(self.connection, self.config.origin, self.config.enabled, self.config.caller_reference, self.config.cnames, self.config.comment, self.config.trusted_si...
def update(self, enabled=None, cnames=None, comment=None)
Update the configuration of the Distribution. The only values of the DistributionConfig that can be directly updated are: * CNAMES * Comment * Whether the Distribution is enabled or not Any changes to the ``trusted_signers`` or ``origin`` properties of this distribu...
2.972798
2.61674
1.136069
bucket = self._get_bucket() objs = [] for key in bucket: objs.append(key) return objs
def get_objects(self)
Return a list of all content objects in this distribution. :rtype: list of :class:`boto.cloudfront.object.Object` :return: The content objects
5.606928
7.324476
0.765506
if isinstance(self.config.origin, S3Origin): if self.config.origin.origin_access_identity: id = self.config.origin.origin_access_identity.split('/')[-1] oai = self.connection.get_origin_access_identity_info(id) policy = object.get_acl() ...
def set_permissions(self, object, replace=False)
Sets the S3 ACL grants for the given object to the appropriate value based on the type of Distribution. If the Distribution is serving private content the ACL will be set to include the Origin Access Identity associated with the Distribution. If the Distribution is serving public conte...
3.823632
3.268456
1.169859
bucket = self._get_bucket() for key in bucket: self.set_permissions(key, replace)
def set_permissions_all(self, replace=False)
Sets the S3 ACL grants for all objects in the Distribution to the appropriate value based on the type of Distribution. :type replace: bool :param replace: If False, the Origin Access Identity will be appended to the existing ACL for the object. If...
4.894153
7.953194
0.61537
if self.config.origin.origin_access_identity: policy = 'private' else: policy = 'public-read' bucket = self._get_bucket() object = bucket.new_key(name) object.set_contents_from_file(content, headers=headers, policy=policy) if self.config.o...
def add_object(self, name, content, headers=None, replace=True)
Adds a new content object to the Distribution. The content for the object will be copied to a new Key in the S3 Bucket and the permissions will be set appropriately for the type of Distribution. :type name: str or unicode :param name: The name or key of the new object. ...
3.332566
3.186774
1.045749
# Get the required parameters params = self._create_signing_params( url=url, keypair_id=keypair_id, expire_time=expire_time, valid_after_time=valid_after_time, ip_address=ip_address, policy_url=policy_url, private_key_file=private_k...
def create_signed_url(self, url, keypair_id, expire_time=None, valid_after_time=None, ip_address=None, policy_url=None, private_key_file=None, private_key_string=None)
Creates a signed CloudFront URL that is only valid within the specified parameters. :type url: str :param url: The URL of the protected object. :type keypair_id: str :param keypair_id: The keypair ID of the Amazon KeyPair used to sign theURL. This ID MUST correspon...
2.139547
2.29818
0.930974
params = {} # Check if we can use a canned policy if expire_time and not valid_after_time and not ip_address and not policy_url: # we manually construct this policy string to ensure formatting # matches signature policy = self._canned_policy(url, expi...
def _create_signing_params(self, url, keypair_id, expire_time=None, valid_after_time=None, ip_address=None, policy_url=None, private_key_file=None, private_key_string=None)
Creates the required URL parameters for a signed URL.
3.368462
3.28898
1.024166
condition = {} if expires: condition["DateLessThan"] = {"AWS:EpochTime": expires} if valid_after: condition["DateGreaterThan"] = {"AWS:EpochTime": valid_after} if ip_address: if '/' not in ip_address: ip_address += "/32" ...
def _custom_policy(resource, expires=None, valid_after=None, ip_address=None)
Creates a custom policy string based on the supplied parameters.
2.301775
2.187146
1.05241
try: from M2Crypto import EVP except ImportError: raise NotImplementedError("Boto depends on the python M2Crypto " "library to generate signed URLs for " "CloudFront") # Make sure only on...
def _sign_string(message, private_key_file=None, private_key_string=None)
Signs a string for use with Amazon CloudFront. Requires the M2Crypto library be installed.
2.58114
2.380725
1.084182
msg_base64 = base64.b64encode(msg) msg_base64 = msg_base64.replace('+', '-') msg_base64 = msg_base64.replace('=', '_') msg_base64 = msg_base64.replace('/', '~') return msg_base64
def _url_base64_encode(msg)
Base64 encodes a string using the URL-safe characters specified by Amazon.
1.847946
1.910461
0.967278
new_config = StreamingDistributionConfig(self.connection, self.config.origin, self.config.enabled, self.config.caller_reference, ...
def update(self, enabled=None, cnames=None, comment=None)
Update the configuration of the StreamingDistribution. The only values of the StreamingDistributionConfig that can be directly updated are: * CNAMES * Comment * Whether the Distribution is enabled or not Any changes to the ``trusted_signers`` or ``origin`` properties of ...
2.836195
2.794638
1.01487
img = image.astype(np.float32) # Substracting Image mean value img -= np.array((104.00698793, 116.66876762, 122.67891434)) # make dims C x H x W for Caffe img = img.transpose((2, 0, 1)) in_img = img[np.newaxis, :, :, :] self.net.blobs['data'].reshape(*...
def extract_feature(self, image, layer)
Passes image to a deepnet and extracts from the specified layer :param image: opencv image :param layer: network layer name :return: extracted features
2.460147
2.516614
0.977562
value = getattr(instance, field) if hasattr(value, 'raw'): value = value.raw return value
def _get_field(instance, field)
This is here to support ``MarkupField``. It's a little ugly to have that support baked-in; other option would be to have a generic way (via setting?) to override how attribute values are fetched from content model instances.
3.797164
3.315506
1.145274
if created: # a brand new FileUpload won't be referenced return for ref in FileUploadReference.objects.filter(upload=instance): try: obj = ref.content_object if obj: obj.save() except AttributeError: pass
def _update_content(sender, instance, created=None, **kwargs)
Re-save any content models referencing the just-modified ``FileUpload``. We don't do anything special to the content model, we just re-save it. If signals are in use, we assume that the content model has incorporated ``render_uploads`` into some kind of rendering that happens automatically at save-...
6.510259
6.034033
1.078923
param_names = ['aws_access_key_id', 'aws_secret_access_key', 'is_secure', 'port', 'proxy', 'proxy_port', 'proxy_user', 'proxy_pass', 'debug', 'https_connection_factory'] params = {} for name in param_names: ...
def get_params(self)
Returns a dictionary containing the value of of all of the keyword arguments passed when constructing this connection.
2.366464
2.127684
1.112225
params = {} if image_ids: self.build_list_params(params, image_ids, 'ImageId') if owners: self.build_list_params(params, owners, 'Owner') if executable_by: self.build_list_params(params, executable_by, 'ExecutableBy') if filters: ...
def get_all_images(self, image_ids=None, owners=None, executable_by=None, filters=None)
Retrieve all the EC2 images available on your account. :type image_ids: list :param image_ids: A list of strings with the image IDs wanted :type owners: list :param owners: A list of owner IDs :type executable_by: list :param executable_by: Returns AMIs for which the s...
1.687645
1.757123
0.960459
params = {} if kernel_ids: self.build_list_params(params, kernel_ids, 'ImageId') if owners: self.build_list_params(params, owners, 'Owner') filter = {'image-type' : 'kernel'} self.build_filter_params(params, filter) return self.get_list('D...
def get_all_kernels(self, kernel_ids=None, owners=None)
Retrieve all the EC2 kernels available on your account. Constructs a filter to allow the processing to happen server side. :type kernel_ids: list :param kernel_ids: A list of strings with the image IDs wanted :type owners: list :param owners: A list of owner IDs :rtype...
2.930401
2.534126
1.156376
params = {} if ramdisk_ids: self.build_list_params(params, ramdisk_ids, 'ImageId') if owners: self.build_list_params(params, owners, 'Owner') filter = {'image-type' : 'ramdisk'} self.build_filter_params(params, filter) return self.get_list...
def get_all_ramdisks(self, ramdisk_ids=None, owners=None)
Retrieve all the EC2 ramdisks available on your account. Constructs a filter to allow the processing to happen server side. :type ramdisk_ids: list :param ramdisk_ids: A list of strings with the image IDs wanted :type owners: list :param owners: A list of owner IDs :rt...
2.541247
2.510645
1.012189
params = {} if name: params['Name'] = name if description: params['Description'] = description if architecture: params['Architecture'] = architecture if kernel_id: params['KernelId'] = kernel_id if ramdisk_id: ...
def register_image(self, name=None, description=None, image_location=None, architecture=None, kernel_id=None, ramdisk_id=None, root_device_name=None, block_device_map=None)
Register an image. :type name: string :param name: The name of the AMI. Valid only for EBS-based images. :type description: string :param description: The description of the AMI. :type image_location: string :param image_location: Full path to your AMI manifest in ...
1.662182
1.75702
0.946023
snapshot_id = None if delete_snapshot: image = self.get_image(image_id) for key in image.block_device_mapping: if key == "/dev/sda1": snapshot_id = image.block_device_mapping[key].snapshot_id break result =...
def deregister_image(self, image_id, delete_snapshot=False)
Unregister an AMI. :type image_id: string :param image_id: the ID of the Image to unregister :type delete_snapshot: bool :param delete_snapshot: Set to True if we should delete the snapshot associated with an EBS volume mo...
3.044813
3.169589
0.960633
params = {'InstanceId' : instance_id, 'Name' : name} if description: params['Description'] = description if no_reboot: params['NoReboot'] = 'true' img = self.get_object('CreateImage', params, Image, verb='POST') return img.id
def create_image(self, instance_id, name, description=None, no_reboot=False)
Will create an AMI from the instance in the running or stopped state. :type instance_id: string :param instance_id: the ID of the instance to image. :type name: string :param name: The name of the new image :type description: string :param description: An optio...
2.397269
3.026266
0.792154
params = {'ImageId' : image_id, 'Attribute' : attribute} return self.get_object('DescribeImageAttribute', params, ImageAttribute, verb='POST')
def get_image_attribute(self, image_id, attribute='launchPermission')
Gets an attribute from an image. :type image_id: string :param image_id: The Amazon image id for which you want info about :type attribute: string :param attribute: The attribute you need information about. Valid choices are: * launch...
3.299665
4.100434
0.804711
params = {'ImageId' : image_id, 'Attribute' : attribute, 'OperationType' : operation} if user_ids: self.build_list_params(params, user_ids, 'UserId') if groups: self.build_list_params(params, groups, 'UserGroup') if pro...
def modify_image_attribute(self, image_id, attribute='launchPermission', operation='add', user_ids=None, groups=None, product_codes=None)
Changes an attribute of an image. :type image_id: string :param image_id: The image id you wish to change :type attribute: string :param attribute: The attribute you wish to change :type operation: string :param operation: Either add or remove (this is required for cha...
1.630746
1.902003
0.857384
params = {'ImageId' : image_id, 'Attribute' : attribute} return self.get_status('ResetImageAttribute', params, verb='POST')
def reset_image_attribute(self, image_id, attribute='launchPermission')
Resets an attribute of an AMI to its default value. :type image_id: string :param image_id: ID of the AMI for which an attribute will be described :type attribute: string :param attribute: The attribute to reset :rtype: bool :return: Whether the operation succeeded or ...
3.019081
4.707342
0.641356
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') if filters: if 'group-id' in filters: gid = filters.get('group-id') if not gid.startswith('sg-') or len(gid) != 11: warning...
def get_all_instances(self, instance_ids=None, filters=None)
Retrieve all the instances associated with your account. :type instance_ids: list :param instance_ids: A list of strings of instance IDs :type filters: dict :param filters: Optional filters that can be used to limit the results returned. Filters are provided ...
3.124298
2.866444
1.089956
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') if max_results: params['MaxResults'] = max_results if next_token: params['NextToken'] = next_token if filters: self.build_filter_params...
def get_all_instance_status(self, instance_ids=None, max_results=None, next_token=None, filters=None)
Retrieve all the instances in your account scheduled for maintenance. :type instance_ids: list :param instance_ids: A list of strings of instance IDs :type max_results: int :param max_results: The maximum number of paginated instance items per response. :type next_...
1.751208
2.075183
0.843881
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') return self.get_list('TerminateInstances', params, [('item', Instance)], verb='POST')
def terminate_instances(self, instance_ids=None)
Terminate the instances specified :type instance_ids: list :param instance_ids: A list of strings of the Instance IDs to terminate :rtype: list :return: A list of the instances terminated
3.035353
4.521245
0.671353
params = {} if force: params['Force'] = 'true' if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') return self.get_list('StopInstances', params, [('item', Instance)], verb='POST')
def stop_instances(self, instance_ids=None, force=False)
Stop the instances specified :type instance_ids: list :param instance_ids: A list of strings of the Instance IDs to stop :type force: bool :param force: Forces the instance to stop :rtype: list :return: A list of the instances stopped
2.619167
3.966516
0.660319
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') return self.get_list('StartInstances', params, [('item', Instance)], verb='POST')
def start_instances(self, instance_ids=None)
Start the instances specified :type instance_ids: list :param instance_ids: A list of strings of the Instance IDs to start :rtype: list :return: A list of the instances started
3.191247
4.783309
0.667163
params = {} self.build_list_params(params, [instance_id], 'InstanceId') return self.get_object('GetConsoleOutput', params, ConsoleOutput, verb='POST')
def get_console_output(self, instance_id)
Retrieves the console output for the specified instance. :type instance_id: string :param instance_id: The instance ID of a running instance on the cloud. :rtype: :class:`boto.ec2.instance.ConsoleOutput` :return: The console output as a ConsoleOutput object
3.857909
4.397923
0.877212
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') return self.get_status('RebootInstances', params)
def reboot_instances(self, instance_ids=None)
Reboot the specified instances. :type instance_ids: list :param instance_ids: The instances to terminate and reboot
2.362263
4.318534
0.547006
params = {'InstanceId' : instance_id} if attribute: params['Attribute'] = attribute return self.get_object('DescribeInstanceAttribute', params, InstanceAttribute, verb='POST')
def get_instance_attribute(self, instance_id, attribute)
Gets an attribute from an instance. :type instance_id: string :param instance_id: The Amazon id of the instance :type attribute: string :param attribute: The attribute you need information about Valid choices are: * instanceType|kern...
3.459135
4.151667
0.833192
# Allow a bool to be passed in for value of disableApiTermination if attribute == 'disableApiTermination': if isinstance(value, bool): if value: value = 'true' else: value = 'false' params = {'InstanceId...
def modify_instance_attribute(self, instance_id, attribute, value)
Changes an attribute of an instance :type instance_id: string :param instance_id: The instance id you wish to change :type attribute: string :param attribute: The attribute you wish to change. * AttributeName - Expected value (default) ...
3.209333
3.351214
0.957663
params = {'InstanceId' : instance_id, 'Attribute' : attribute} return self.get_status('ResetInstanceAttribute', params, verb='POST')
def reset_instance_attribute(self, instance_id, attribute)
Resets an attribute of an instance to its default value. :type instance_id: string :param instance_id: ID of the instance :type attribute: string :param attribute: The attribute to reset. Valid values are: kernel|ramdisk :rtype: bool :return: ...
3.425219
4.93769
0.693689
params = {} if request_ids: self.build_list_params(params, request_ids, 'SpotInstanceRequestId') if filters: if 'launch.group-id' in filters: lgid = filters.get('launch.group-id') if not lgid.startswith('sg-') or len(lgid) != 11: ...
def get_all_spot_instance_requests(self, request_ids=None, filters=None)
Retrieve all the spot instances requests associated with your account. :type request_ids: list :param request_ids: A list of strings of spot instance request IDs :type filters: dict :param filters: Optional filters that can be used to limit the results returned....
2.914209
2.931118
0.994231
params = {} if start_time: params['StartTime'] = start_time if end_time: params['EndTime'] = end_time if instance_type: params['InstanceType'] = instance_type if product_description: params['ProductDescription'] = product_d...
def get_spot_price_history(self, start_time=None, end_time=None, instance_type=None, product_description=None, availability_zone=None)
Retrieve the recent history of spot instances pricing. :type start_time: str :param start_time: An indication of how far back to provide price changes for. An ISO8601 DateTime string. :type end_time: str :param end_time: An indication of how far forward to pr...
1.526076
1.782962
0.855922
params = {} if request_ids: self.build_list_params(params, request_ids, 'SpotInstanceRequestId') return self.get_list('CancelSpotInstanceRequests', params, [('item', Instance)], verb='POST')
def cancel_spot_instance_requests(self, request_ids)
Cancel the specified Spot Instance Requests. :type request_ids: list :param request_ids: A list of strings of the Request IDs to terminate :rtype: list :return: A list of the instances terminated
3.107197
4.55284
0.682475
params = {'Bucket' : bucket} if prefix: params['Prefix'] = prefix return self.get_object('CreateSpotDatafeedSubscription', params, SpotDatafeedSubscription, verb='POST')
def create_spot_datafeed_subscription(self, bucket, prefix)
Create a spot instance datafeed subscription for this account. :type bucket: str or unicode :param bucket: The name of the bucket where spot instance data will be written. The account issuing this request must have FULL_CONTROL access to the bucket ...
3.955663
3.925985
1.007559
params = {} if zones: self.build_list_params(params, zones, 'ZoneName') if filters: self.build_filter_params(params, filters) return self.get_list('DescribeAvailabilityZones', params, [('item', Zone)], verb='POST')
def get_all_zones(self, zones=None, filters=None)
Get all Availability Zones associated with the current region. :type zones: list :param zones: Optional list of zones. If this list is present, only the Zones associated with these zone names will be returned. :type filters: dict :param filt...
2.590912
2.444877
1.059731
params = {} if addresses: self.build_list_params(params, addresses, 'PublicIp') if allocation_ids: self.build_list_params(params, allocation_ids, 'AllocationId') if filters: self.build_filter_params(params, filters) return self.get_lis...
def get_all_addresses(self, addresses=None, filters=None, allocation_ids=None)
Get all EIP's associated with the current credentials. :type addresses: list :param addresses: Optional list of addresses. If this list is present, only the Addresses associated with these addresses will be returned. :type filters: dict ...
1.970562
2.23924
0.880014
params = {} if domain is not None: params['Domain'] = domain return self.get_object('AllocateAddress', params, Address, verb='POST')
def allocate_address(self, domain=None)
Allocate a new Elastic IP address and associate it with your account. :rtype: :class:`boto.ec2.address.Address` :return: The newly allocated Address
3.925925
4.959045
0.79167
params = { 'InstanceId' : instance_id } if public_ip is not None: params['PublicIp'] = public_ip elif allocation_id is not None: params['AllocationId'] = allocation_id return self.get_status('AssociateAddress', params, verb='POST')
def associate_address(self, instance_id, public_ip=None, allocation_id=None)
Associate an Elastic IP address with a currently running instance. This requires one of ``public_ip`` or ``allocation_id`` depending on if you're associating a VPC address or a plain EC2 address. :type instance_id: string :param instance_id: The ID of the instance :type public_...
1.971608
2.48015
0.794955
params = {} if public_ip is not None: params['PublicIp'] = public_ip elif association_id is not None: params['AssociationId'] = association_id return self.get_status('DisassociateAddress', params, verb='POST')
def disassociate_address(self, public_ip=None, association_id=None)
Disassociate an Elastic IP address from a currently running instance. :type public_ip: string :param public_ip: The public IP address for EC2 elastic IPs. :type association_id: string :param association_id: The association ID for a VPC based elastic ip. :rtype: bool :r...
2.06397
2.799627
0.73723
params = {} if public_ip is not None: params['PublicIp'] = public_ip elif allocation_id is not None: params['AllocationId'] = allocation_id return self.get_status('ReleaseAddress', params, verb='POST')
def release_address(self, public_ip=None, allocation_id=None)
Free up an Elastic IP address. :type public_ip: string :param public_ip: The public IP address for EC2 elastic IPs. :type allocation_id: string :param allocation_id: The ID for VPC elastic IPs. :rtype: bool :return: True if successful
2.247951
2.735177
0.821867