code stringlengths 1 18.2k |
|---|
def cache(time=0, byUser=None): """Decorator to specify the number of seconds the result should be cached, and if cache can be shared between users :param time: Cache timeout in seconds :param byUser: False by default, if true, cache is shared among users """ def real_decorator(function): function.pi_api_cache_time = t... |
def add_unique_postfix(fn): """__source__ = 'http://code.activestate.com/recipes/577200-make-unique-file-name/'""" if not os.path.exists(fn): return fn path, name = os.path.split(fn) name, ext = os.path.splitext(name) make_fn = lambda i: os.path.join(path, '%s(%d)%s' % (name, i, ext)) for i in xrange(2, sys.maxint): un... |
def handle(self, *args, **options): """ Handle liquibase command parameters """ database = getattr( settings, 'LIQUIMIGRATE_DATABASE', options['database']) try: dbsettings = databases[database] except KeyError: raise CommandError("don't know such a connection: %s" % database) verbosity = int(options.get('verbosity')) #... |
'.join(args), } cmdline = "java -jar %(jar)s --changeLogFile %(changelog_file)s \ --username=%(username)s --password=%(password)s \ --driver=%(driver)s --classpath=%(classpath)s --url=%(url)s \ %(command)s %(args)s" % (cmdargs) if verbosity > 0: print("changelog file: %s" % (changelog_file,)) print("executing: %s" % (c... |
def messages(fp, key='@message'): """ Read lines of UTF-8 from the file-like object given in ``fp``, with the same fault-tolerance as :function:`tagalog.io.lines`, but instead yield dicts with the line data stored in the key given by ``key`` (default: "@message"). """ for line in lines(fp): txt = line.rstrip('\n') yiel... |
def lines(fp): """ Read lines of UTF-8 from the file-like object given in ``fp``, making sure that when reading from STDIN, reads are at most line-buffered. UTF-8 decoding errors are handled silently. Invalid characters are replaced by U+FFFD REPLACEMENT CHARACTER. Line endings are normalised to newlines by Python's un... |
l: if decode: l = l.decode(UTF8, 'replace') yield l else: break finally: if close: fp.close() |
def publish(self, cat, **kwargs): """ This method is used for creating objects in the facebook graph. The first paramter is "cat", the category of publish. In addition to "cat" "id" must also be passed and is catched by "kwargs" """ res=request.publish_cat1("POST", self.con, self.token, cat, kwargs) return res |
def get_object(self, cat, **kwargs): """ This method is used for retrieving objects from facebook. "cat", the category, must be passed. When cat is "single", pass the "id "and desired "fields" of the single object. If the cat is "multiple", only pass the "ids" of the objects to be fetched. """ if 'id' not in kwargs.key... |
def delete(self, **kwargs): """ Used for deleting objects from the facebook graph. Just pass the id of the object to be deleted. But in case of like, have to pass the cat ("likes") and object id as a like has no id itself in the facebook graph """ if 'cat' not in kwargs.keys(): kwargs['cat']='' cat=kwargs['cat'] del kw... |
def getColumnsByName(elem, name): """ Return a list of Column elements named name under elem. The name comparison is done with CompareColumnNames(). """ name = StripColumnName(name) return elem.getElements(lambda e: (e.tagName == ligolw.Column.tagName) and (e.Name == name)) |
def StripTableName(name): """ Return the significant portion of a table name according to LIGO LW naming conventions. Example: >>> StripTableName("sngl_burst_group:sngl_burst:table") 'sngl_burst' >>> StripTableName("sngl_burst:table") 'sngl_burst' >>> StripTableName("sngl_burst") 'sngl_burst' """ if name.lower() != nam... |
def getTablesByName(elem, name): """ Return a list of Table elements named name under elem. The name comparison is done using CompareTableNames(). """ name = StripTableName(name) return elem.getElements(lambda e: (e.tagName == ligolw.Table.tagName) and (e.Name == name)) |
def get_table(xmldoc, name): """ Scan xmldoc for a Table element named name. The comparison is done using CompareTableNames(). Raises ValueError if not exactly 1 such table is found. NOTE: if a Table sub-class has its .tableName attribute set, then its .get_table() class method can be used instead. This is true for all... |
>>> sngl_inspiral_table = lsctables.SnglInspiralTable.get_table(xmldoc) See also the .get_table() class method of the Table class. """ tables = getTablesByName(xmldoc, name) if len(tables) != 1: raise ValueError("document must contain exactly one %s table" % StripTableName(name)) return tables[0] |
def reassign_ids(elem): """ Recurses over all Table elements below elem whose next_id attributes are not None, and uses the .get_next_id() method of each of those Tables to generate and assign new IDs to their rows. The modifications are recorded, and finally all ID attributes in all rows of all tables are updated to f... |
not occur. Example: >>> import ligolw >>> import lsctables >>> xmldoc = ligolw.Document() >>> xmldoc.appendChild(ligolw.LIGO_LW()).appendChild(lsctables.New(lsctables.SnglInspiralTable)) [] >>> reassign_ids(xmldoc) """ mapping = {} for tbl in elem.getElementsByTagName(ligolw.Table.tagName): if tbl.next_id is not None: ... |
def reset_next_ids(classes): """ For each class in the list, if the .next_id attribute is not None (meaning the table has an ID generator associated with it), set .next_id to 0. This has the effect of reseting the ID generators, and is useful in applications that process multiple documents and add new rows to tables in... |
cls.set_next_id(type(cls.next_id)(0)) |
def use_in(ContentHandler): """ Modify ContentHandler, a sub-class of pycbc_glue.ligolw.LIGOLWContentHandler, to cause it to use the Table, Column, and Stream classes defined in this module when parsing XML documents. Example: >>> from pycbc_glue.ligolw import ligolw >>> class LIGOLWContentHandler(ligolw.LIGOLWContentH... |
def count(self, value): """ Return the number of rows with this column equal to value. """ return sum(getattr(row, self.Name) == value for row in self.parentNode) |
def index(self, value): """ Return the smallest index of the row(s) with this column equal to value. """ for i in xrange(len(self.parentNode)): if getattr(self.parentNode[i], self.Name) == value: return i raise ValueError(value) |
def asarray(self): """ Construct a numpy array from this column. Note that this creates a copy of the data, so modifications made to the array will *not* be recorded in the original document. """ # most codes don't use this feature, this is the only place # numpy is used here, and importing numpy can be # time-consumin... |
def unlink(self): """ Break internal references within the document tree rooted on this element to promote garbage collection. """ self._tokenizer = None self._rowbuilder = None super(TableStream, self).unlink() |
def copy(self): """ Construct and return a new Table document subtree whose structure is the same as this table, that is it has the same columns etc.. The rows are not copied. Note that a fair amount of metadata is shared between the original and new tables. In particular, a copy of the Table object itself is created (... |
def CheckProperties(cls, tagname, attrs): """ Return True if tagname and attrs are the XML tag name and element attributes, respectively, of a Table element whose Name attribute matches the .tableName attribute of this class according to CompareTableNames(); return False otherwise. The Table parent class does not provi... |
def getColumnByName(self, name): """ Retrieve and return the Column child element named name. The comparison is done using CompareColumnNames(). Raises KeyError if this table has no column by that name. Example: >>> import lsctables >>> tbl = lsctables.New(lsctables.SnglInspiralTable) >>> col = tbl.getColumnByName("mas... |
def appendColumn(self, name): """ Append a Column element named "name" to the table. Returns the new child. Raises ValueError if the table already has a column by that name, and KeyError if the validcolumns attribute of this table does not contain an entry for a column by that name. Note that the name string is assumed... |
except KeyError: pass column = Column(AttributesImpl({u"Name": "%s:%s" % (StripTableName(self.tableName), name), u"Type": self.validcolumns[name]})) streams = self.getElementsByTagName(ligolw.Stream.tagName) if streams: self.insertBefore(column, streams[0]) else: self.appendChild(column) return column |
def appendRow(self, *args, **kwargs): """ Create and append a new row to this table, then return it All positional and keyword arguments are passed to the RowType constructor for this table. """ row = self.RowType(*args, **kwargs) self.append(row) return row |
def _update_column_info(self): """ Used for validation during parsing, and additional book-keeping. For internal use only. """ del self.columnnames[:] del self.columntypes[:] del self.columnpytypes[:] for child in self.getElementsByTagName(ligolw.Column.tagName): if self.validcolumns is not None: try: if self.validcolu... |
def _verifyChildren(self, i): """ Used for validation during parsing, and additional book-keeping. For internal use only. """ super(Table, self)._verifyChildren(i) child = self.childNodes[i] if child.tagName == ligolw.Column.tagName: self._update_column_info() elif child.tagName == ligolw.Stream.tagName: # require agre... |
def removeChild(self, child): """ Remove a child from this element. The child element is returned, and it's parentNode element is reset. """ super(Table, self).removeChild(child) if child.tagName == ligolw.Column.tagName: self._update_column_info() return child |
def sync_next_id(self): """ Determines the highest-numbered ID in this table, and sets the table's .next_id attribute to the next highest ID in sequence. If the .next_id attribute is already set to a value greater than the highest value found, then it is left unmodified. The return value is the ID identified by this me... |
ID to the next ID higher than any ID in any of those tables. Example: >>> import lsctables >>> tbl = lsctables.New(lsctables.ProcessTable) >>> print tbl.sync_next_id() process:process_id:0 """ if self.next_id is not None: if len(self): n = max(self.getColumnByName(self.next_id.column_name)) + 1 else: n = type(self.next... |
def updateKeyMapping(self, mapping): """ Used as the first half of the row key reassignment algorithm. Accepts a dictionary mapping old key --> new key. Iterates over the rows in this table, using the table's next_id attribute to assign a new ID to each row, recording the changes in the mapping. Returns the mapping. Ra... |
def applyKeyMapping(self, mapping): """ Used as the second half of the key reassignment algorithm. Loops over each row in the table, replacing references to old row keys with the new values from the mapping. """ for coltype, colname in zip(self.columntypes, self.columnnames): if coltype in ligolwtypes.IDTypes and (self... |
def _part(self, name, func, args, help, **kwargs): """Parses arguments of a single command (e.g. 'v'). If :args: is empty, it assumes that command takes no further arguments. :name: Name of the command. :func: Arg method to execute. :args: Dictionary of CLI arguments pointed at Arg method arguments. :help: Commands' he... |
def rock(self): """Starts and does the parsing.""" if not self.argv: self.arg.view() while(self.argv): arg = self.argv.popleft() if arg == "-h" or arg == "--help": print( """Usage: td [-h (--help)] [-v (--version)] [command]""" """, where [command] is one of:\n\n""" """v (view)\tChanges the way next output""" """ will ... |
""" -v (--version)Shows version number.""" ) elif arg == "-v" or arg == "--version": print("td :: {}".format(__version__)) elif arg == "v" or arg == "view": self._part("view", self.arg.view, { "--no-color": ("nocolor", False), "-s": ("sort", True), "--sort": ("sort", True), "-p": ("purge", False), "--purge": ("purge", ... |
"-s": ("sort", True), "--sort": ("sort", True), "-p": ("purge", False), "--purge": ("purge", False), "-d": ("done", True), "--done": ("done", True), "-D": ("undone", True), "--undone": ("undone", True) }, """Usage: td m [-h (--help)] [command(s)]""" """, where [command(s)] are any of:\n\n""" """-s (--sort) <pattern>\tS... |
any of:\n\n""" """-n (--name) <text>\t\tSets item's name.\n""" """-p (--priority) <no|name>\tSets item's priority.\n""" """-c (--comment) <text>\t\tSets item's comment.\n""" """\nIf [parent] index is specified, new item will""" """ become it's child.\n""" """If any of the arguments is omitted,""" """ this command will ... |
parent.\n""" """-n (--name) <text>\t\tChanges item's name.\n""" """-p (--priority) <no|name>\tChanges item's priority.\n""" """-c (--comment) <text>\t\tChanges item's comment.\n""" """\nIndex argument is required and has to point at""" """ an existing item.\n""" """If any of the arguments is omitted, it will launch""" ... |
dict() if not self.argv: raise NotEnoughArgumentsError("done") elif self.argv[0] not in ["-h", "--help"]: args["index"] = self.argv.popleft() self._part("done", self.arg.done, { }, """Usage: td d [-h (--help)] <index>\n\n""" """Index argument is required and has to point at""" """ an existing item.\n""" """\nAdditional... |
("purge", False), "--purge": ("purge", False), "-d": ("done", True), "--done": ("done", True), "-D": ("undone", True), "--undone": ("undone", True) }, """Usage: td o [-h (--help)] [command(s)]""" """, where [command(s)] are any of:\n\n""" """-g (--global)\t\tApply specified options to all""" """ ToDo lists (store in ~/... |
def input(self, field): """Gets user input for given field. Can be interrupted with ^C. :field: Field name. :returns: User input. """ try: desc = Get.TYPES[field] return input("{}|{}[{}]> ".format( field, "-" * (Get._LEN - len(field) - len(desc)), desc )) except KeyboardInterrupt: print() exit(0) |
def get(self, field, value=None): """Gets user input for given field and checks if it is valid. If input is invalid, it will ask the user to enter it again. Defaults values to empty or :value:. It does not check validity of parent index. It can only be tested further down the road, so for now accept anything. :field: F... |
name [{}].".format(c)) val = self.input(field) val = int(val) return val |
def _getPattern(self, ipattern, done=None): """Parses sort pattern. :ipattern: A pattern to parse. :done: If :ipattern: refers to done|undone, use this to indicate proper state. :returns: A pattern suitable for Model.modify. """ if ipattern is None: return None if ipattern is True: if done is not None: return ([(None, ... |
k = s.split(':') if len(k) == 1: if done is not None: ipattern1.append(_getDone(k[0])) continue ko = k[0][:-1] try: if len(k[0]) == 1: k = 0 else: k = Model.indexes[ko] except KeyError: k = _getIndex(k[0][:-1]) else: ipattern1.append((k, v)) continue v = (0, v) elif len(k) == 2: try: if done is not None: v = _getDone(k... |
def _getDone(self, done, undone): """Parses the done|undone state. :done: Done marking pattern. :undone: Not done marking pattern. :returns: Pattern for done|undone or None if neither were specified. """ if done: return self._getPattern(done, True) if undone: return self._getPattern(undone, False) |
def view(self, sort=None, purge=False, done=None, undone=None, **kwargs): """Handles the 'v' command. :sort: Sort pattern. :purge: Whether to purge items marked as 'done'. :done: Done pattern. :undone: Not done pattern. :kwargs: Additional arguments to pass to the View object. """ View(self.model.modify( sort=self._get... |
def modify(self, sort=None, purge=False, done=None, undone=None): """Handles the 'm' command. :sort: Sort pattern. :purge: Whether to purge items marked as 'done'. :done: Done pattern. :undone: Not done pattern. """ self.model.modifyInPlace( sort=self._getPattern(sort), purge=purge, done=self._getDone(done, undone) ) |
def add(self, **args): """Handles the 'a' command. :args: Arguments supplied to the 'a' command. """ kwargs = self.getKwargs(args) if kwargs: self.model.add(**kwargs) |
def edit(self, **args): """Handles the 'e' command. :args: Arguments supplied to the 'e' command. """ if self.model.exists(args["index"]): values = dict(zip( ['parent', 'name', 'priority', 'comment', 'done'], self.model.get(args["index"]) )) kwargs = self.getKwargs(args, values) if kwargs: self.model.edit(args["index"]... |
def rm(self, index): """Handles the 'r' command. :index: Index of the item to remove. """ if self.model.exists(index): self.model.remove(index) |
def done(self, index): """Handles the 'd' command. :index: Index of the item to mark as done. """ if self.model.exists(index): self.model.edit(index, done=True) |
def undone(self, index): """Handles the 'D' command. :index: Index of the item to mark as not done. """ if self.model.exists(index): self.model.edit(index, done=False) |
def options(self, glob=False, **args): """Handles the 'o' command. :glob: Whether to store specified options globally. :args: Arguments supplied to the 'o' command (excluding '-g'). """ kwargs = {} for argname, argarg in args.items(): if argname == "sort": argarg = self._getPattern(argarg) if argname not in ["done", "u... |
def getKwargs(self, args, values={}, get=Get()): """Gets necessary data from user input. :args: Dictionary of arguments supplied in command line. :values: Default values dictionary, supplied for editing. :get: Object used to get values from user input. :returns: A dictionary containing data gathered from user input. ""... |
def url(self): """ The cache entry's URL. The URL is constructed from the values of the scheme, host, and path attributes. Assigning a value to the URL attribute causes the value to be parsed and the scheme, host and path attributes updated. """ return urlparse.urlunparse((self.scheme, self.host, self.path, None, None,... |
def segmentlistdict(self): """ A segmentlistdict object describing the instruments and time spanned by this CacheEntry. A new object is constructed each time this attribute is accessed (segments are immutable so there is no reason to try to share a reference to the CacheEntry's internal segment; modifications of one wo... |
break the cyclic # dependancy from pycbc_glue.ligolw.lsctables import instrument_set_from_ifos instruments = instrument_set_from_ifos(self.observatory) or (None,) return segments.segmentlistdict((instrument, segments.segmentlist(self.segment is not None and [self.segment] or [])) for instrument in instruments) |
def from_T050017(cls, url, coltype = LIGOTimeGPS): """ Parse a URL in the style of T050017-00 into a CacheEntry. The T050017-00 file name format is, essentially, observatory-description-start-duration.extension Example: >>> c = CacheEntry.from_T050017("file://localhost/data/node144/frames/S5/strain-L2/LLO/L-L1_RDS_C03_... |
def fromfile(cls, fileobj, coltype=LIGOTimeGPS): """ Return a Cache object whose entries are read from an open file. """ c = [cls.entry_class(line, coltype=coltype) for line in fileobj] return cls(c) |
def fromfilenames(cls, filenames, coltype=LIGOTimeGPS): """ Read Cache objects from the files named and concatenate the results into a single Cache. """ cache = cls() for filename in filenames: cache.extend(cls.fromfile(open(filename), coltype=coltype)) return cache |
def from_urls(cls, urllist, coltype=LIGOTimeGPS): """ Return a Cache whose entries are inferred from the URLs in urllist, if possible. PFN lists will also work; for PFNs, the path will be absolutized and "file://" and "localhost" will be assumed for the schemes and hosts. The filenames must be in the format set forth b... |
def unique(self): """ Return a Cache which has every element of self, but without duplication. Preserve order. Does not hash, so a bit slow. """ new = self.__class__([]) for elem in self: if elem not in new: new.append(elem) return new |
def tofile(self, fileobj): """ write a cache object to the fileobj as a lal cache file """ for entry in self: print >>fileobj, str(entry) fileobj.close() |
def topfnfile(self, fileobj): """ write a cache object to filename as a plain text pfn file """ for entry in self: print >>fileobj, entry.path fileobj.close() |
def to_segmentlistdict(self): """ Return a segmentlistdict object describing the instruments and times spanned by the entries in this Cache. The return value is coalesced. """ d = segments.segmentlistdict() for entry in self: d |= entry.segmentlistdict return d |
def sieve(self, ifos=None, description=None, segment=None, segmentlist=None, exact_match=False): """ Return a Cache object with those CacheEntries that contain the given patterns (or overlap, in the case of segment or segmentlist). If exact_match is True, then non-None ifos, description, and segment patterns must match... |
lambda e: segmentlist.intersects_segment(e.segment) c = self if ifos is not None: ifos_regexp = re.compile(fnmatch.translate(ifos)) c = [entry for entry in c if ifos_regexp.match(entry.observatory) is not None] if description is not None: descr_regexp = re.compile(fnmatch.translate(description)) c = [entry for entry in... |
def checkfilesexist(self, on_missing="warn"): ''' Runs through the entries of the Cache() object and checks each entry if the file which it points to exists or not. If the file does exist then it adds the entry to the Cache() object containing found files, otherwise it adds the entry to the Cache() object containing al... |
self: if os.path.isfile(entry.path): c_found.append(entry) else: c_missed.append(entry) if len(c_missed) > 0: msg = "%d of %d files in the cache were not found "\ "on disk" % (len(c_missed), len(self)) if on_missing == "warn": print >>sys.stderr, "warning: " + msg elif on_missing == "error": raise ValueError(msg) elif ... |
def get_ilwdchar_class(tbl_name, col_name, namespace = globals()): """ Searches this module's namespace for a subclass of _ilwd.ilwdchar whose table_name and column_name attributes match those provided. If a matching subclass is found it is returned; otherwise a new class is defined, added to this module's namespace, a... |
KeyError: pass # # otherwise define a new class, and add it to the cache # class new_class(_ilwd.ilwdchar): __slots__ = () table_name, column_name = key index_offset = len("%s:%s:" % key) new_class.__name__ = cls_name namespace[cls_name] = new_class # # pickle support # copy_reg.pickle(new_class, lambda x: (ilwdchar, (... |
def get_username(): """ Try to retrieve the username from a variety of sources. First the environment variable LOGNAME is tried, if that is not set the environment variable USERNAME is tried, if that is not set the password database is consulted (only on Unix systems, if the import of the pwd module succeeds), finally ... |
def append_process(xmldoc, program = None, version = None, cvs_repository = None, cvs_entry_time = None, comment = None, is_online = False, jobid = 0, domain = None, ifos = None): """ Add an entry to the process table in xmldoc. program, version, cvs_repository, comment, and domain should all be strings or unicodes. cv... |
None and cvs_entry_time != "": try: # try the git_version format first process.cvs_entry_time = _UTCToGPS(time.strptime(cvs_entry_time, "%Y-%m-%d %H:%M:%S +0000")) except ValueError: # fall back to the old cvs format process.cvs_entry_time = _UTCToGPS(time.strptime(cvs_entry_time, "%Y/%m/%d %H:%M:%S")) else: process.cv... |
def append_process_params(xmldoc, process, params): """ xmldoc is an XML document tree, process is the row in the process table for which these are the parameters, and params is a list of (name, type, value) tuples one for each parameter. See also process_params_from_dict(), register_to_xmldoc(). """ try: paramtable = ... |
def get_process_params(xmldoc, program, param, require_unique_program = True): """ Return a list of the values stored in the process_params table for params named param for the program(s) named program. The values are returned as Python native types, not as the strings appearing in the XML document. If require_unique_p... |
for row in lsctables.ProcessParamsTable.get_table(xmldoc) if (row.process_id in process_ids) and (row.param == param)] |
def doc_includes_process(xmldoc, program): """ Return True if the process table in xmldoc includes entries for a program named program. """ return program in lsctables.ProcessTable.get_table(xmldoc).getColumnByName(u"program") |
def process_params_from_dict(paramdict): """ Generator function yields (name, type, value) tuples constructed from a dictionary of name/value pairs. The tuples are suitable for input to append_process_params(). This is intended as a convenience for converting command-line options into process_params rows. The name valu... |
form it had on the command line name = u"--%s" % name.replace("_", "-") if values is True or values is False: yield (name, None, None) elif values is not None: if not isinstance(values, list): values = [values] for value in values: yield (name, ligolwtypes.FromPyType[type(value)], value) |
def register_to_xmldoc(xmldoc, program, paramdict, **kwargs): """ Register the current process and params to an XML document. program is the name of the program. paramdict is a dictionary of name/value pairs that will be used to populate the process_params table; see process_params_from_dict() for information on how th... |
def register_to_ldbd(client, program, paramdict, version = u'0', cvs_repository = u'-', cvs_entry_time = 0, comment = u'-', is_online = False, jobid = 0, domain = None, ifos = u'-'): """ Register the current process and params to a database via a LDBDClient. The program and paramdict arguments and any additional keywor... |
def plugitInclude(parser, token): """ Load and render a template, using the same context of a specific action. Example: {% plugitInclude "/menuBar" %} """ bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError("'plugitInclude' tag takes one argument: the tempalte's action to use") action = parser.co... |
def install_signal_trap(signums = (signal.SIGTERM, signal.SIGTSTP), retval = 1): """ Installs a signal handler to erase temporary scratch files when a signal is received. This can be used to help ensure scratch files are erased when jobs are evicted by Condor. signums is a squence of the signals to trap, the default va... |
after the scratch files are erased the original signal handler will be invoked. If program control returns from that handler, i.e. that handler does not cause the interpreter to exit, then sys.exit() is invoked and retval is returned to the shell as the exit code. Note: by invoking sys.exit(), the signal handler causes... |
remove the handler from that signal. Note: this function is called by get_connection_filename() whenever it creates a scratch file. """ # NOTE: this must be called with the temporary_files_lock held. # ignore signums we've already replaced signums = set(signums) - set(origactions) def temporary_file_cleanup_on_signal(s... |
def uninstall_signal_trap(signums = None): """ Undo the effects of install_signal_trap(). Restores the original signal handlers. If signums is a sequence of signal numbers only the signal handlers for those signals will be restored (KeyError will be raised if one of them is not one that install_signal_trap() installed ... |
signums: signal.signal(signum, origactions.pop(signum)) |
def get_connection_filename(filename, tmp_path = None, replace_file = False, verbose = False): """ Utility code for moving database files to a (presumably local) working location for improved performance and reduced fileserver load. """ def mktmp(path, suffix = ".sqlite", verbose = False): with temporary_files_lock: # ... |
umask, creates all files accessible # only by owner; we should respect umask. note that # os.umask() sets it, too, so we have to set it back after # we know what it is umsk = os.umask(0777) os.umask(umsk) os.chmod(filename, 0666 & ~umsk) return filename def truncate(filename, verbose = False): if verbose: print >>sys.s... |
are # supposed preserve them but don't. maybe they # don't preserve them if the destination file # already exists? shutil.copystat(srcname, dstname) except Exception as e: if verbose: print >>sys.stderr, "warning: ignoring failure to copy permission bits from '%s' to '%s': %s" % (filename, target, str(e)) database_exis... |
1 while True: try: cpy(filename, target, verbose = verbose) except IOError as e: import errno import time if e.errno not in (errno.EPERM, errno.ENOSPC): # anything other # than out-of-space # is a real error raise if i < 5: if verbose: print >>sys.stderr, "warning: attempt %d: %s, sleeping and trying again ..." % (i, e... |
del cpy return target |
def set_temp_store_directory(connection, temp_store_directory, verbose = False): """ Sets the temp_store_directory parameter in sqlite. """ if temp_store_directory == "_CONDOR_SCRATCH_DIR": temp_store_directory = os.getenv("_CONDOR_SCRATCH_DIR") if verbose: print >>sys.stderr, "setting the temp_store_directory to %s ..... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.