code stringlengths 1 18.2k |
|---|
def close(self): """ Closes connection to database. """ if getattr(self, '_connection', None): logger.debug('Closing postgresql connection.') self._connection.close() self._connection = None if getattr(self, '_engine', None): self._engine.dispose() |
def _get_mpr_table(self, connection, partition): """ Returns name of the postgres table who stores mpr data. Args: connection: connection to postgres db who stores mpr data. partition (orm.Partition): Returns: str: Raises: MissingTableError: if partition table not found in the db. """ # TODO: This is the first candidat... |
table logger.debug( 'Looking for foreign table of the partition.\n partition: {}'.format(partition.name)) foreign_exists = self._relation_exists(connection, foreign_table) if foreign_exists: logger.debug( 'Foreign table of the partition found.\n partition: {}, foreign table: {}' .format(partition.name, foreign_table)) ... |
def _add_partition(self, connection, partition): """ Creates FDW for the partition. Args: connection: partition (orm.Partition): """ logger.debug('Creating foreign table for partition.\n partition: {}'.format(partition.name)) with connection.cursor() as cursor: postgres_med.add_partition(cursor, partition.datafile, par... |
def _get_connection(self): """ Returns connection to the postgres database. Returns: connection to postgres database who stores mpr data. """ if not getattr(self, '_connection', None): logger.debug( 'Creating new connection.\n dsn: {}' .format(self._dsn)) d = parse_url_to_dict(self._dsn) self._connection = psycopg2.con... |
def _execute(self, connection, query, fetch=True): """ Executes given query and returns result. Args: connection: connection to postgres database who stores mpr data. query (str): sql query fetch (boolean, optional): if True, fetch query result and return it. If False, do not fetch. Returns: iterable with query result ... |
def _relation_exists(cls, connection, relation): """ Returns True if relation exists in the postgres db. Otherwise returns False. Args: connection: connection to postgres database who stores mpr data. relation (str): name of the table, view or materialized view. Note: relation means table, view or materialized view her... |
def load(self, country="all"): """ Load data """ u = ("https://api.worldbank.org/v2/countries/{}/indicators/CPTOTSAXN" "?format=json&per_page=10000").format(country) r = requests.get(u) j = r.json() cpi_data = j[1] # Loop through the rows of the datapackage with the help of data for row in cpi_data: # Get the code and ... |
def get(self, date=datetime.date.today(), country=None): """ Get the CPI value for a specific time. Defaults to today. This uses the closest method internally but sets limit to one day. """ if not country: country = self.country if country == "all": raise ValueError("You need to specify a country") if not isinstance(da... |
def build_subreverse(self, _name, **kwargs): ''' String-based reverse API. Returns subreverse object:: env.root.build_subreverse('user', user_id=1).profile ''' _, subreverse = self._build_url_silent(_name, **kwargs) return subreverse |
def build_url(self, _name, **kwargs): ''' String-based reverse API. Returns URL object:: env.root.build_url('user.profile', user_id=1) Checks that all necessary arguments are provided and all provided arguments are used. ''' used_args, subreverse = self._build_url_silent(_name, **kwargs) if set(kwargs).difference(used_... |
def as_url(self): ''' Reverse object converted to `web.URL`. If Reverse is bound to env: * try to build relative URL, * use current domain name, port and scheme as default ''' if '' in self._scope: return self._finalize().as_url if not self._is_endpoint: raise UrlBuildingError('Not an endpoint {}'.format(repr(self))) i... |
domain values with aliased replaced by their # primary value primary_domain = self._bound_env._route_state.primary_domain host_split = request.host.split(':') request_domain = host_split[0] request_port = host_split[1] if len(host_split) > 1 else scheme_port port = port or request_port return URL(path, host=domain or r... |
def bind_to_env(self, bound_env): ''' Get a copy of the reverse, bound to `env` object. Can be found in env.root attribute:: # done in iktomi.web.app.Application env.root = Reverse.from_handler(app).bind_to_env(env) ''' return self.__class__(self._scope, self._location, path=self._path, host=self._host, fragment=self._... |
def from_url(cls, url, show_host=True): '''Parse string and get URL instance''' # url must be idna-encoded and url-quotted if six.PY2: if isinstance(url, six.text_type): url = url.encode('utf-8') parsed = urlparse(url) netloc = parsed.netloc.decode('utf-8') # XXX HACK else:# pragma: no cover if isinstance(url, six.bina... |
def qs_set(self, *args, **kwargs): '''Set values in QuerySet MultiDict''' if args and kwargs: raise TypeError('Use positional args or keyword args not both') query = self.query.copy() if args: mdict = MultiDict(args[0]) for k in mdict.keys(): if k in query: del query[k] for k, v in mdict.items(): query.add(k, v) else: ... |
def qs_add(self, *args, **kwargs): '''Add value to QuerySet MultiDict''' query = self.query.copy() if args: mdict = MultiDict(args[0]) for k, v in mdict.items(): query.add(k, v) for k, v in kwargs.items(): query.add(k, v) return self._copy(query=query) |
def qs_delete(self, *keys): '''Delete value from QuerySet MultiDict''' query = self.query.copy() for key in set(keys): try: del query[key] except KeyError: pass return self._copy(query=query) |
def qs_get(self, key, default=None): '''Get a value from QuerySet MultiDict''' return self.query.get(key, default=default) |
def get_readable(self): ''' Gets human-readable representation of the url (as unicode string, IRI according RFC3987) ''' query = (u'?' + u'&'.join(u'{}={}'.format(urlquote(k), urlquote(v)) for k, v in six.iteritems(self.query)) if self.query else '') hash_part = (u'#' + self.fragment) if self.fragment is not None else ... |
def cancel(self, id, **kwargs): """ Cancel running build. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >>> >>> thread = api.cancel(id... |
def get_ssh_credentials(self, id, **kwargs): """ Gets ssh credentials for a build This GET request is for authenticated users only. The path for the endpoint is not restful to be able to authenticate this GET request only. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, pl... |
def get_all_builds_in_distributed_recordset_of_product_release(self, id, **kwargs): """ Gets all BuildRecords distributed for Product Version This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> ... |
def get_all_by_product_version_id(self, version_id, **kwargs): """ Gets all Product Releases of the Specified Product Version This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_fun... |
def get_all_support_level(self, **kwargs): """ Gets all Product Releases Support Level This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >... |
def TableArgsMeta(table_args): '''Declarative metaclass automatically adding (merging) __table_args__ to mapped classes. Example: Meta = TableArgsMeta({ 'mysql_engine': 'InnoDB', 'mysql_default charset': 'utf8', } Base = declarative_base(name='Base', metaclass=Meta) class MyClass(Base): … is equivalent to Base = declar... |
assert isinstance(ta, tuple) if ta and isinstance(ta[-1], dict): tad = dict(table_args, **ta[-1]) ta = ta[:-1] else: tad = dict(table_args) cls.__table_args__ = ta + (tad,) super(_TableArgsMeta, cls).__init__(name, bases, dict_) return _TableArgsMeta |
def warehouse_query(line, cell): "my cell magic" from IPython import get_ipython parts = line.split() w_var_name = parts.pop(0) w = get_ipython().ev(w_var_name) w.query(cell).close() |
def list_product_releases(page_size=200, page_index=0, sort="", q=""): """ List all ProductReleases """ data = list_product_releases_raw(page_size, page_index, sort, q) if data: return utils.format_json_list(data) |
def update_release(id, **kwargs): """ Update an existing ProductRelease with new information """ data = update_release_raw(id, **kwargs) if data: return utils.format_json(data) |
def get(self, identifier): """get provider by id""" for provider in self._providers: if provider.identifier == identifier: return provider return None |
def search(self, keyword, source_in=None, **kwargs): """search song/artist/album by keyword TODO: search album or artist """ for provider in self._providers: if source_in is not None: if provider.identifier not in source_in: continue try: result = provider.search(keyword=keyword) except Exception as e: logger.exception... |
def list_song_standby(self, song, onlyone=True): """try to list all valid standby Search a song in all providers. The typical usage scenario is when a song is not available in one provider, we can try to acquire it from other providers. Standby choosing strategy: search from all providers, select two song from each pro... |
> album if song.artists_name != standby.artists_name: score -= 0.4 if song.title != standby.title: score -= 0.3 if song.album_name != standby.album_name: score -= 0.2 return score valid_sources = [p.identifier for p in self.list() if p.identifier != song.source] q = '{} {}'.format(song.title, song.artists_name) standby... |
def import_class_by_string(name): """Return a class by importing its module from a fully qualified string.""" components = name.split('.') clazz = components.pop() mod = __import__('.'.join(components)) components += [clazz] for comp in components[1:]: mod = getattr(mod, comp) return mod |
def get_all_for_build_configuration(self, configuration_id, **kwargs): """ Gets the Build Records linked to a specific Build Configuration This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def... |
def get_all_for_project(self, name, **kwargs): """ Gets the Build Records produced from the BuildConfiguration by name. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(... |
def get_all_for_project_0(self, project_id, **kwargs): """ Gets the Build Records linked to a specific Project This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response)... |
def get_attributes(self, id, **kwargs): """ Get Build Record attributes. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >>> >>> thread ... |
def get_build_configuration_audited(self, id, **kwargs): """ Gets the audited build configuration for specific build record This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_funct... |
def get_built_artifacts(self, id, **kwargs): """ Gets artifacts built for specific Build Record This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(re... |
def get_completed_or_runnning(self, id, **kwargs): """ Deprecated, use /builds/{id} This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >>> ... |
def get_dependency_artifacts(self, id, **kwargs): """ Gets dependency artifacts for specific Build Record This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>>... |
def get_dependency_graph(self, id, **kwargs): """ Gets dependency graph for a Build Record (running or completed). This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(respo... |
def get_logs(self, id, **kwargs): """ Gets logs for specific Build Record This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >>> >>> thread... |
def get_repour_logs(self, id, **kwargs): """ Gets repour logs for specific Build Record This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) ... |
def put_attribute(self, id, key, value, **kwargs): """ Add attribute to the BuildRecord. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response)... |
def query_by_attribute(self, key, value, **kwargs): """ Get Build Records by attribute. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) ... |
def remove_attribute(self, id, key, **kwargs): """ Remove attribute from BuildRecord. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >>... |
def get_unconstrained_bytes(self, name, bits, source=None, key=None, inspect=True, events=True, **kwargs): """ Get some consecutive unconstrained bytes. :param name: Name of the unconstrained variable :param bits: Size of the unconstrained variable :param source: Where those bytes are read from. Currently it is only us... |
key=key, inspect=inspect, events=events, **kwargs) return r |
def build_type(self, build_type): """ Sets the build_type of this BuildConfigurationRest. :param build_type: The build_type of this BuildConfigurationRest. :type: str """ allowed_values = ["MVN", "NPM"] if build_type not in allowed_values: raise ValueError( "Invalid value for `build_type` ({0}), must be one of {1}" .fo... |
def ssh_client(host, username=None, password=None, **kwargs): """ Create a new :class:`paramiko.SSHClient`, connect it and return the instance. This is a simple wrapper around the connect method that add some good defaults when using username/password to connect. """ client = paramiko.SSHClient() # save hostname and us... |
def failUnlessWarns(self, category, message, filename, f, *args, **kwargs): """ Fail if the given function doesn't generate the specified warning when called. It calls the function, checks the warning, and forwards the result of the function if everything is fine. @param category: the category of the warning to check. ... |
warningsShown: self.fail("No warnings emitted") first = warningsShown[0] for other in warningsShown[1:]: if other[:2] != first[:2]: self.fail("Can't handle different warnings") gotMessage, gotCategory, gotFilename, lineno = first[:4] self.assertEqual(gotMessage, message) self.assertIdentical(gotCategory, category) # Us... |
def _setup_default_handler(progname, fmt=None, datefmt=None, **_): """Create a Stream handler (default handler). Args: progname (str): Name of program. fmt (:obj:`str`, optional): Desired log format if different than the default; uses the same formatting string options supported in the stdlib's `logging` module. datefm... |
def setup_logging(progname, level, handlers, **kwargs): """Setup logging to stdout (stream), syslog, or stackdriver. Attaches handler(s) and sets log level to the root logger. Example usage: import logging from ulogger import setup_logging setup_logging('my_awesome_program', 'INFO', ['stream']) logging.info('ohai') Arg... |
**kwargs) logging.getLogger('').addHandler(handler) level = logging.getLevelName(level) logging.getLogger('').setLevel(level) |
def sim(self, key, size=None): ''' key: memory address(int) or register name(str) size: size of object in bytes ''' project = load_project() if key in project.arch.registers: if size is None: size = project.arch.registers[key][1] size *= 8 s = claripy.BVS("angrdbg_reg_" + str(key), size) setattr(self.state.regs, key, s... |
def add_distributed_artifact(self, id, **kwargs): """ Adds an artifact to the list of distributed artifacts for this product milestone This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def cal... |
def cancel_milestone_close(self, id, **kwargs): """ Cancel Product Milestone Release process. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(resp... |
def close_milestone(self, id, **kwargs): """ Close/Release a Product Milestone This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >>> >>> t... |
def get_distributed_artifacts(self, id, **kwargs): """ Get the artifacts distributed in this milestone This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pp... |
def get_distributed_builds(self, id, **kwargs): """ Gets the set of builds which produced artifacts distributed/shipped in a Product Milestone This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>>... |
def get_performed_builds(self, id, **kwargs): """ Gets the set of builds performed during in a Product Milestone cycle This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(r... |
def remove_distributed_artifact(self, id, artifact_id, **kwargs): """ Removes an artifact from the specified product milestone This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_fu... |
def playlists(self): """获取用户创建的歌单 如果不是用户本人,则不能获取用户默认精选集 """ if self._playlists is None: playlists_data = self._api.user_playlists(self.identifier) playlists = [] for playlist_data in playlists_data: playlist = _deserialize(playlist_data, PlaylistSchema) playlists.append(playlist) self._playlists = playlists return self... |
def fav_songs(self): """ FIXME: 支持获取所有的收藏歌曲 """ if self._fav_songs is None: songs_data = self._api.user_favorite_songs(self.identifier) self._fav_songs = [] if not songs_data: return for song_data in songs_data: song = _deserialize(song_data, NestedSongSchema) self._fav_songs.append(song) return self._fav_songs |
def parse(timestamp, utc=False, produce_naive=False): ''' Parse an :RFC:`3339`-formatted timestamp and return a `datetime.datetime`. If the timestamp is presented in UTC, then the `tzinfo` parameter of the returned `datetime` will be set to `pytz.utc`. >>> parse('2009-01-01T10:01:02Z') datetime.datetime(2009, 1, 1, 10,... |
input. >>> parse('2009-01-01T06:01:02') Traceback (most recent call last): ... ValueError: timestamp does not conform to RFC 3339 >>> parse('2009-01-01T25:01:02Z') Traceback (most recent call last): ... ValueError: hour must be in 0..23 ''' parse_re = re.compile(r'''^(?:(?:(?P<date_fullyear>[0-9]{4})\-(?P<date_month>[0... |
def add_song(fpath, g_songs, g_artists, g_albums): """ parse music file metadata with Easymp3 and return a song model. """ try: if fpath.endswith('mp3') or fpath.endswith('ogg') or fpath.endswith('wma'): metadata = EasyMP3(fpath) elif fpath.endswith('m4a'): metadata = EasyMP4(fpath) except MutagenError as e: logger.exc... |
= ''.join([title, artists_name, album_name, str(int(duration))]) song_id = gen_id(song_id_str) if song_id not in g_songs: # 剩下 album, lyric 三个字段没有初始化 song = LSongModel(identifier=song_id, artists=[], title=title, url=fpath, duration=duration, comments=[], # 下面这些字段不向外暴露 genre=data['genre'], cover=data['cover'], date=dat... |
artist_name_list: artist_id = gen_id(artist_name) if artist_id in g_artists: artist = g_artists[artist_id] else: artist = create_artist(identifier=artist_id, name=artist_name) g_artists[artist_id] = artist if artist not in song.artists: song.artists.append(artist) if song not in artist.songs: artist.songs.append(song) |
def scan(self, paths=None, depth=2): """scan media files in all paths """ song_exts = ['mp3', 'ogg', 'wma', 'm4a'] exts = song_exts paths = paths or [Library.DEFAULT_MUSIC_FOLDER] depth = depth if depth <= 3 else 3 media_files = [] for directory in paths: logger.debug('正在扫描目录(%s)...', directory) media_files.extend(scan... |
def cases(self, env, data): '''Calls each nested handler until one of them returns nonzero result. If any handler returns `None`, it is interpreted as "request does not match, the handler has nothing to do with it and `web.cases` should try to call the next handler".''' for handler in self.handlers: env._push() data._p... |
def create_win32tz_map(windows_zones_xml): """Creates a map between Windows and Olson timezone names. Args: windows_zones_xml: The CLDR XML mapping. Yields: (win32_name, olson_name, comment) """ coming_comment = None win32_name = None territory = None parser = genshi.input.XMLParser(StringIO(windows_zones_xml)) map_zon... |
def update_stored_win32tz_map(): """Downloads the cldr win32 timezone map and stores it in win32tz_map.py.""" windows_zones_xml = download_cldr_win32tz_map_xml() source_hash = hashlib.md5(windows_zones_xml).hexdigest() if hasattr(windows_zones_xml, "decode"): windows_zones_xml = windows_zones_xml.decode("utf-8") map_zo... |
str(olson_name), comment or "")) map_file.write("}\n") map_file.close() return True |
def load_mo(self, state, page_idx): """ Loads a memory object from memory. :param page_idx: the index into the page :returns: a tuple of the object """ mo = self._storage[page_idx - self._page_addr] #print filter(lambda x: x != None, self._storage) if mo is None and hasattr(self, "from_dbg"): byte_val = get_debugger().... |
def load_slice(self, state, start, end): """ Return the memory objects overlapping with the provided slice. :param start: the start address :param end: the end address (non-inclusive) :returns: tuples of (starting_addr, memory_object) """ items = [] if start > self._page_addr + self._page_size or end < self._page_addr:... |
def load_objects(self, addr, num_bytes, ret_on_segv=False): """ Load memory objects from paged memory. :param addr: Address to start loading. :param num_bytes: Number of bytes to load. :param bool ret_on_segv: True if you want load_bytes to return directly when a SIGSEV is triggered, otherwise a SimSegfaultError will b... |
return result |
def memory_objects_for_name(self, n): """ Returns a set of :class:`SimMemoryObjects` that contain expressions that contain a variable with the name of `n`. This is useful for replacing those values in one fell swoop with :func:`replace_memory_object()`, even if they have been partially overwritten. """ return set([self... |
def memory_objects_for_hash(self, n): """ Returns a set of :class:`SimMemoryObjects` that contain expressions that contain a variable with the hash `h`. """ return set([self[i] for i in self.addrs_for_hash(n)]) |
def permissions(self, addr, permissions=None): """ Returns the permissions for a page at address `addr`. If optional argument permissions is given, set page permissions to that prior to returning permissions. """ if self.state.solver.symbolic(addr): raise SimMemoryError( "page permissions cannot currently be looked up ... |
def call_interval(freq, **kwargs): """Decorator for the CallInterval wrapper""" def wrapper(f): return CallInterval(f, freq, **kwargs) return wrapper |
def add(self, *args, **kwargs): """Add a new record to the section""" if self.start and self.start.state == 'done' and kwargs.get('log_action') != 'done': raise ProgressLoggingError("Can't add -- process section is done") self.augment_args(args, kwargs) kwargs['log_action'] = kwargs.get('log_action', 'add') rec = Proce... |
def update(self, *args, **kwargs): """Update the last section record""" self.augment_args(args, kwargs) kwargs['log_action'] = kwargs.get('log_action', 'update') if not self.rec: return self.add(**kwargs) else: for k, v in kwargs.items(): # Don't update object; use whatever was set in the original record if k not in ('... |
def add_update(self, *args, **kwargs): """A records is added, then on subsequent calls, updated""" if not self._ai_rec_id: self._ai_rec_id = self.add(*args, **kwargs) else: au_save = self._ai_rec_id self.update(*args, **kwargs) self._ai_rec_id = au_save return self._ai_rec_id |
def update_done(self, *args, **kwargs): """Clear out the previous update""" kwargs['state'] = 'done' self.update(*args, **kwargs) self.rec = None |
def done(self, *args, **kwargs): """Mark the whole ProgressSection as done""" kwargs['state'] = 'done' pr_id = self.add(*args, log_action='done', **kwargs) self._session.query(Process).filter(Process.group == self._group).update({Process.state: 'done'}) self.start.state = 'done' self._session.commit() return pr_id |
def start(self, phase, stage, **kwargs): """Start a new routine, stage or phase""" return ProgressSection(self, self._session, phase, stage, self._logger, **kwargs) |
def records(self): """Return all start records for this the dataset, grouped by the start record""" return (self._session.query(Process) .filter(Process.d_vid == self._d_vid)).all() |
def starts(self): """Return all start records for this the dataset, grouped by the start record""" return (self._session.query(Process) .filter(Process.d_vid == self._d_vid) .filter(Process.log_action == 'start') ).all() |
def query(self): """Return all start records for this the dataset, grouped by the start record""" return self._session.query(Process).filter(Process.d_vid == self._d_vid) |
def exceptions(self): """Return all start records for this the dataset, grouped by the start record""" return (self._session.query(Process) .filter(Process.d_vid == self._d_vid) .filter(Process.exception_class != None) .order_by(Process.modified)).all() |
def clean(self): """Delete all of the records""" # Deleting seems to be really weird and unrelable. self._session \ .query(Process) \ .filter(Process.d_vid == self._d_vid) \ .delete(synchronize_session='fetch') for r in self.records: self._session.delete(r) self._session.commit() |
def build(self): """Access build configuration values as attributes. See self.process for a usage example""" from ambry.orm.config import BuildConfigGroupAccessor # It is a lightweight object, so no need to cache return BuildConfigGroupAccessor(self.dataset, 'buildstate', self._session) |
def configure_logging(add_handler, log=log): """ Configure log records. If adding a handler, make the formatter print all passed in key:value data. ie log.extra('msg', extra=dict(a=1)) generates 'msg a=1' `add_handler` (True, False, None, or Handler instance) if True, add a logging.StreamHandler() instance if False, do... |
log.propagate = False return log |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.