Package daklib :: Module dbconn
[hide private]
[frames] | no frames]

Module dbconn

source code

DB access class


Contact: Debian FTPMaster <ftpmaster@debian.org>

Copyright:

License: GNU General Public License version 2 or later

Classes [hide private]
  DebVersion
  ORMObject
ORMObject is a base class for all ORM classes mapped by SQLalchemy.
  ACL
  ACLPerSource
  Archive
  ArchiveFile
  BinContents
  DBBinary
  BuildQueue
  Component
  DBConfig
  DSCFile
  ExternalOverride
  PoolFile
  Fingerprint
  Keyring
  DBChange
  Maintainer
  NewComment
  Override
  OverrideType
  PolicyQueue
  PolicyQueueUpload
  PolicyQueueByhandFile
  Priority
  SignatureHistory
  SrcContents
  DBSource
  SrcFormat
  Suite
  Uid
  MetadataKey
  BinaryMetadata
  SourceMetadata
  MetadataProxy
  VersionCheck
  DBConn
database module init.
Functions [hide private]
 
session_wrapper(fn)
Wrapper around common ".., session=None):" handling.
source code
Architecture
get_architecture(architecture, session=None)
Returns database id for given architecture.
source code
Archive
get_archive(archive, session=None)
returns database id for given archive.
source code
list
get_suites_binary_in(package, session=None)
Returns list of Suite objects which given package name is in
source code
str or NoneType
get_component_by_package_suite(package, suite_list, arch_list=None, session=None)
Returns the component name of the newest binary package in suite_list or None if no package is found.
source code
int
get_component(component, session=None)
Returns database id for given component.
source code
 
get_mapped_component_name(component_name) source code
daklib.dbconn.Component or None
get_mapped_component(component_name, session=None)
get component after mappings
source code
list
get_component_names(session=None)
Returns list of strings of component names.
source code
list
get_dscfiles(dscfile_id=None, source_id=None, poolfile_id=None, session=None)
Returns a list of DSCFiles which may be empty
source code
Fingerprint
get_fingerprint(fpr, session=None)
Returns Fingerprint object for given fpr.
source code
Fingerprint
get_or_set_fingerprint(fpr, session=None)
Returns Fingerprint object for given fpr.
source code
 
get_ldap_name(entry) source code
Keyring
get_keyring(keyring, session=None)
If keyring does not have an entry in the keyrings table yet, return None If keyring already has an entry, simply return the existing Keyring
source code
list
get_active_keyring_paths(session=None)
Returns: list of active keyring paths
source code
DBChange
get_dbchange(filename, session=None)
returns DBChange object for given filename.
source code
Maintainer
get_or_set_maintainer(name, session=None)
Returns Maintainer object for given maintainer name.
source code
Maintainer
get_maintainer(maintainer_id, session=None)
Return the name of the maintainer behind maintainer_id or None if that maintainer_id is invalid.
source code
boolean
has_new_comment(policy_queue, package, version, session=None)
Returns true if the given combination of package, version has a comment.
source code
list
get_new_comments(policy_queue, package=None, version=None, comment_id=None, session=None)
Returns (possibly empty) list of NewComment objects for the given parameters
source code
list
get_override(package, suite=None, component=None, overridetype=None, session=None)
Returns Override object for the given parameters
source code
int
get_override_type(override_type, session=None)
Returns OverrideType object for given override type.
source code
PolicyQueue
get_policy_queue(queuename, session=None)
Returns PolicyQueue object for given queue name
source code
Priority
get_priority(priority, session=None)
Returns Priority object for given priority name.
source code
dictionary
get_priorities(session=None)
Returns dictionary of priority names -> id mappings
source code
Section
get_section(section, session=None)
Returns Section object for given section name.
source code
dictionary
get_sections(session=None)
Returns dictionary of section names -> id mappings
source code
list
get_suites_source_in(source, session=None)
Returns list of Suite objects which given source name is in
source code
string
get_source_in_suite(source, suite_name, session=None)
Returns a DBSource object for a combination of source and suite_name.
source code
 
import_metadata_into_db(obj, session=None)
This routine works on either DBBinary or DBSource objects and imports their metadata into the database
source code
Suite
get_suite(suite, session=None)
Returns Suite object for given suite name.
source code
list
get_suite_architectures(suite, skipsrc=False, skipall=False, session=None)
Returns list of Architecture objects for given suite name.
source code
Uid
get_or_set_uid(uidname, session=None)
Returns uid object for given uidname.
source code
 
get_uid_from_fingerprint(fpr, session=None) source code
MetadataKey
get_or_set_metadatakey(keyname, session=None)
Returns MetadataKey object for given uidname.
source code
 
get_version_checks(suite_name, check=None, session=None) source code
Variables [hide private]
  SUITE_FIELDS = [('SuiteName', 'suite_name'), ('SuiteID', 'suit...

Imports: apt_pkg, GpgException, functools, inspect, os, normpath, re, subprocess, warnings, Deb822, TarFile, create_engine, Table, desc, sessionmaker, mapper, relation, object_session, backref, object_mapper, sqlalchemy, attribute_mapped_collection, association_proxy, NoResultFound, AptVersion, Config, fix_maintainer, Base, postgresql, Architecture, Section


Function Details [hide private]

session_wrapper(fn)

source code 

Wrapper around common ".., session=None):" handling. If the wrapped function is called without passing 'session', we create a local one and destroy it when the function ends.

Also attaches a commit_or_flush method to the session; if we created a local session, this is a synonym for session.commit(), otherwise it is a synonym for session.flush().

get_architecture(architecture, session=None)

source code 

Returns database id for given architecture.

Parameters:
  • architecture (string) - The name of the architecture
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: Architecture
Architecture object for the given arch (None if not present)
Decorators:
  • @session_wrapper

get_archive(archive, session=None)

source code 

returns database id for given archive.

Parameters:
  • archive (string) - the name of the arhive
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: Archive
Archive object for the given name (None if not present)
Decorators:
  • @session_wrapper

get_suites_binary_in(package, session=None)

source code 

Returns list of Suite objects which given package name is in

Parameters:
  • package (str) - DBBinary package name to search for
Returns: list
list of Suite objects for the given package
Decorators:
  • @session_wrapper

get_component_by_package_suite(package, suite_list, arch_list=None, session=None)

source code 

Returns the component name of the newest binary package in suite_list or None if no package is found. The result can be optionally filtered by a list of architecture names.

Parameters:
  • package (str) - DBBinary package name to search for
  • suite_list (list of str) - list of suite_name items
  • arch_list (list of str) - optional list of arch_string items that defaults to []
Returns: str or NoneType
name of component or None
Decorators:
  • @session_wrapper

get_component(component, session=None)

source code 

Returns database id for given component.

Parameters:
  • component (string) - The name of the override type
Returns: int
the database id for the given component
Decorators:
  • @session_wrapper

get_mapped_component(component_name, session=None)

source code 

get component after mappings

Evaluate component mappings from ComponentMappings in dak.conf for the given component name.

Parameters:
  • component_name (str) - component name
  • session - database session
Returns: daklib.dbconn.Component or None
component after applying maps or None
Decorators:
  • @session_wrapper

To Do: ansgar wants to get rid of this. It's currently only used for the security archive

get_component_names(session=None)

source code 

Returns list of strings of component names.

Returns: list
list of strings of component names
Decorators:
  • @session_wrapper

get_dscfiles(dscfile_id=None, source_id=None, poolfile_id=None, session=None)

source code 

Returns a list of DSCFiles which may be empty

Parameters:
  • dscfile_id (int (optional)) - the dscfile_id of the DSCFiles to find
  • source_id (int (optional)) - the source id related to the DSCFiles to find
  • poolfile_id (int (optional)) - the poolfile id related to the DSCFiles to find
Returns: list
Possibly empty list of DSCFiles
Decorators:
  • @session_wrapper

get_fingerprint(fpr, session=None)

source code 

Returns Fingerprint object for given fpr.

Parameters:
  • fpr (string) - The fpr to find / add
  • session (SQLAlchemy) - Optional SQL session object (a temporary one will be generated if not supplied).
Returns: Fingerprint
the Fingerprint object for the given fpr or None
Decorators:
  • @session_wrapper

get_or_set_fingerprint(fpr, session=None)

source code 

Returns Fingerprint object for given fpr.

If no matching fpr is found, a row is inserted.

Parameters:
  • fpr (string) - The fpr to find / add
  • session (SQLAlchemy) - Optional SQL session object (a temporary one will be generated if not supplied). If not passed, a commit will be performed at the end of the function, otherwise the caller is responsible for commiting. A flush will be performed either way.
Returns: Fingerprint
the Fingerprint object for the given fpr
Decorators:
  • @session_wrapper

get_keyring(keyring, session=None)

source code 

If keyring does not have an entry in the keyrings table yet, return None If keyring already has an entry, simply return the existing Keyring

Parameters:
  • keyring (string) - the keyring name
Returns: Keyring
the Keyring object for this keyring
Decorators:
  • @session_wrapper

get_active_keyring_paths(session=None)

source code 
Returns: list
list of active keyring paths
Decorators:
  • @session_wrapper

get_dbchange(filename, session=None)

source code 

returns DBChange object for given filename.

Parameters:
  • filename (string) - the name of the file
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: DBChange
DBChange object for the given filename (None if not present)
Decorators:
  • @session_wrapper

get_or_set_maintainer(name, session=None)

source code 

Returns Maintainer object for given maintainer name.

If no matching maintainer name is found, a row is inserted.

Parameters:
  • name (string) - The maintainer name to add
  • session (SQLAlchemy) - Optional SQL session object (a temporary one will be generated if not supplied). If not passed, a commit will be performed at the end of the function, otherwise the caller is responsible for commiting. A flush will be performed either way.
Returns: Maintainer
the Maintainer object for the given maintainer
Decorators:
  • @session_wrapper

get_maintainer(maintainer_id, session=None)

source code 

Return the name of the maintainer behind maintainer_id or None if that maintainer_id is invalid.

Parameters:
  • maintainer_id (int) - the id of the maintainer
Returns: Maintainer
the Maintainer with this maintainer_id
Decorators:
  • @session_wrapper

has_new_comment(policy_queue, package, version, session=None)

source code 

Returns true if the given combination of package, version has a comment.

Parameters:
  • package (string) - name of the package
  • version (string) - package version
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: boolean
true/false
Decorators:
  • @session_wrapper

get_new_comments(policy_queue, package=None, version=None, comment_id=None, session=None)

source code 

Returns (possibly empty) list of NewComment objects for the given parameters

Parameters:
  • package (string (optional)) - name of the package
  • version (string (optional)) - package version
  • comment_id (int (optional)) - An id of a comment
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: list
A (possibly empty) list of NewComment objects will be returned
Decorators:
  • @session_wrapper

get_override(package, suite=None, component=None, overridetype=None, session=None)

source code 

Returns Override object for the given parameters

Parameters:
  • package (string) - The name of the package
  • suite (string, list or None) - The name of the suite (or suites if a list) to limit to. If None, don't limit. Defaults to None.
  • component (string, list or None) - The name of the component (or components if a list) to limit to. If None, don't limit. Defaults to None.
  • overridetype (string, list or None) - The name of the overridetype (or overridetypes if a list) to limit to. If None, don't limit. Defaults to None.
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: list
A (possibly empty) list of Override objects will be returned
Decorators:
  • @session_wrapper

get_override_type(override_type, session=None)

source code 

Returns OverrideType object for given override type.

Parameters:
  • override_type (string) - The name of the override type
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: int
the database id for the given override type
Decorators:
  • @session_wrapper

get_policy_queue(queuename, session=None)

source code 

Returns PolicyQueue object for given queue name

Parameters:
  • queuename (string) - The name of the queue
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: PolicyQueue
PolicyQueue object for the given queue
Decorators:
  • @session_wrapper

get_priority(priority, session=None)

source code 

Returns Priority object for given priority name.

Parameters:
  • priority (string) - The name of the priority
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: Priority
Priority object for the given priority
Decorators:
  • @session_wrapper

get_priorities(session=None)

source code 

Returns dictionary of priority names -> id mappings

Parameters:
  • session (Session) - Optional SQL session object (a temporary one will be generated if not supplied)
Returns: dictionary
dictionary of priority names -> id mappings
Decorators:
  • @session_wrapper

get_section(section, session=None)

source code 

Returns Section object for given section name.

Parameters:
  • section (string) - The name of the section
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: Section
Section object for the given section name
Decorators:
  • @session_wrapper

get_sections(session=None)

source code 

Returns dictionary of section names -> id mappings

Parameters:
  • session (Session) - Optional SQL session object (a temporary one will be generated if not supplied)
Returns: dictionary
dictionary of section names -> id mappings
Decorators:
  • @session_wrapper

get_suites_source_in(source, session=None)

source code 

Returns list of Suite objects which given source name is in

Parameters:
  • source (str) - DBSource package name to search for
Returns: list
list of Suite objects for the given source
Decorators:
  • @session_wrapper

get_source_in_suite(source, suite_name, session=None)

source code 

Returns a DBSource object for a combination of source and suite_name.

  • source - source package name, eg. mailfilter, bbdb, glibc
  • suite_name - a suite name, eg. unstable
Parameters:
  • source (string) - source package name
  • suite_name (string) - the suite name
Returns: string
the version for source in suite
Decorators:
  • @session_wrapper

import_metadata_into_db(obj, session=None)

source code 

This routine works on either DBBinary or DBSource objects and imports their metadata into the database

Decorators:
  • @session_wrapper

get_suite(suite, session=None)

source code 

Returns Suite object for given suite name.

Parameters:
  • suite (string) - The name of the suite
  • session (Session) - Optional SQLA session object (a temporary one will be generated if not supplied)
Returns: Suite
Suite object for the requested suite name (None if not present)
Decorators:
  • @session_wrapper

get_suite_architectures(suite, skipsrc=False, skipall=False, session=None)

source code 

Returns list of Architecture objects for given suite name. The list is empty if suite does not exist.

Parameters:
  • suite (str) - Suite name to search for
  • skipsrc (boolean) - Whether to skip returning the 'source' architecture entry (Default False)
  • skipall (boolean) - Whether to skip returning the 'all' architecture entry (Default False)
  • session (Session) - Optional SQL session object (a temporary one will be generated if not supplied)
Returns: list
list of Architecture objects for the given name (may be empty)
Decorators:
  • @session_wrapper

get_or_set_uid(uidname, session=None)

source code 

Returns uid object for given uidname.

If no matching uidname is found, a row is inserted.

Parameters:
  • uidname (string) - The uid to add
  • session (SQLAlchemy) - Optional SQL session object (a temporary one will be generated if not supplied). If not passed, a commit will be performed at the end of the function, otherwise the caller is responsible for commiting.
Returns: Uid
the uid object for the given uidname
Decorators:
  • @session_wrapper

get_uid_from_fingerprint(fpr, session=None)

source code 
Decorators:
  • @session_wrapper

get_or_set_metadatakey(keyname, session=None)

source code 

Returns MetadataKey object for given uidname.

If no matching keyname is found, a row is inserted.

Parameters:
  • keyname (string) - The keyname to add
  • session (SQLAlchemy) - Optional SQL session object (a temporary one will be generated if not supplied). If not passed, a commit will be performed at the end of the function, otherwise the caller is responsible for commiting.
Returns: MetadataKey
the metadatakey object for the given keyname
Decorators:
  • @session_wrapper

get_version_checks(suite_name, check=None, session=None)

source code 
Decorators:
  • @session_wrapper

Variables Details [hide private]

SUITE_FIELDS

Value:
[('SuiteName', 'suite_name'), ('SuiteID', 'suite_id'), ('Version', 've\
rsion'), ('Origin', 'origin'), ('Label', 'label'), ('Description', 'de\
scription'), ('Untouchable', 'untouchable'), ('Announce', 'announce'),\
 ('Codename', 'codename'), ('OverrideCodename', 'overridecodename'), (\
'ValidTime', 'validtime'), ('Priority', 'priority'), ('NotAutomatic', \
'notautomatic'), ('CopyChanges', 'copychanges'), ('OverrideSuite', 'ov\
erridesuite')]