Commit 32343595 authored by Bastian Blank's avatar Bastian Blank 🙊 Committed by Joerg Jaspert

Fix E302: Expected 2 blank lines, found 0

parent 3de33fa8
......@@ -23,6 +23,7 @@ import sys
from daklib.dbconn import DBConn, Fingerprint, Keyring, Uid, ACL
def usage():
print("""Usage:
dak acl set-fingerprints <acl-name>
......@@ -42,6 +43,7 @@ def usage():
Grant (revoke) per-source upload rights for ACL <acl-name>.
""")
def get_fingerprint(entry, session):
"""get fingerprint for given ACL entry
......@@ -76,6 +78,7 @@ def get_fingerprint(entry, session):
return q.all()
def acl_set_fingerprints(acl_name, entries):
session = DBConn().session()
acl = session.query(ACL).filter_by(name=acl_name).one()
......@@ -94,6 +97,7 @@ def acl_set_fingerprints(acl_name, entries):
session.commit()
def acl_export_per_source(acl_name):
session = DBConn().session()
acl = session.query(ACL).filter_by(name=acl_name).one()
......@@ -126,6 +130,7 @@ def acl_export_per_source(acl_name):
session.rollback()
session.close()
def acl_allow(acl_name, fingerprint, sources):
tbl = DBConn().tbl_acl_per_source
......@@ -150,6 +155,7 @@ def acl_allow(acl_name, fingerprint, sources):
session.commit()
def acl_deny(acl_name, fingerprint, sources):
tbl = DBConn().tbl_acl_per_source
......@@ -167,6 +173,7 @@ def acl_deny(acl_name, fingerprint, sources):
session.commit()
def main(argv=None):
if argv is None:
argv = sys.argv
......
......@@ -32,6 +32,7 @@ Logger = None
################################################################################
def usage(exit_code=0):
print """Usage: add-user [OPTION]...
Adds a new user to the dak databases and keyrings
......@@ -43,6 +44,7 @@ Adds a new user to the dak databases and keyrings
################################################################################
def main():
global Cnf
keyrings = None
......
......@@ -36,17 +36,22 @@ dispatch = {}
dryrun = False
################################################################################
def warn(msg):
print >> sys.stderr, msg
def die(msg, exit_code=1):
print >> sys.stderr, msg
sys.exit(exit_code)
def die_arglen(args, args_needed, msg):
if len(args) < args_needed:
die(msg)
def usage(exit_code=0):
"""Perform administrative work on the dak database."""
......@@ -153,6 +158,7 @@ Perform administrative work on the dak database.
################################################################################
def __architecture_list(d, args):
q = d.session().query(Architecture).order_by(Architecture.arch_string)
for j in q.all():
......@@ -162,6 +168,7 @@ def __architecture_list(d, args):
print j.arch_string
sys.exit(0)
def __architecture_add(d, args):
die_arglen(args, 4, "E: adding an architecture requires a name and a description")
print "Adding architecture %s" % args[2]
......@@ -188,6 +195,7 @@ def __architecture_add(d, args):
die("E: Error adding architecture %s (%s)" % (args[2], e))
print "Architecture %s added" % (args[2])
def __architecture_rm(d, args):
die_arglen(args, 3, "E: removing an architecture requires at least a name")
print "Removing architecture %s" % args[2]
......@@ -205,6 +213,7 @@ def __architecture_rm(d, args):
die("E: Error removing architecture %s (%s)" % (args[2], e))
print "Architecture %s removed" % args[2]
def architecture(command):
args = [str(x) for x in command]
Cnf = utils.get_conf()
......@@ -227,11 +236,13 @@ dispatch['a'] = architecture
################################################################################
def component_list():
session = DBConn().session()
for component in session.query(Component).order_by(Component.component_name):
print "{0} ordering={1}".format(component.component_name, component.ordering)
def component_add(args):
(name, description, ordering) = args[0:3]
......@@ -259,6 +270,7 @@ def component_add(args):
else:
session.commit()
def component_rm(name):
session = DBConn().session()
component = get_component(name, session)
......@@ -270,6 +282,7 @@ def component_rm(name):
else:
session.commit()
def component_rename(oldname, newname):
session = DBConn().session()
component = get_component(oldname, session)
......@@ -281,6 +294,7 @@ def component_rename(oldname, newname):
else:
session.commit()
def component(command):
mode = command[1]
if mode == 'list':
......@@ -298,6 +312,7 @@ dispatch['component'] = component
################################################################################
def __suite_list(d, args):
s = d.session()
for j in s.query(Suite).join(Suite.archive).order_by(Archive.archive_name, Suite.suite_name).all():
......@@ -306,6 +321,7 @@ def __suite_list(d, args):
else:
print "{0}".format(j.suite_name)
def __suite_show(d, args):
if len(args) < 2:
die("E: showing an suite entry requires a suite")
......@@ -317,6 +333,7 @@ def __suite_show(d, args):
print su.details()
def __suite_add(d, args, addallarches=False):
die_arglen(args, 4, "E: adding a suite requires at least a name and a version")
suite_name = args[2].lower()
......@@ -372,6 +389,7 @@ def __suite_add(d, args, addallarches=False):
s.commit()
def __suite_rm(d, args):
die_arglen(args, 3, "E: removing a suite requires at least a name")
name = args[2]
......@@ -390,6 +408,7 @@ def __suite_rm(d, args):
die("E: Error removing suite {0} ({1})".format(name, e))
print "Suite {0} removed".format(name)
def __suite_add_build_queue(d, args):
session = d.session()
......@@ -444,6 +463,7 @@ def __suite_add_build_queue(d, args):
session.commit()
def suite(command):
args = [str(x) for x in command]
Cnf = utils.get_conf()
......@@ -473,6 +493,7 @@ dispatch['s'] = suite
################################################################################
def __suite_architecture_list(d, args):
s = d.session()
for j in s.query(Suite).order_by(Suite.suite_name):
......@@ -480,6 +501,7 @@ def __suite_architecture_list(d, args):
print j.suite_name + ': ' + \
', '.join([a.arch_string for a in architectures])
def __suite_architecture_listarch(d, args):
die_arglen(args, 3, "E: suite-architecture list-arch requires a suite")
suite = get_suite(args[2].lower(), d.session())
......@@ -529,6 +551,7 @@ def __suite_architecture_add(d, args):
s.close()
def __suite_architecture_rm(d, args):
if len(args) < 3:
die("E: removing an suite-architecture entry requires a suite and arch")
......@@ -581,6 +604,7 @@ dispatch['s-a'] = suite_architecture
################################################################################
def __suite_component_list(d, args):
s = d.session()
for j in s.query(Suite).order_by(Suite.suite_name):
......@@ -636,6 +660,7 @@ def __suite_component_add(d, args):
s.commit()
s.close()
def __suite_component_rm(d, args):
if len(args) < 3:
die("E: removing an suite-component entry requires a suite and component")
......@@ -688,11 +713,13 @@ dispatch['s-c'] = suite_component
################################################################################
def archive_list():
session = DBConn().session()
for archive in session.query(Archive).order_by(Archive.archive_name):
print "{0} path={1} description={2} tainted={3}".format(archive.archive_name, archive.path, archive.description, archive.tainted)
def archive_add(args):
(name, path, description) = args[0:3]
......@@ -720,6 +747,7 @@ def archive_add(args):
else:
session.commit()
def archive_rm(name):
session = DBConn().session()
archive = get_archive(name, session)
......@@ -731,6 +759,7 @@ def archive_rm(name):
else:
session.commit()
def archive_rename(oldname, newname):
session = DBConn().session()
archive = get_archive(oldname, session)
......@@ -742,6 +771,7 @@ def archive_rename(oldname, newname):
else:
session.commit()
def archive(command):
mode = command[1]
if mode == 'list':
......@@ -759,16 +789,19 @@ dispatch['archive'] = archive
################################################################################
def __version_check_list(d):
session = d.session()
for s in session.query(Suite).order_by(Suite.suite_name):
__version_check_list_suite(d, s.suite_name)
def __version_check_list_suite(d, suite_name):
vcs = get_version_checks(suite_name)
for vc in vcs:
print "%s %s %s" % (suite_name, vc.check, vc.reference.suite_name)
def __version_check_add(d, suite_name, check, reference_name):
suite = get_suite(suite_name)
if not suite:
......@@ -785,6 +818,7 @@ def __version_check_add(d, suite_name, check, reference_name):
session.add(vc)
session.commit()
def __version_check_rm(d, suite_name, check, reference_name):
suite = get_suite(suite_name)
if not suite:
......@@ -801,6 +835,7 @@ def __version_check_rm(d, suite_name, check, reference_name):
except NoResultFound:
print "W: version-check not found."
def version_check(command):
args = [str(x) for x in command]
Cnf = utils.get_conf()
......@@ -831,6 +866,7 @@ dispatch['v-c'] = version_check
################################################################################
def show_config(command):
args = [str(x) for x in command]
cnf = utils.get_conf()
......@@ -886,6 +922,7 @@ dispatch['c'] = show_config
################################################################################
def show_keyring(command):
args = [str(x) for x in command]
cnf = utils.get_conf()
......@@ -910,6 +947,7 @@ def show_keyring(command):
for k in q.all():
print k.keyring_name
def keyring_add_buildd(command):
name = command[2]
arch_names = command[3:]
......@@ -934,6 +972,7 @@ def keyring_add_buildd(command):
session.commit()
def keyring(command):
if command[1].startswith('list-'):
show_keyring(command)
......@@ -947,6 +986,7 @@ dispatch['k'] = keyring
################################################################################
def change_component_source(transaction, suite, component, source_names):
session = transaction.session
......@@ -961,6 +1001,7 @@ def change_component_source(transaction, suite, component, source_names):
print "Copying {0}={1}".format(source.source, source.version)
transaction.copy_source(source, suite, component)
def change_component_binary(transaction, suite, component, binary_names):
session = transaction.session
......@@ -976,6 +1017,7 @@ def change_component_binary(transaction, suite, component, binary_names):
transaction.copy_binary(binary, suite, component)
pass
def change_component(args):
with daklib.archive.ArchiveTransaction() as transaction:
session = transaction.session
......@@ -996,6 +1038,7 @@ dispatch['change-component'] = change_component
################################################################################
def forget_signature(args):
filename = args[1]
with open(filename, 'r') as fh:
......@@ -1016,6 +1059,7 @@ dispatch['forget-signature'] = forget_signature
################################################################################
def main():
"""Perform administrative work on the dak database"""
global dryrun
......
......@@ -40,6 +40,7 @@ Logger = None
################################################################################
################################################################################
def usage(exit_code=0):
print """Usage: dak archive-dedup-pool [OPTION]...
-h, --help show this help and exit.
......@@ -49,6 +50,7 @@ def usage(exit_code=0):
################################################################################
def dedup_one(size, reference, *filenames):
stat_reference = os.stat(reference)
......@@ -83,6 +85,7 @@ def dedup_one(size, reference, *filenames):
################################################################################
def dedup(session):
results = session.execute("""
SELECT DISTINCT *
......@@ -113,6 +116,7 @@ SELECT DISTINCT *
################################################################################
def main():
global Options, Logger
......
......@@ -412,6 +412,7 @@ def decruft_newer_version_in(othersuite, suite_name, suite_id, rm_msg, session,
################################################################################
def main():
global Options
cnf = Config()
......
......@@ -36,6 +36,7 @@ import apt_pkg
from daklib import utils
import debianbts as bts
def usage():
print """
SYNOPSIS
......@@ -65,6 +66,7 @@ arguments = [('s','simulate','BtsCategorize::Options::Simulate'),
('q', 'quiet', 'BtsCategorize::Options::Quiet'),
('h', 'help', 'BtsCategorize::Options::Help')]
class BugClassifier(object):
"""
classify bugs using usertags based on the bug subject lines
......@@ -135,6 +137,7 @@ class BugClassifier(object):
log.error("couldn't retrieve bugs from soap interface: %s" % sys.exc_info()[0])
return None
def send_email(commands, simulate=False):
global Cnf
......@@ -149,6 +152,7 @@ def send_email(commands, simulate=False):
else:
utils.send_mail( bts_mail_message )
def main():
"""
for now, we just dump a list of commands that could be sent for
......
......@@ -54,6 +54,7 @@ current_time = time.time() #: now()
################################################################################
def usage(exit_code=0):
print """Usage: dak check-archive MODE
Run various sanity checks of the archive and/or database.
......@@ -78,6 +79,7 @@ The following MODEs are available:
################################################################################
def process_dir(unused, dirname, filenames):
"""
Process a directory and output every files name which is not listed already
......@@ -104,6 +106,7 @@ def process_dir(unused, dirname, filenames):
################################################################################
def check_files():
"""
Prepare the dictionary of existing filenames, then walk through the archive
......@@ -167,6 +170,7 @@ def check_files():
################################################################################
def check_dscs():
"""
Parse every .dsc file in the archive and check for it's validity.
......@@ -196,6 +200,7 @@ def check_dscs():
################################################################################
def check_override():
"""
Check for missing overrides in stable and unstable.
......@@ -265,6 +270,8 @@ def check_source_in_one_dir():
print "Found %d source packages where the source is not all in one directory." % (broken_count)
################################################################################
def check_checksums():
"""
Validate all files
......@@ -305,6 +312,7 @@ def check_checksums():
################################################################################
#
def Ent(Kind,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor):
global future_files
......@@ -312,6 +320,7 @@ def Ent(Kind,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor):
future_files[current_file] = MTime
print "%s: %s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % (current_file, Kind,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor)
def check_timestamps():
"""
Check all files for timestamps in the future; common from hardware
......@@ -340,6 +349,7 @@ def check_timestamps():
################################################################################
def check_files_in_dsc():
"""
Ensure each .dsc lists appropriate files in its Files field (according
......@@ -410,6 +420,7 @@ def validate_sources(suite, component):
########################################
def validate_packages(suite, component, architecture):
"""
Ensure files mentioned in Packages exist
......@@ -426,6 +437,7 @@ def validate_packages(suite, component, architecture):
########################################
def check_indices_files_exist():
"""
Ensure files mentioned in Packages & Sources exist
......@@ -443,6 +455,7 @@ def check_indices_files_exist():
################################################################################
def check_files_not_symlinks():
"""
Check files in the database aren't symlinks
......@@ -461,6 +474,7 @@ def check_files_not_symlinks():
################################################################################
def chk_bd_process_dir(unused, dirname, filenames):
for name in filenames:
if not name.endswith(".dsc"):
......@@ -478,6 +492,7 @@ def chk_bd_process_dir(unused, dirname, filenames):
################################################################################
def check_build_depends():
""" Validate build-dependencies of .dsc files in the archive """
cnf = Config()
......@@ -512,6 +527,7 @@ SELECT
WHERE NOT EXISTS (SELECT 1 FROM source_metadata md WHERE md.src_id=s.id AND md.key_id = :checksum_key);
"""
def add_missing_source_checksums():
""" Add missing source checksums to source_metadata """
session = DBConn().session()
......@@ -525,6 +541,7 @@ def add_missing_source_checksums():
################################################################################
def main():
global db_files, waste, excluded
......
......@@ -73,6 +73,7 @@ blacklist = {}
################################################################################
def usage(exit_code=0):
print """Usage: dak check-overrides
Check for cruft in overrides.
......@@ -84,6 +85,7 @@ Check for cruft in overrides.
################################################################################
def process(osuite, affected_suites, originosuite, component, otype, session):
global Logger, Options, sections, priorities
......
......@@ -53,6 +53,7 @@ delete_date = None
################################################################################
def usage(exit_code=0):
print """Usage: dak clean-queues [OPTIONS]
Clean out incoming directories.
......@@ -67,6 +68,7 @@ Clean out incoming directories.
################################################################################
def init(cnf):
global delete_date, del_dir
......@@ -106,6 +108,8 @@ def init(cnf):
utils.fubar("Cannot chdir to %s" % incoming)
# Remove a file to the morgue
def remove(from_dir, f):
fname = os.path.basename(f)
if os.access(f, os.R_OK):
......@@ -128,6 +132,8 @@ def remove(from_dir, f):
# Removes any old files.
# [Used for Incoming/REJECT]
#
def flush_old():
Logger.log(["check Incoming/REJECT for old files", os.getcwd()])
for f in os.listdir('.'):
......@@ -141,6 +147,8 @@ def flush_old():
# Removes any files which are old orphans (not associated with a valid .changes file).
# [Used for Incoming]
#
def flush_orphans():
all_files = {}
changes_files = []
......@@ -193,6 +201,7 @@ def flush_orphans():
################################################################################
def main():
global Options, Logger
......
......@@ -55,6 +55,7 @@ Logger = None
################################################################################
def usage(exit_code=0):
print """Usage: dak clean-suites [OPTIONS]
Clean old packages from suites.
......@@ -66,6 +67,7 @@ Clean old packages from suites.
################################################################################
def check_binaries(now_date, session):
Logger.log(["Checking for orphaned binary packages..."])
......@@ -108,6 +110,7 @@ def check_binaries(now_date, session):
########################################
def check_sources(now_date, session):
Logger.log(["Checking for orphaned source packages..."])
......@@ -167,6 +170,7 @@ def check_sources(now_date, session):
########################################
def check_files(now_date, session):
# FIXME: this is evil; nothing should ever be in this state. if
# they are, it's a bug.
......@@ -194,6 +198,7 @@ def check_files(now_date, session):
if not Options["No-Action"]:
session.commit()
def clean_binaries(now_date, session):
# We do this here so that the binaries we remove will have their
# source also removed (if possible).
......@@ -217,6 +222,7 @@ def clean_binaries(now_date, session):
########################################
def clean(now_date, archives, max_delete, session):
cnf = Config()
......@@ -331,6 +337,7 @@ def clean(now_date, archives, max_delete, session):
################################################################################
def clean_maintainers(now_date, session):
Logger.log(["Cleaning out unused Maintainer entries..."])
......@@ -358,6 +365,7 @@ SELECT m.id, m.name FROM maintainer m
################################################################################
def clean_fingerprints(now_date, session):
Logger.log(["Cleaning out unused fingerprint entries..."])
......@@ -386,6 +394,7 @@ SELECT f.id, f.fingerprint FROM fingerprint f
################################################################################
def clean_byhash(now_date, session):
cnf = Config()
suite_suffix = cnf.find("Dinstall::SuiteSuffix", "")
......@@ -419,6 +428,7 @@ def clean_byhash(now_date, session):
################################################################################
def clean_empty_directories(session):
"""
Removes empty directories from pool directories.
......@@ -447,6 +457,7 @@ def clean_empty_directories(session):
################################################################################
def set_archive_delete_dates(now_date, session):
session.execute("""