_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q39400
get_version
train
def get_version(): """Reads version number. This workaround is required since __init__ is an entry point exposing stuff from other modules, which may use dependencies unavailable in current environment, which in turn will prevent this application from install. """ contents = read(os.path.j...
python
{ "resource": "" }
q39401
fromfilenames
train
def fromfilenames(filenames, coltype = int): """ Return a segmentlist describing the intervals spanned by the files whose names are given in the list filenames. The segmentlist is constructed by parsing the file names, and the boundaries of each segment are coerced to type coltype. The file names are parsed usi...
python
{ "resource": "" }
q39402
fromlalcache
train
def fromlalcache(cachefile, coltype = int): """ Construct a segmentlist representing the times spanned by the files identified in the LAL cache contained in the file object file. The segmentlist will be created with segments whose boundaries are of type coltype, which should raise ValueError if it cannot convert ...
python
{ "resource": "" }
q39403
S2playground
train
def S2playground(extent): """ Return a segmentlist identifying the S2 playground times within the interval defined by the segment extent. Example: >>> from pycbc_glue import segments >>> S2playground(segments.segment(874000000, 874010000)) [segment(874000013, 874000613), segment(874006383, 874006983)] """ lo...
python
{ "resource": "" }
q39404
vote
train
def vote(seglists, n): """ Given a sequence of segmentlists, returns the intervals during which at least n of them intersect. The input segmentlists must be coalesced, the output is coalesced. Example: >>> from pycbc_glue.segments import * >>> w = segmentlist([segment(0, 15)]) >>> x = segmentlist([segment(5,...
python
{ "resource": "" }
q39405
validate_proxy
train
def validate_proxy(path): """Validate the users X509 proxy certificate Tests that the proxy certificate is RFC 3820 compliant and that it is valid for at least the next 15 minutes. @returns: L{True} if the certificate validates @raises RuntimeError: if the certificate cannot be validated """ ...
python
{ "resource": "" }
q39406
find_credential
train
def find_credential(): """Locate the users X509 certificate and key files This method uses the C{X509_USER_CERT} and C{X509_USER_KEY} to locate valid proxy information. If those are not found, the standard location in /tmp/ is searched. @raises RuntimeError: if the proxy found via either method ca...
python
{ "resource": "" }
q39407
find_server
train
def find_server(): """Find the default server host from the environment This method uses the C{LIGO_DATAFIND_SERVER} variable to construct a C{(host, port)} tuple. @returns: C{(host, port)}: the L{str} host name and L{int} port number @raises RuntimeError: if the C{LIGO_DATAFIND_SERVER} environme...
python
{ "resource": "" }
q39408
GWDataFindHTTPConnection._requestresponse
train
def _requestresponse(self, method, url, body=None, headers={}): """Internal method to perform request and verify reponse. @param method: name of the method to use (e.g. 'GET') @param url : remote URL to query @type method: L{str} @type url : L{str} @returns: L{st...
python
{ "resource": "" }
q39409
GWDataFindHTTPConnection.find_observatories
train
def find_observatories(self, match=None): """Query the LDR host for observatories. Use match to restrict returned observatories to those matching the regular expression. Example: >>> connection.find_observatories() ['AGHLT', 'G', 'GHLTV', 'GHLV', 'GHT', 'H', 'HL', 'HLT'...
python
{ "resource": "" }
q39410
GWDataFindHTTPConnection.find_types
train
def find_types(self, site=None, match=None): """Query the LDR host for frame types. Use site to restrict query to given observatory prefix, and use match to restrict returned types to those matching the regular expression. Example: >>> connection.find_types("L", "RDS") ...
python
{ "resource": "" }
q39411
GWDataFindHTTPConnection.find_times
train
def find_times(self, site, frametype, gpsstart=None, gpsend=None): """Query the LDR for times for which frames are avaliable Use gpsstart and gpsend to restrict the returned times to this semiopen interval. @returns: L{segmentlist<pycbc_glue.segments.segmentlist>} @param site:...
python
{ "resource": "" }
q39412
GWDataFindHTTPConnection.find_frame
train
def find_frame(self, framefile, urltype=None, on_missing="warn"): """Query the LDR host for a single framefile @returns: L{Cache<pycbc_glue.lal.Cache>} @param frametype: name of frametype to match @param urltype: file scheme to search for (e.g. 'file') @...
python
{ "resource": "" }
q39413
GWDataFindHTTPConnection.find_frame_urls
train
def find_frame_urls(self, site, frametype, gpsstart, gpsend, match=None, urltype=None, on_gaps="warn"): """Find the framefiles for the given type in the [start, end) interval frame @param site: single-character name of site to match @param frametype: ...
python
{ "resource": "" }
q39414
WalkChildren
train
def WalkChildren(elem): """ Walk the XML tree of children below elem, returning each in order. """ for child in elem.childNodes: yield child for elem in WalkChildren(child): yield elem
python
{ "resource": "" }
q39415
make_parser
train
def make_parser(handler): """ Convenience function to construct a document parser with namespaces enabled and validation disabled. Document validation is a nice feature, but enabling validation can require the LIGO LW DTD to be downloaded from the LDAS document server if the DTD is not included inline in the XML...
python
{ "resource": "" }
q39416
Element.appendChild
train
def appendChild(self, child): """ Add a child to this element. The child's parentNode attribute is updated, too. """ self.childNodes.append(child) child.parentNode = self self._verifyChildren(len(self.childNodes) - 1) return child
python
{ "resource": "" }
q39417
Element.insertBefore
train
def insertBefore(self, newchild, refchild): """ Insert a new child node before an existing child. It must be the case that refchild is a child of this node; if not, ValueError is raised. newchild is returned. """ for i, childNode in enumerate(self.childNodes): if childNode is refchild: self.childNode...
python
{ "resource": "" }
q39418
Element.replaceChild
train
def replaceChild(self, newchild, oldchild): """ Replace an existing node with a new node. It must be the case that oldchild is a child of this node; if not, ValueError is raised. newchild is returned. """ # .index() would use compare-by-value, we want # compare-by-id because we want to find the exact obje...
python
{ "resource": "" }
q39419
Element.appendData
train
def appendData(self, content): """ Add characters to the element's pcdata. """ if self.pcdata is not None: self.pcdata += content else: self.pcdata = content
python
{ "resource": "" }
q39420
Column.start_tag
train
def start_tag(self, indent): """ Generate the string for the element's start tag. """ return u"%s<%s%s/>" % (indent, self.tagName, u"".join(u" %s=\"%s\"" % keyvalue for keyvalue in self.attributes.items()))
python
{ "resource": "" }
q39421
Time.from_gps
train
def from_gps(cls, gps, Name = None): """ Instantiate a Time element initialized to the value of the given GPS time. The Name attribute will be set to the value of the Name parameter if given. Note: the new Time element holds a reference to the GPS time, not a copy of it. Subsequent modification of the G...
python
{ "resource": "" }
q39422
Document.write
train
def write(self, fileobj = sys.stdout, xsl_file = None): """ Write the document. """ fileobj.write(Header) fileobj.write(u"\n") if xsl_file is not None: fileobj.write(u'<?xml-stylesheet type="text/xsl" href="%s" ?>\n' % xsl_file) for c in self.childNodes: if c.tagName not in self.validchildren: r...
python
{ "resource": "" }
q39423
SimpleLWXMLParser.start_element
train
def start_element(self, name, attrs): """ Callback for start of an XML element. Checks to see if we are about to start a table that matches the ignore pattern. @param name: the name of the tag being opened @type name: string @param attrs: a dictionary of the attributes for the tag being opened...
python
{ "resource": "" }
q39424
SimpleLWXMLParser.parse_line
train
def parse_line(self, line): """ For each line we are passed, call the XML parser. Returns the line if we are outside one of the ignored tables, otherwise returns the empty string. @param line: the line of the LIGO_LW XML file to be parsed @type line: string @return: the line of XML passed ...
python
{ "resource": "" }
q39425
LDBDClient.ping
train
def ping(self): """ Ping the LDBD Server and return any message received back as a string. @return: message received (may be empty) from LDBD Server as a string """ msg = "PING\0" self.sfile.write(msg) ret, output = self.__response__() reply = str(output[0]) if ret: msg = "...
python
{ "resource": "" }
q39426
LDBDClient.query
train
def query(self,sql): """ Execute an SQL query on the server and fetch the resulting XML file back. @return: message received (may be empty) from LDBD Server as a string """ msg = "QUERY\0" + sql + "\0" self.sfile.write(msg) ret, output = self.__response__() reply = str(output[0]) ...
python
{ "resource": "" }
q39427
julianDay
train
def julianDay(year, month, day): "returns julian day=day since Jan 1 of year" hr = 12 #make sure you fall into right day, middle is save t = time.mktime((year, month, day, hr, 0, 0.0, 0, 0, -1)) julDay = time.localtime(t)[7] return julDay
python
{ "resource": "" }
q39428
mkUTC
train
def mkUTC(year, month, day, hour, min, sec): "similar to python's mktime but for utc" spec = [year, month, day, hour, min, sec] + [0, 0, 0] utc = time.mktime(spec) - time.timezone return utc
python
{ "resource": "" }
q39429
UTCFromGps
train
def UTCFromGps(gpsWeek, SOW, leapSecs=14): """converts gps week and seconds to UTC see comments of inverse function! SOW = seconds of week gpsWeek is the full number (not modulo 1024) """ secFract = SOW % 1 epochTuple = gpsEpoch + (-1, -1, 0) t0 = time.mktime(epochTuple) - time.timezo...
python
{ "resource": "" }
q39430
GpsSecondsFromPyUTC
train
def GpsSecondsFromPyUTC( pyUTC, leapSecs=14 ): """converts the python epoch to gps seconds pyEpoch = the python epoch from time.time() """ t = t=gpsFromUTC(*ymdhmsFromPyUTC( pyUTC )) return int(t[0] * 60 * 60 * 24 * 7 + t[1])
python
{ "resource": "" }
q39431
genMeme
train
def genMeme(template_id, text0, text1): ''' This function returns the url of the meme with the given template, upper text, and lower text using the ImgFlip meme generation API. Thanks! Returns None if it is unable to generate the meme. ''' username = 'blag' password = 'blag' api_u...
python
{ "resource": "" }
q39432
string_format_func
train
def string_format_func(s): """ Function used internally to format string data for output to XML. Escapes back-slashes and quotes, and wraps the resulting string in quotes. """ return u"\"%s\"" % unicode(s).replace(u"\\", u"\\\\").replace(u"\"", u"\\\"")
python
{ "resource": "" }
q39433
mk_complex_format_func
train
def mk_complex_format_func(fmt): """ Function used internally to generate functions to format complex valued data. """ fmt = fmt + u"+i" + fmt def complex_format_func(z): return fmt % (z.real, z.imag) return complex_format_func
python
{ "resource": "" }
q39434
fields
train
def fields(iterable, fields=None): """ Add a set of fields to each item in ``iterable``. The set of fields have a key=value format. '@' are added to the front of each key. """ if not fields: for item in iterable: yield item prepared_fields = _prepare_fields(fields) for ...
python
{ "resource": "" }
q39435
PlugItAPI._request
train
def _request(self, uri, params=None, postParams=None, verb='GET'): """Execute a request on the plugit api""" return getattr(requests, verb.lower())(self.url + uri, params=params, data=postParams, stream=True)
python
{ "resource": "" }
q39436
PlugItAPI.get_user
train
def get_user(self, userPk): """Returns the user specified with the user's Pk or UUID""" r = self._request('user/' + str(userPk)) if r: # Set base properties and copy data inside the user u = User() u.pk = u.id = userPk u.__dict__.update(r.json()) ...
python
{ "resource": "" }
q39437
PlugItAPI.get_subscription_labels
train
def get_subscription_labels(self, userPk): """Returns a list with all the labels the user is subscribed to""" r = self._request('subscriptions/' + str(userPk)) if r: s = r.json() return s return []
python
{ "resource": "" }
q39438
PlugItAPI.get_orgas
train
def get_orgas(self): """Return the list of pk for all orgas""" r = self._request('orgas/') if not r: return None retour = [] for data in r.json()['data']: o = Orga() o.__dict__.update(data) o.pk = o.id retour.append(...
python
{ "resource": "" }
q39439
PlugItAPI.get_orga
train
def get_orga(self, orgaPk): """Return an organization speficied with orgaPk""" r = self._request('orga/' + str(orgaPk)) if r: # Set base properties and copy data inside the orga o = Orga() o.pk = o.id = orgaPk o.__dict__.update(r.json()) ...
python
{ "resource": "" }
q39440
PlugItAPI.get_project_members
train
def get_project_members(self): """Return the list of members in the project""" r = self._request('members/') if not r: return None retour = [] for data in r.json()['members']: # Base properties u = User() u.__dict__.update(data) ...
python
{ "resource": "" }
q39441
PlugItAPI.send_mail
train
def send_mail(self, sender, subject, recipients, message, response_id=None, html_message=False): """Send an email using EBUio features. If response_id is set, replies will be send back to the PlugIt server.""" params = { 'sender': sender, 'subject': subject, 'dests':...
python
{ "resource": "" }
q39442
PlugItAPI.forum_create_topic
train
def forum_create_topic(self, subject, author, message, tags=""): """Create a topic using EBUio features.""" params = {'subject': subject, 'author': author, 'message': message, 'tags': tags} return self._request('ebuio/forum/', postParams=params, verb='POST')
python
{ "resource": "" }
q39443
PlugItAPI.forum_topic_get_by_tag_for_user
train
def forum_topic_get_by_tag_for_user(self, tag=None, author=None): """Get all forum topics with a specific tag""" if not tag: return None if author: r = self._request('ebuio/forum/search/bytag/' + tag + '?u=' + author) else: r = self._request('ebuio/f...
python
{ "resource": "" }
q39444
get_for_directory
train
def get_for_directory( dp, hash_mode="md5", filter_dots=False, filter_func=lambda fp:False ): r""" Returns a hash string for the files below a given directory path. :param dp: Path to a directory. :param hash_mode: Can be either one of 'md5', '...
python
{ "resource": "" }
q39445
get_for_file
train
def get_for_file( fp, hash_mode="md5" ): r""" Returns a hash string for the given file path. :param fp: Path to the file. :param hash_mode: Can be either one of 'md5', 'sha1', 'sha256' or 'sha512'. Defines the algorithm used to generate the resulting h...
python
{ "resource": "" }
q39446
get_for_handle
train
def get_for_handle( f, hash_mode="md5" ): r""" Returns a hash string for the given file-like object. :param f: The file object. :param hash_mode: Can be either one of 'md5', 'sha1', 'sha256' or 'sha512'. Defines the algorithm used to generate the resu...
python
{ "resource": "" }
q39447
getArraysByName
train
def getArraysByName(elem, name): """ Return a list of arrays with name name under elem. """ name = StripArrayName(name) return elem.getElements(lambda e: (e.tagName == ligolw.Array.tagName) and (e.Name == name))
python
{ "resource": "" }
q39448
from_array
train
def from_array(name, array, dim_names = None): """ Construct a LIGO Light Weight XML Array document subtree from a numpy array object. Example: >>> import numpy, sys >>> a = numpy.arange(12, dtype = "double") >>> a.shape = (4, 3) >>> from_array(u"test", a).write(sys.stdout) # doctest: +NORMALIZE_WHITESPACE <...
python
{ "resource": "" }
q39449
get_array
train
def get_array(xmldoc, name): """ Scan xmldoc for an array named name. Raises ValueError if not exactly 1 such array is found. """ arrays = getArraysByName(xmldoc, name) if len(arrays) != 1: raise ValueError("document must contain exactly one %s array" % StripArrayName(name)) return arrays[0]
python
{ "resource": "" }
q39450
use_in
train
def use_in(ContentHandler): """ Modify ContentHandler, a sub-class of pycbc_glue.ligolw.LIGOLWContentHandler, to cause it to use the Array and ArrayStream classes defined in this module when parsing XML documents. Example: >>> from pycbc_glue.ligolw import ligolw >>> class MyContentHandler(ligolw.LIGOLWConten...
python
{ "resource": "" }
q39451
Array.get_shape
train
def get_shape(self): """ Return a tuple of this array's dimensions. This is done by querying the Dim children. Note that once it has been created, it is also possible to examine an Array object's .array attribute directly, and doing that is much faster. """ return tuple(int(c.pcdata) for c in self.getEl...
python
{ "resource": "" }
q39452
get_all_files_in_range
train
def get_all_files_in_range(dirname, starttime, endtime, pad=64): """Returns all files in dirname and all its subdirectories whose names indicate that they contain segments in the range starttime to endtime""" ret = [] # Maybe the user just wants one file... if os.path.isfile(dirname): ...
python
{ "resource": "" }
q39453
ensure_segment_table
train
def ensure_segment_table(connection): """Ensures that the DB represented by connection posses a segment table. If not, creates one and prints a warning to stderr""" count = connection.cursor().execute("SELECT count(*) FROM sqlite_master WHERE name='segment'").fetchone()[0] if count == 0: print...
python
{ "resource": "" }
q39454
build_segment_list_one
train
def build_segment_list_one(engine, gps_start_time, gps_end_time, ifo, segment_name, version = None, start_pad = 0, end_pad = 0): """Builds a list of segments satisfying the given criteria """ seg_result = segmentlist([]) sum_result = segmentlist([]) # Is there any way to get segment and segement summar...
python
{ "resource": "" }
q39455
run_query_segments
train
def run_query_segments(doc, proc_id, engine, gps_start_time, gps_end_time, included_segments_string, excluded_segments_string = None, write_segments = True, start_pad = 0, end_pad = 0): """Runs a segment query. This was originally part of ligolw_query_segments, but now is also used by ligolw_segments_from_cats...
python
{ "resource": "" }
q39456
url2path
train
def url2path(url): """ If url identifies a file on the local host, return the path to the file otherwise raise ValueError. """ scheme, host, path, nul, nul, nul = urlparse(url) if scheme.lower() in ("", "file") and host.lower() in ("", "localhost"): return path raise ValueError(url)
python
{ "resource": "" }
q39457
remove_input
train
def remove_input(urls, preserves, verbose = False): """ Attempt to delete all files identified by the URLs in urls except any that are the same as the files in the preserves list. """ for path in map(url2path, urls): if any(os.path.samefile(path, preserve) for preserve in preserves): continue if verbose: ...
python
{ "resource": "" }
q39458
reassign_ids
train
def reassign_ids(doc, verbose = False): """ Assign new IDs to all rows in all LSC tables in doc so that there are no collisions when the LIGO_LW elements are merged. """ # Can't simply run reassign_ids() on doc because we need to # construct a fresh old --> new mapping within each LIGO_LW block. for n, elem in e...
python
{ "resource": "" }
q39459
merge_ligolws
train
def merge_ligolws(elem): """ Merge all LIGO_LW elements that are immediate children of elem by appending their children to the first. """ ligolws = [child for child in elem.childNodes if child.tagName == ligolw.LIGO_LW.tagName] if ligolws: dest = ligolws.pop(0) for src in ligolws: # copy children; LIGO_LW...
python
{ "resource": "" }
q39460
merge_compatible_tables
train
def merge_compatible_tables(elem): """ Below the given element, find all Tables whose structure is described in lsctables, and merge compatible ones of like type. That is, merge all SnglBurstTables that have the same columns into a single table, etc.. """ for name in lsctables.TableByName.keys(): tables = tabl...
python
{ "resource": "" }
q39461
Climb.run
train
def run(self): """Loops and executes commands in interactive mode.""" if self._skip_delims: delims = readline.get_completer_delims() for delim in self._skip_delims: delims = delims.replace(delim, '') readline.set_completer_delims(delims) readl...
python
{ "resource": "" }
q39462
Climb.execute
train
def execute(self, *args): """Executes single command and returns result.""" command, kwargs = self.parse(*args) return self._commands.execute(command, **kwargs)
python
{ "resource": "" }
q39463
gcommer_donate_threaded
train
def gcommer_donate_threaded(interval=5, region='EU-London', mode=None): """ Run a daemon thread that requests and donates a token every `interval` seconds. """ def donate_thread(): while 1: gcommer_donate(*find_server(region, mode)) time.sleep(interval) Thread(ta...
python
{ "resource": "" }
q39464
Xlator._make_regex
train
def _make_regex(self): """ Build a re object based on keys in the current dictionary """ return re.compile("|".join(map(re.escape, self.keys())))
python
{ "resource": "" }
q39465
LIGOLwParser.__lstring
train
def __lstring(self,lstr): """ Returns a parsed lstring by stripping out and instances of the escaped delimiter. Sometimes the raw lstring has whitespace and a double quote at the beginning or end. If present, these are removed. """ lstr = self.llsrx.sub('',lstr.encode('ascii')) lstr = se...
python
{ "resource": "" }
q39466
LIGOMetadata.parse
train
def parse(self,xml): """ Parses an XML document into a form read for insertion into the database xml = the xml document to be parsed """ if not self.xmlparser: raise LIGOLwParseError, "pyRXP parser not initialized" if not self.lwtparser: raise LIGOLwParseError, "LIGO_LW tuple parser...
python
{ "resource": "" }
q39467
LIGOMetadata.add_lfn
train
def add_lfn(self,lfn): """ Add an LFN table to a parsed LIGO_LW XML document. lfn = lfn to be added """ if len(self.table['process']['stream']) > 1: msg = "cannot add lfn to table with more than one process" raise LIGOLwParseError, msg # get the process_id from the process table ...
python
{ "resource": "" }
q39468
LIGOMetadata.set_dn
train
def set_dn(self,dn): """ Use the domain column in the process table to store the DN dn = dn to be added """ try: domain_col = self.table['process']['orderedcol'].index('domain') for row_idx in range(len(self.table['process']['stream'])): row_list = list(self.table['process']['st...
python
{ "resource": "" }
q39469
LIGOMetadata.insert
train
def insert(self): """Insert the object into the database""" if not self.curs: raise LIGOLwDBError, "Database connection not initalized" if len(self.table) == 0: raise LIGOLwDBError, 'attempt to insert empty table' for tab in self.table.keys(): # find and add any missing unique ids ...
python
{ "resource": "" }
q39470
LIGOMetadata.select
train
def select(self,sql): """ Execute an SQL select statement and stuff the results into a dictionary. sql = the (case sensitve) SQL statment to execute """ if not self.curs: raise LIGOLwDBError, "Database connection not initalized" if len(self.table) != 0: raise LIGOLwDBError, 'att...
python
{ "resource": "" }
q39471
Model.add
train
def add(self, name, priority=3, comment="", parent=""): """Adds new item to the model. Name argument may contain (ref:) syntax, which will be stripped down as needed. :parent: should have a form "<itemref>.<subitemref...>" (e.g. "1.1"). :name: Name (with refs). :priori...
python
{ "resource": "" }
q39472
Model.remove
train
def remove(self, index): """Removes specified item from the model. :index: Should have a form "<itemref>.<subitemref...>" (e.g. "1.1"). :index: Item's index. """ data = self.data index = self._split(index) for j, c in enumerate(index): i = int(c) - ...
python
{ "resource": "" }
q39473
Model._modifyInternal
train
def _modifyInternal(self, *, sort=None, purge=False, done=None): """Creates a whole new database from existing one, based on given modifiers. :sort: pattern should look like this: ([(<index>, True|False)], {<level_index>: [(<index>, True|False)]}), where True|False indicate whet...
python
{ "resource": "" }
q39474
Model.modify
train
def modify(self, *, sort=None, purge=False, done=None): """Calls Model._modifyInternal after loading the database.""" return self._modifyInternal(sort=sort, purge=purge, done=done)
python
{ "resource": "" }
q39475
Model.modifyInPlace
train
def modifyInPlace(self, *, sort=None, purge=False, done=None): """Like Model.modify, but changes existing database instead of returning a new one.""" self.data = self.modify(sort=sort, purge=purge, done=done)
python
{ "resource": "" }
q39476
CodeContainer.add_line
train
def add_line(self, string): """ Adds a line to the LISP code to execute :param string: The line to add :return: None """ self.code_strings.append(string) code = '' if len(self.code_strings) == 1: code = '(setv result ' + self.code_strings[0] +...
python
{ "resource": "" }
q39477
CodeContainer.add_graph_to_namespace
train
def add_graph_to_namespace(self, graph): """ Adds the variables name to the namespace of the local LISP code :param graph: the graph to add to the namespace :return: None """ for node in graph.vs: attributes = node.attributes() self.namespace[node...
python
{ "resource": "" }
q39478
CodeContainer.execute
train
def execute(self, vertices_substitution_dict={}): """ Executes the code :param vertices_substitution_dict: aliases of the variables in the code :return: True/False, depending on the result of the code (default is True) """ if not self.code_strings: return Tr...
python
{ "resource": "" }
q39479
Client.droplets
train
def droplets(self): """ This method returns the list of droplets """ json = self.request('/droplets/', method='GET') status = json.get('status') if status == 'OK': droplet_json = json.get('droplets', []) droplets = [Droplet.from_json(droplet) for d...
python
{ "resource": "" }
q39480
Client.reboot_droplet
train
def reboot_droplet(self, droplet_id): """ This method allows you to reboot a droplet. This is the preferred method to use if a server is not responding. """ if not droplet_id: raise DOPException('droplet_id is required to reboot a droplet!') json = self.reques...
python
{ "resource": "" }
q39481
Client.power_cycle_droplet
train
def power_cycle_droplet(self, droplet_id): """ This method allows you to power cycle a droplet. This will turn off the droplet and then turn it back on. """ if not droplet_id: msg = 'droplet_id is required to power cycle a droplet!' raise DOPException(msg)...
python
{ "resource": "" }
q39482
Client.resize_droplet
train
def resize_droplet(self, droplet_id, size): """ This method allows you to resize a specific droplet to a different size. This will affect the number of processors and memory allocated to the droplet. Required parameters: droplet_id: Integer, this is the id o...
python
{ "resource": "" }
q39483
Client.restore_droplet
train
def restore_droplet(self, droplet_id, image_id): """ This method allows you to restore a droplet with a previous image or snapshot. This will be a mirror copy of the image or snapshot to your droplet. Be sure you have backed up any necessary information prior to restore. Require...
python
{ "resource": "" }
q39484
Client.rename_droplet
train
def rename_droplet(self, droplet_id, name): """ This method allows you to reinstall a droplet with a default image. This is useful if you want to start again but retain the same IP address for your droplet. Required parameters: droplet_id: Numeric, t...
python
{ "resource": "" }
q39485
Client.destroy_droplet
train
def destroy_droplet(self, droplet_id, scrub_data=False): """ This method destroys one of your droplets - this is irreversible. Required parameters: droplet_id: Numeric, this is the id of your droplet that you want to destroy Optional parameters ...
python
{ "resource": "" }
q39486
Client.regions
train
def regions(self): """ This method will return all the available regions within the DigitalOcean cloud. """ json = self.request('/regions', method='GET') status = json.get('status') if status == 'OK': regions_json = json.get('regions', []) ...
python
{ "resource": "" }
q39487
Client.images
train
def images(self, filter='global'): """ This method returns all the available images that can be accessed by your client ID. You will have access to all public images by default, and any snapshots or backups that you have created in your own account. Optional parameters ...
python
{ "resource": "" }
q39488
Client.show_image
train
def show_image(self, image_id_or_slug): """ This method displays the attributes of an image. Required parameters image_id: Numeric, this is the id of the image you would like to use to rebuild your droplet with """ if not image_id_or_...
python
{ "resource": "" }
q39489
Client.destroy_image
train
def destroy_image(self, image_id_or_slug): """ This method allows you to destroy an image. There is no way to restore a deleted image so be careful and ensure your data is properly backed up. Required parameters image_id: Numeric, this is the id of the image...
python
{ "resource": "" }
q39490
Client.transfer_image
train
def transfer_image(self, image_id_or_slug, region_id): """ This method allows you to transfer an image to a specified region. Required parameters image_id: Numeric, this is the id of the image you would like to transfer. region_id Numeri...
python
{ "resource": "" }
q39491
Client.ssh_keys
train
def ssh_keys(self): """ This method lists all the available public SSH keys in your account that can be added to a droplet. """ params = {} json = self.request('/ssh_keys', method='GET', params=params) status = json.get('status') if status == 'OK': ...
python
{ "resource": "" }
q39492
Client.add_ssh_key
train
def add_ssh_key(self, name, ssh_pub_key): """ This method allows you to add a new public SSH key to your account. Required parameters name: String, the name you want to give this SSH key. ssh_pub_key: String, the actual public SSH key. ...
python
{ "resource": "" }
q39493
Client.show_ssh_key
train
def show_ssh_key(self, ssh_key_id): """ This method shows a specific public SSH key in your account that can be added to a droplet. """ params = {} json = self.request('/ssh_keys/%s' % ssh_key_id, method='GET', params=params) status = json.get('status') if...
python
{ "resource": "" }
q39494
Client.destroy_ssh_key
train
def destroy_ssh_key(self, ssh_key_id): """ This method will delete the SSH key from your account. """ json = self.request('/ssh_keys/%s/destroy' % ssh_key_id, method='GET') status = json.get('status') return status
python
{ "resource": "" }
q39495
Client.sizes
train
def sizes(self): """ This method returns all the available sizes that can be used to create a droplet. """ json = self.request('/sizes', method='GET') status = json.get('status') if status == 'OK': sizes_json = json.get('sizes', []) sizes =...
python
{ "resource": "" }
q39496
Client.domains
train
def domains(self): """ This method returns all of your current domains. """ json = self.request('/domains', method='GET') status = json.get('status') if status == 'OK': domains_json = json.get('domains', []) domains = [Domain.from_json(domain) for ...
python
{ "resource": "" }
q39497
Client.show_domain
train
def show_domain(self, domain_id): """ This method returns the specified domain. Required parameters domain_id: Integer or Domain Name (e.g. domain.com), specifies the domain to display. """ json = self.request('/domains/%s' % domain_i...
python
{ "resource": "" }
q39498
Client.destroy_domain
train
def destroy_domain(self, domain_id): """ This method deletes the specified domain. Required parameters domain_id: Integer or Domain Name (e.g. domain.com), specifies the domain to destroy. """ json = self.request('/domains/%s/destroy'...
python
{ "resource": "" }
q39499
Client.domain_records
train
def domain_records(self, domain_id): """ This method returns all of your current domain records. Required parameters domain_id: Integer or Domain Name (e.g. domain.com), specifies the domain for which to retrieve records. """ json = s...
python
{ "resource": "" }