code stringlengths 1 18.2k |
|---|
def execute(self, *args): """Executes single command and returns result.""" command, kwargs = self.parse(*args) return self._commands.execute(command, **kwargs) |
def gcommer_claim(address=None): """ Try to get a token for this server address. `address` has to be ip:port, e.g. `'1.2.3.4:1234'` Returns tuple(address, token) """ if not address: # get token for any world # this is only useful for testing, # because that is exactly what m.agar.io does url = 'http://at.gcommer.com/st... |
def gcommer_donate(address, token, *_): """ Donate a token for this server address. `address` and `token` should be the return values from find_server(). """ token = urllib.request.quote(token) url = 'http://at.gcommer.com/donate?server=%s&token=%s' % (address, token) response = urllib.request.urlopen(url).read().decod... |
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(target=donate_thread, daemon=True).start() |
def run(self, src_project=None, path_to_zip_file=None): """Run deploy the lambdas defined in our project. Steps: * Build Artefact * Read file or deploy to S3. It's defined in config["deploy"]["deploy_method"] * Reload conf with deploy changes * check lambda if exist * Create Lambda * Update Lambda :param src_project: s... |
def set_artefact_path(self, path_to_zip_file): """ Set the route to the local file to deploy :param path_to_zip_file: :return: """ self.config["deploy"]["deploy_file"] = path_to_zip_file return {'ZipFile': self.build.read(self.config["deploy"]["deploy_file"])} |
def build_artefact(self, src_project=None): """Run deploy the lambdas defined in our project. Steps: * Build Artefact * Read file or deploy to S3. It's defined in config["deploy"]["deploy_method"] :param src_project: str. Name of the folder or path of the project where our code lives :return: bool """ path_to_zip_file ... |
deploy_bucket, 'S3Key': s3_keyfile, } elif deploy_method == "FILE": code = {'ZipFile': self.build.read(self.config["deploy"]["deploy_file"])} else: raise Exception("No deploy_method in config") return code |
def deploy(self): """Upload code to AWS Lambda. To use this method, first, must set the zip file with code with `self.set_artefact(code=code)`. Check all lambdas in our config file or the functions passed in command line and exist in our config file. If the function is upload correctly, update/create versions, alias an... |
update funcion {}".format(conf["FunctionName"])) self.remote_update_conf_lambada(**conf) result = self.remote_update_code_lambada(**conf) logger.debug("Funcion {} updated {}".format(conf["FunctionName"], result)) else: logger.info("START to create funcion {}".format(lambda_funcion["FunctionName"])) result = self.remote... |
for trigger in lambda_funcion["triggers"].keys(): trigger_object = get_trigger(trigger, lambda_funcion, result["FunctionArn"]) trigger_object.put() if lambdas_deployed: logger.info("Deploy finished. Created/updated lambdas {}".format(", ".join(lambdas_deployed))) else: logger.info("No lambdas found to deploy") # TODO: ... |
def _make_regex(self): """ Build a re object based on keys in the current dictionary """ return re.compile("|".join(map(re.escape, self.keys()))) |
def lookup(self,istring): """ istring = the ilwd:char string corresponding to a unique id """ try: return self.uqids[istring] except KeyError: curs = self.curs curs.execute('VALUES BLOB(GENERATE_UNIQUE())') self.uqids[istring] = curs.fetchone()[0] return self.uqids[istring] |
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 = self.rlsrx.sub('',lstr) lstr = sel... |
def __ilwdchar(self,istr): """ If the ilwd:char field contains octal data, it is translated to a binary string and returned. Otherwise a lookup is done in the unique id dictionary and a binary string containing the correct unique id is returned. """ istr_orig = istr istr = self.licrx.sub('',istr.encode('ascii')) istr =... |
def parsetuple(self,xmltuple): """ Parse an XML tuple returned by pyRXP into a dictionary of LIGO metadata elements. The dictionary contains one entry for each table found in the XML tuple. """ # first extract all the table and columns from the tuple from the # children of the ligo lightweight parent tuple table = {} t... |
type in the attributes # store the index in which the columns were found as # we need this to decode the stream later for subtag in tag[2]: if subtag[0] == 'Column' or subtag[0] == 'column': col = subtag[1]['Name'].encode('ascii').lower() try: col = self.colrx.match(col).group(3) except AttributeError: raise LIGOLwPars... |
delim != ',': raise LIGOLwParseError, 'unable to handle stream delimiter: '+delim # If the result set is empty tag[2] is an empty array, which causes # the next step to fail. Add an empty string in this case. if len(tag[2]) == 0: tag[2].append("") # strip newlines from the stream and parse it stream = csv.reader([re.su... |
lst[j][k] = self.types[table[tab]['column'][thiscol]](stream[i]) except (KeyError, ValueError), errmsg: msg = "stream translation error (%s) " % str(errmsg) msg += "for column %s in table %s: %s -> %s" \ % (tab,thiscol,stream[i],str(table[tab])) raise LIGOLwParseError, msg table[tab]['stream'] = map(tuple,lst) # return... |
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 not initialized" xml = "".join([x.st... |
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 pid_col = self.table['process']['ordered... |
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']['stream'][row_idx]) row_list[domain_col] = d... |
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 generate = [] missingcols = [k for k i... |
e: self.curs.execute('rollback') raise LIGOLwDBError, e[2] #except Exception, e: # self.curs.execute('rollback') # raise LIGOLwDBError, e[2] except KeyError: pass self.curs.execute('commit') return rowcount |
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, 'attempt to fill non-empty table from databas... |
self.curs.description for col,typ,disp,intsz,prec,sca,nul in desc: try: self.table[tab]['column'][col] = sqltypes[typ] except KeyError: raise LIGOLwDBError, 'unknown type returned by database ' + str(typ) self.table[tab].setdefault('orderedcol',[]).append(col) try: self.table[tab]['stream'] = self.curs.fetchall() excep... |
def xml(self, ilwdchar_to_hex = True): """Convert a table dictionary to LIGO lightweight XML""" if len(self.table) == 0: raise LIGOLwDBError, 'attempt to convert empty table to xml' ligolw = """\ <?xml version='1.0' encoding='utf-8' ?> <?xml-stylesheet type="text/xsl" href="ligolw.xsl"?> <!DOCTYPE LIGO_LW SYSTEM "http:... |
ligolw += '\\\\%.3o' % (ord(ch)) ligolw += '"' elif re.match(r'\Ailwd:char\Z',coltype): if ilwdchar_to_hex is True: # encode in DB2-style hex (e.g., "x'deadbeef'") ligolw += '"x\'' for ch in str(tupi): ligolw += "%02x" % ord(ch) ligolw += '\'"' else: ligolw += '"' + str(tupi) + '"' elif re.match(r'\Alstring\Z',coltype)... |
ligolw += ',' colidx += 1 stridx += 1 ligolw += '\n </Stream>\n' ligolw += ' </Table>\n' ligolw += '</LIGO_LW>' return ligolw |
def parse(url): """Parses a search URL.""" config = {} url = urlparse.urlparse(url) # Remove query strings. path = url.path[1:] path = path.split('?', 2)[0] if url.scheme in SCHEMES: config["ENGINE"] = SCHEMES[url.scheme] if url.scheme in USES_URL: config["URL"] = urlparse.urlunparse(("http",) + url[1:]) if url.scheme ... |
def save(func): """@decorator: Saves data after executing :func:. Also performs modifications set as permanent options. """ def aux(self, *args, **kwargs): out = func(self, *args, **kwargs) path = (hasattr(self, 'path') and self.path or os.path.join(os.getcwd(), '.td')) gpath = (hasattr(self, 'gpath') and self.gpath or... |
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). :priority: Item's priority. :comment: Comment. :parent: It... |
def edit( self, index, name=None, priority=None, comment=None, done=None, parent=None ): """Modifies :index: to specified data. Every argument, which is not None, will get changed. If parent is not None, the item will get reparented. Use parent=-1 or parent='' for reparenting to top-level. :index: Index of the item to ... |
None: item[3] = done if parent is not None and parent != index[:-1]: parentitem = self.data for c in parent: parentitem = parentitem[int(c) - 1][4] parentitem.append(item) parent = index[:-1] parentitem = self.data for c in parent: parentitem = parentitem[int(c) - 1][4] parentitem.remove(item) |
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) - 1 if j + 1 == len(index): try: del data[i] except IndexError: raise NoI... |
def exists(self, index): """Checks whether :index: exists in the Model. :index: Index to look for. :returns: True if :index: exists in the Model, False otherwise. """ data = self.data try: for c in self._split(index): i = int(c) - 1 data = data[i][4] except Exception: return False return True |
def get(self, index): """Gets data values for specified :index:. :index: Index for which to get data. :returns: A list in form [parent, name, priority, comment, done, children]. """ data = self.data index2 = self._split(index) for c in index2[:-1]: i = int(c) - 1 data = data[i][4] return [index[:-2] or ""] + data[int(i... |
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 whether to reverse or not, <index> are one of... |
supplied arguments. """ sortAll, sortLevels = sort is not None and sort or ([], {}) doneAll, doneLevels = done is not None and done or ([], {}) def _mark(v, i): if done is None: return v[:4] def _mark_(index, regexp, du): if du is None: return v[:4] if index is None: for v_ in v[:3]: if regexp is None or re.match(regex... |
+ [_modify(v[4], i + 1)]) else: _new.append(_mark(v, i) + [_modify(v[4], i + 1)]) levels = sortLevels.get(i) or sortLevels.get(str(i)) for index, reverse in levels or sortAll: _new = sorted(_new, key=lambda e: e[index], reverse=reverse) return _new return _modify(self.data, 1) |
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) |
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) |
def setOptions(self, glob=False, **kwargs): """Set option(s). :glob: If True, stores specified options globally. :kwargs: Dictionary of options and values to set. """ if glob: self.globalOptions.update(kwargs) else: self.options.update(kwargs) |
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] + ')' if len(self.code_strings) > 1: code = '(setv result (and ' + ' '.join(se... |
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['name']] = attributes for node in graph.es: attributes = node.attributes... |
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 True if vertices_substitution_dict: namespace = self.__substitut... |
def substitute_namespace_into_graph(self, graph): """ Creates a graph from the local namespace of the code (to be used after the execution of the code) :param graph: The graph to use as a recipient of the namespace :return: the updated graph """ for key, value in self.namespace.items(): try: nodes = graph.vs.select(nam... |
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 droplet in droplet_json] return droplets else: message = json.get('messag... |
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.request('/droplets/%s/reboot' % droplet_id, method='GET') status =... |
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) json = self.request('/droplets/%s/power_cycle' % droplet_id, me... |
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 of your droplet that you want to resize size, one of size_id: N... |
json = self.request('/droplets/%s/resize' % droplet_id, method='GET', params=params) status = json.get('status') if status == 'OK': return json.get('event_id') else: message = json.get('message') raise DOPException('[%s]: %s' % (status, message)) |
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. Required parameters: droplet_id: Numeric, this i... |
DOPException('[%s]: %s' % (status, message)) |
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, this is the id of your droplet that you want to snapshot image_id: Nume... |
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 scrub_data: Boolean, this will strictly write 0s to your prior partition to... |
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', []) regions = [Region.from_json(region) for region in regions_json] return regions e... |
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 filter: String, either "my_images" or "global" """... |
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_slug: msg = 'image_id_or_slug is required to destroy an image!' raise DOPException(msg... |
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 you would like to destroy """ if not image_id_or_slug: msg = ... |
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 Numeric, this is the id of the region to which you would like to transfer. """ if not ima... |
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': ssh_keys_json = json.get('ssh_keys', []) keys = [SSHKey.from_json(ssh_k... |
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. """ params = {'name': name, 'ssh_pub_key': ssh_pub_key} json = self.request('/ssh_ke... |
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 status == 'OK': ssh_key_json = json.get('ssh_key') ssh_key = SS... |
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 |
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 = [Size.from_json(s) for s in sizes_json] return sizes else: message = json.get('... |
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 domain in domains_json] return domains else: message = json.get('message... |
def create_domain(self, name, ip_address): """ This method creates a new domain name with an A record for the specified [ip_address]. Required parameters name: String, the name you want to give this SSH key. ip_address: String, ip address for the domain's initial a record. """ params = {'name': name, 'ip_address': ip_a... |
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_id, method='GET') status = json.get('status') if status == 'OK': domain_json = json.get... |
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' % domain_id, method='GET') status = json.get('status') return status |
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 = self.request('/domains/%s/records' % domain_id, method='GET') status = json.get('status... |
def create_domain_record(self, domain_id, record_type, data, name=None, priority=None, port=None, weight=None): """ This method creates a new domain name with an A record for the specified [ip_address]. Required parameters domain_id: Integer or Domain Name (e.g. domain.com), specifies the domain for which to create a r... |
method='GET', params=params) status = json.get('status') if status == 'OK': domain_record_json = json.get('domain_record') domain_record = Record.from_json(domain_record_json) return domain_record else: message = json.get('message') raise DOPException('[%s]: %s' % (status, message)) |
def show_domain_record(self, domain_id, record_id): """ This method returns the specified domain record. Required parameters domain_id: Integer or Domain Name (e.g. domain.com), specifies the domain for which to retrieve a record. record_id: Integer, specifies the record_id to retrieve. """ json = self.request('/domain... |
def destroy_domain_record(self, domain_id, record_id): """ This method deletes the specified domain record. Required parameters domain_id: Integer or Domain Name (e.g. domain.com), specifies the domain for which to destroy a record. record_id: Integer, specifies the record_id to destroy. """ json = self.request('/domai... |
def events(self, event_id): """ This method is primarily used to report on the progress of an event by providing the percentage of completion. Required parameters event_id: Numeric, this is the id of the event you would like more information about """ json = self.request('/events/%s' % event_id, method='GET') status = ... |
def get_ebuio_headers(request): """Return a dict with ebuio headers""" retour = {} for (key, value) in request.headers: if key.startswith('X-Plugit-'): key = key[9:] retour[key] = value return retour |
def getTerminalSize(): """ returns (lines:int, cols:int) """ def ioctl_GWINSZ(fd): # These two imports are only present on POSIX systems, so they must be # guarded by a try block. import fcntl import termios return struct.unpack("hh", fcntl.ioctl(fd, termios.TIOCGWINSZ, "1234")) # try stdin, stdout, stderr for fd in (0... |
def demo(): """Demonstrate progress bar.""" from time import sleep maxProgress = 1000 with ProgressBar(max=maxProgress) as progressbar: for i in range(-100, maxProgress): sleep(0.01) progressbar.update(i) progressbar2 = ProgressBar(max=maxProgress) for s in progressbar2.iterate(range(maxProgress)): sleep(0.01) for s in... |
def iterate(self, iterable, format="%s"): """Use as a target of a for-loop to issue a progress update for every iteration. For example: progress = ProgressBar() for text in progress.iterate(["foo", "bar", "bat"]): ... """ # If iterable has a definite length, then set the maximum value of the # progress bar. Else, set t... |
def show(self): """Redraw the text progress bar.""" if len(self.text) > self.textwidth: label = self.text[0:self.textwidth] else: label = self.text.rjust(self.textwidth) terminalSize = getTerminalSize() if terminalSize is None: terminalSize = 80 else: terminalSize = terminalSize[1] barWidth = terminalSize - self.textwi... |
\ ']' + progressFractionText, self.fid.flush() self.linefed = False |
def update(self, value=None, text=None): """Redraw the progress bar, optionally changing the value and text and return the (possibly new) value. For I/O performance, the progress bar might not be written to the terminal if the text does not change and the value changes by too little. Use .show() to force a redraw.""" r... |
def increment(self, delta=1, text=None): """Redraw the progress bar, incrementing the value by delta (default=1) and optionally changing the text. Returns the ProgressBar's new value. See also .update().""" return self.update(value=min(self.max, self.value + delta), text=text) |
def adjust_fit(dst_w, dst_h, img_w, img_h): """ given a x and y of dest, determine the ratio and return an (x,y,w,h) for a fitted image (note x or y could be neg). >>> adjust_fit(4,3,5,5) (0.5, 0, 3.0, 3.0) >>> adjust_fit(8,6,5,5) (1.0, 0, 6.0, 6.0) >>> adjust_fit(4,3,5,2) (0, 0.69999999999999996, 4.0, 1.60000000000000... |
/ 2 - h / 2 return x, y, w, h |
def adjust_size(self, dst_x, dst_y, mode=FIT): """ given a x and y of dest, determine the ratio and return an (x,y,w,h) for a output image. """ # get image size image = Image.open(self.path) width, height = image.size if mode == FIT: return adjust_crop(dst_x, dst_y, width, height) |
def fit(self, P): """Fit the diagonal matrices in Sinkhorn Knopp's algorithm Parameters ---------- P : 2d array-like Must be a square non-negative 2d array-like object, that is convertible to a numpy array. The matrix must not be equal to 0 and it must have total support for the algorithm to converge. Returns ------- A... |
not np.all(pdotr != 0): warnings.warn(total_support_warning_str, UserWarning) c = 1 / pdotr pdotc = P.dot(c) if not np.all(pdotc != 0): warnings.warn(total_support_warning_str, UserWarning) r = 1 / pdotc del pdotr, pdotc P_eps = np.copy(P) while np.any(np.sum(P_eps, axis=1) < min_thresh) \ or np.any(np.sum(P_eps, axis=... |
def request_ligodotorg(url, debug=False): """Request the given URL using LIGO.ORG SAML authentication. This requires an active Kerberos ticket for the user, to get one: $ kinit albert.einstein@LIGO.ORG Parameters ---------- url : `str` URL path for request debug : `bool`, optional Query in verbose debuggin mode, defaul... |
# set ignore_discard so that session cookies are preserved jar.load(COOKIE_JAR, ignore_discard = True) # create a cookie handler from the cookier jar cookie_handler = urllib2.HTTPCookieProcessor(jar) # need a redirect handler to follow redirects redirectHandler = urllib2.HTTPRedirectHandler() # need an auth handler tha... |
def publish_cat1(method, con, token, cat, kwargs): """ Constructs a "POST" and "DELETE" URL. The function is used by the publish and delete method First category of "POST" and "DELETE" url construction. Caling it first category because for publishing photos or more complex stuffs, newer fucntions might be added to deal... |
def get_object_cat1(con, token, cat, kwargs): """ Constructs the "GET" URL. The functions is used by the get_object method First Category of "GET" URL construction. Again calling it first category because more complex functions maybe added later. """ req_str = "/"+kwargs['id']+"?" #/id? req_str += "access_token="+token... |
def get_variables_substitution_dictionaries(self, lhs_graph, rhs_graph): """ Looks for sub-isomorphisms of rhs into lhs :param lhs_graph: The graph to look sub-isomorphisms into (the bigger graph) :param rhs_graph: The smaller graph :return: The list of matching names """ if not rhs_graph: return {}, {}, {} self.matchi... |
def run(self, src_folder, requirements="requirements.txt", local_package=None): """Builds the file bundle. :param str src: The path to your Lambda ready project (folder must contain a valid config.yaml and handler module (e.g.: service.py). :param str local_package: The path to a local package with should be included i... |
them together into a single file. # TODO: Delete temp directory created once the archive has been compiled. path_to_zip_file = self.create_artefact(path_to_temp, path_to_dist, output_filename) return path_to_zip_file |
def _install_packages(self, path, packages): """Install all packages listed to the target directory. Ignores any package that includes Python itself and python-lambda as well since its only needed for deploying and not running the code :param str path: Path to copy installed pip packages to. :param list packages: A lis... |
def pip_install_to_target(self, path, requirements="", local_package=None): """For a given active virtualenv, gather all installed pip packages then copy (re-install) them to the path provided. :param str path: Path to copy installed pip packages to. :param str requirements: If set, only the packages in the requirement... |
= self.read(requirements_path) packages.extend(data.splitlines()) else: logger.debug('No requirements file in {}'.format(requirements_path)) if local_package is not None: if not isinstance(local_package, (list, tuple)): local_package = [local_package] for l_package in local_package: packages.append(l_package) self._ins... |
def readTableFromDelimited(f, separator="\t"): """ Reads a table object from given plain delimited file. """ rowNames = [] columnNames = [] matrix = [] first = True for line in f.readlines(): line = line.rstrip() if len(line) == 0: continue row = line.split(separator) if first: columnNames = row[1:] first = False else:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.