本文整理汇总了Python中daklib.config.Config.subtree方法的典型用法代码示例。如果您正苦于以下问题:Python Config.subtree方法的具体用法?Python Config.subtree怎么用?Python Config.subtree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类daklib.config.Config
的用法示例。
在下文中一共展示了Config.subtree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main():
global Options, Logger
cnf = Config()
session = DBConn().session()
Arguments = [('h', "help", "Archive-Dedup-Pool::Options::Help")]
apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
for i in ["help"]:
key = "Archive-Dedup-Pool::Options::%s" % i
if key not in cnf:
cnf[key] = ""
Options = cnf.subtree("Archive-Dedup-Pool::Options")
if Options["Help"]:
usage()
Logger = daklog.Logger("archive-dedup-pool")
dedup(session)
Logger.close()
示例2: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main():
global Options, Logger
cnf = Config()
Arguments = [('h', "help", "Obsolete::Options::Help"),
('s', "suite", "Obsolete::Options::Suite", "HasArg"),
('n', "no-action", "Obsolete::Options::No-Action"),
('f', "force", "Obsolete::Options::Force")]
cnf['Obsolete::Options::Help'] = ''
cnf['Obsolete::Options::No-Action'] = ''
cnf['Obsolete::Options::Force'] = ''
apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
Options = cnf.subtree("Obsolete::Options")
if Options['Help']:
usage()
if 'Suite' not in Options:
query_suites = DBConn().session().query(Suite)
suites = [suite.suite_name for suite in query_suites.all()]
cnf['Obsolete::Options::Suite'] = ','.join(suites)
Logger = daklog.Logger("dominate")
session = DBConn().session()
for suite_name in utils.split_args(Options['Suite']):
suite = session.query(Suite).filter_by(suite_name = suite_name).one()
if not suite.untouchable or Options['Force']:
doDaDoDa(suite.suite_id, session)
if Options['No-Action']:
session.rollback()
else:
session.commit()
Logger.close()
示例3: init
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def init(session):
global cnf, Options
cnf = Config()
Arguments = [
("h", "help", "Show-New::Options::Help"),
("p", "html-path", "Show-New::HTMLPath", "HasArg"),
("q", "queue", "Show-New::Options::Queue", "HasArg"),
]
for i in ["help"]:
if not cnf.has_key("Show-New::Options::%s" % (i)):
cnf["Show-New::Options::%s" % (i)] = ""
changesnames = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
Options = cnf.subtree("Show-New::Options")
if Options["help"]:
usage()
queue_names = Options.find("Queue", "new").split(",")
uploads = (
session.query(PolicyQueueUpload)
.join(PolicyQueueUpload.policy_queue)
.filter(PolicyQueue.queue_name.in_(queue_names))
.join(PolicyQueueUpload.changes)
.order_by(DBChange.source)
)
if len(changesnames) > 0:
uploads = uploads.filter(DBChange.changesname.in_(changesnames))
return uploads
示例4: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main(argv=None):
if argv is None:
argv = sys.argv
arguments = [('h', 'help', 'Export::Options::Help'),
('a', 'all', 'Export::Options::All'),
('c', 'copy', 'Export::Options::Copy'),
('d', 'directory', 'Export::Options::Directory', 'HasArg'),
('q', 'queue', 'Export::Options::Queue', 'HasArg')]
cnf = Config()
source_names = apt_pkg.parse_commandline(cnf.Cnf, arguments, argv)
options = cnf.subtree('Export::Options')
if 'Help' in options or 'Queue' not in options:
usage()
sys.exit(0)
session = DBConn().session()
queue = session.query(PolicyQueue).filter_by(queue_name=options['Queue']).first()
if queue is None:
print("Unknown queue '{0}'".format(options['Queue']))
sys.exit(1)
uploads = session.query(PolicyQueueUpload).filter_by(policy_queue=queue)
if 'All' not in options:
uploads = uploads.filter(DBChange.source.in_(source_names))
directory = options.get('Directory', '.')
symlink = 'Copy' not in options
for u in uploads:
UploadCopy(u).export(directory, symlink=symlink, ignore_existing=True)
示例5: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main():
cnf = Config()
Arguments = [('h', "help", "External-Overrides::Options::Help"),
('f', 'force', 'External-Overrides::Options::Force')]
args = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
try:
Options = cnf.subtree("External-Overrides::Options")
except KeyError:
Options = {}
if "Help" in Options:
usage()
force = False
if "Force" in Options and Options["Force"]:
force = True
logger = daklog.Logger('external-overrides')
command = args[0]
if command in ('import', 'i'):
external_overrides_import(args[1], args[2], args[3], sys.stdin, force)
elif command in ('copy', 'c'):
external_overrides_copy(args[1], args[2], force)
else:
print("E: Unknown commands.")
示例6: init
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def init (self):
cnf = Config()
arguments = [('h', "help", "Update-DB::Options::Help")]
for i in [ "help" ]:
if not cnf.has_key("Update-DB::Options::%s" % (i)):
cnf["Update-DB::Options::%s" % (i)] = ""
arguments = apt_pkg.parse_commandline(cnf.Cnf, arguments, sys.argv)
options = cnf.subtree("Update-DB::Options")
if options["Help"]:
self.usage()
elif arguments:
utils.warn("dak update-db takes no arguments.")
self.usage(exit_code=1)
try:
if os.path.isdir(cnf["Dir::Lock"]):
lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'dinstall.lock'), os.O_RDWR | os.O_CREAT)
fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
else:
utils.warn("Lock directory doesn't exist yet - not locking")
except IOError as e:
if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.")
self.update_db()
示例7: init
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def init(self):
cnf = Config()
arguments = [('h', "help", "Update-DB::Options::Help"),
("y", "yes", "Update-DB::Options::Yes")]
for i in ["help"]:
key = "Update-DB::Options::%s" % i
if key not in cnf:
cnf[key] = ""
arguments = apt_pkg.parse_commandline(cnf.Cnf, arguments, sys.argv)
options = cnf.subtree("Update-DB::Options")
if options["Help"]:
self.usage()
elif arguments:
utils.warn("dak update-db takes no arguments.")
self.usage(exit_code=1)
try:
if os.path.isdir(cnf["Dir::Lock"]):
lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'daily.lock'), os.O_RDONLY | os.O_CREAT)
fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
else:
utils.warn("Lock directory doesn't exist yet - not locking")
except IOError as e:
if e.errno in (errno.EACCES, errno.EAGAIN):
utils.fubar("Couldn't obtain lock, looks like archive is doing something, try again later.")
self.update_db()
示例8: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main():
cnf = Config()
Arguments = [
('h', "help", "Copy-Installer::Options::Help"),
('s', "source", "Copy-Installer::Options::Source", "HasArg"),
('d', "destination", "Copy-Installer::Options::Destination", "HasArg"),
('n', "no-action", "Copy-Installer::Options::No-Action"),
]
for option in ["help", "source", "destination", "no-action"]:
key = "Copy-Installer::Options::%s" % option
if key not in cnf:
cnf[key] = ""
extra_arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
Options = cnf.subtree("Copy-Installer::Options")
if Options["Help"]:
usage()
if len(extra_arguments) != 1:
usage(1)
initializer = {"version": extra_arguments[0]}
if Options["Source"] != "":
initializer["source"] = Options["Source"]
if Options["Destination"] != "":
initializer["dest"] = Options["Destination"]
copier = InstallerCopier(**initializer)
print(copier.get_message())
if Options["No-Action"]:
print('Do nothing because --no-action has been set.')
else:
copier.do_copy()
print('Installer has been copied successfully.')
示例9: check_upload_for_external_signature_request
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def check_upload_for_external_signature_request(session, target_suite, suite, binary):
if 'External-Signature-Requests' not in Config():
return
config = Config().subtree('External-Signature-Requests')
config_sources = config.subtree('Sources')
source = binary.source
if source.source not in config_sources:
return
src_config = config_sources.subtree(source.source)
if binary.package not in src_config.value_list('Packages'):
return
suites = config.value_list('Default-Suites')
if 'Suites' in src_config:
suites = src_config.value_list('Suites')
if target_suite.suite_name not in suites:
return
archs = config.value_list('Default-Architectures')
if 'Architectures' in src_config:
archs = src_config.value_list('Architectures')
if binary.architecture.arch_string not in archs:
return
add_external_signature_request(session, target_suite, suite, binary)
示例10: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main():
cnf = Config()
Arguments = [('a', "architecture", "Ls::Options::Architecture", "HasArg"),
('b', "binarytype", "Ls::Options::BinaryType", "HasArg"),
('c', "component", "Ls::Options::Component", "HasArg"),
('f', "format", "Ls::Options::Format", "HasArg"),
('g', "greaterorequal", "Ls::Options::GreaterOrEqual"),
('G', "greaterthan", "Ls::Options::GreaterThan"),
('r', "regex", "Ls::Options::Regex"),
('s', "suite", "Ls::Options::Suite", "HasArg"),
('S', "source-and-binary", "Ls::Options::Source-And-Binary"),
('h', "help", "Ls::Options::Help")]
for i in ["architecture", "binarytype", "component", "format",
"greaterorequal", "greaterthan", "regex", "suite",
"source-and-binary", "help"]:
key = "Ls::Options::%s" % i
if key not in cnf:
cnf[key] = ""
packages = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
Options = cnf.subtree("Ls::Options")
if Options["Help"]:
usage()
if not packages:
utils.fubar("need at least one package name as an argument.")
# Handle buildd maintenance helper options
if Options["GreaterOrEqual"] or Options["GreaterThan"]:
if Options["GreaterOrEqual"] and Options["GreaterThan"]:
utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.")
if not Options["Suite"]:
Options["Suite"] = "unstable"
kwargs = dict()
if Options["Regex"]:
kwargs['regex'] = True
if Options["Source-And-Binary"]:
kwargs['source_and_binary'] = True
if Options["Suite"]:
kwargs['suites'] = utils.split_args(Options['Suite'])
if Options["Architecture"]:
kwargs['architectures'] = utils.split_args(Options['Architecture'])
if Options['BinaryType']:
kwargs['binary_types'] = utils.split_args(Options['BinaryType'])
if Options['Component']:
kwargs['components'] = utils.split_args(Options['Component'])
if Options['Format']:
kwargs['format'] = Options['Format']
if Options['GreaterOrEqual']:
kwargs['highest'] = '>='
elif Options['GreaterThan']:
kwargs['highest'] = '>>'
for line in list_packages(packages, **kwargs):
print(line)
示例11: do_update
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def do_update(self):
print "Updating use of queue table"
try:
c = self.db.cursor()
cnf = Config()
print "Adding path to queue table"
c.execute("ALTER TABLE queue ADD COLUMN path TEXT")
c.execute("SELECT * FROM queue")
rows = c.fetchall()
seenqueues = {}
for row in rows:
dir = cnf["Dir::Queue::%s" % row[1]].rstrip('/')
seenqueues[row[1].lower()] = 1
print "Setting %s queue to use path %s" % (row[1], dir)
c.execute("UPDATE queue SET path = %s WHERE id = %s", (dir, row[0]))
print "Adding missing queues to the queue table"
for q in cnf.subtree("Dir::Queue").keys():
qname = q.lower()
if qname in seenqueues.keys():
continue
if qname in ["done", "holding", "reject", "newstage", "btsversiontrack"]:
print "Skipping queue %s" % qname
continue
pth = cnf["Dir::Queue::%s" % qname].rstrip('/')
if not os.path.exists(pth):
print "Skipping %s as %s does not exist" % (qname, pth)
continue
print "Adding %s queue with path %s" % (qname, pth)
c.execute("INSERT INTO queue (queue_name, path) VALUES (%s, %s)", (qname, pth))
seenqueues[qname] = 1
print "Adding queue and approved_for columns to known_changes"
c.execute("ALTER TABLE known_changes ADD COLUMN in_queue INT4 REFERENCES queue(id) DEFAULT NULL")
c.execute("ALTER TABLE known_changes ADD COLUMN approved_for INT4 REFERENCES queue(id) DEFAULT NULL")
print "Adding policy queue column to suite table"
c.execute("ALTER TABLE suite DROP COLUMN policy_engine")
c.execute("ALTER TABLE suite ADD COLUMN policy_queue_id INT4 REFERENCES queue(id) DEFAULT NULL")
# Handle some of our common cases automatically
if seenqueues.has_key('proposedupdates'):
c.execute("""UPDATE suite SET policy_queue_id = (SELECT id FROM queue WHERE queue_name = 'proposedupdates')
WHERE suite_name = 'proposed-updates'""")
if seenqueues.has_key('oldproposedupdates'):
c.execute("""UPDATE suite SET policy_queue_id = (SELECT id FROM queue WHERE queue_name = 'oldproposedupdates')
WHERE suite_name = 'oldstable-proposed-updates'""")
print "Committing"
c.execute("UPDATE config SET value = '20' WHERE name = 'db_revision'")
self.db.commit()
except psycopg2.InternalError as msg:
self.db.rollback()
raise DBUpdateError("Unable to apply debversion update 20, rollback issued. Error message : %s" % (str(msg)))
示例12: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main(argv=None):
if argv is None:
argv = sys.argv
arguments = [('h', 'help', 'Export::Options::Help'),
('c', 'copy', 'Export::Options::Copy'),
('d', 'directory', 'Export::Options::Directory', 'HasArg'),
('r', 'relative', 'Export::Options::Relative'),
('s', 'suite', 'Export::Options::Suite', 'HasArg')]
cnf = Config()
apt_pkg.parse_commandline(cnf.Cnf, arguments, argv)
options = cnf.subtree('Export::Options')
if 'Help' in options or 'Suite' not in options:
usage()
sys.exit(0)
session = DBConn().session()
suite = session.query(Suite).filter_by(suite_name=options['Suite']).first()
if suite is None:
print "Unknown suite '{0}'".format(options['Suite'])
sys.exit(1)
directory = options.get('Directory')
if not directory:
print "No target directory."
sys.exit(1)
symlink = 'Copy' not in options
relative = 'Relative' in options
if relative and not symlink:
print "E: --relative and --copy cannot be used together."
sys.exit(1)
binaries = suite.binaries
sources = suite.sources
files = []
files.extend([ b.poolfile for b in binaries ])
for s in sources:
files.extend([ ds.poolfile for ds in s.srcfiles ])
with FilesystemTransaction() as fs:
for f in files:
af = session.query(ArchiveFile) \
.join(ArchiveFile.component).join(ArchiveFile.file) \
.filter(ArchiveFile.archive == suite.archive) \
.filter(ArchiveFile.file == f).first()
src = af.path
if relative:
src = os.path.relpath(src, directory)
dst = os.path.join(directory, f.basename)
if not os.path.exists(dst):
fs.copy(src, dst, symlink=symlink)
fs.commit()
示例13: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main(argv=None):
if argv is None:
argv = sys.argv
arguments = [('h', 'help', 'Export::Options::Help'),
('c', 'copy', 'Export::Options::Copy'),
('d', 'directory', 'Export::Options::Directory', 'HasArg'),
('s', 'suite', 'Export::Options::Suite', 'HasArg')]
cnf = Config()
apt_pkg.parse_commandline(cnf.Cnf, arguments, argv)
options = cnf.subtree('Export::Options')
if 'Help' in options or 'Suite' not in options:
usage()
sys.exit(0)
session = DBConn().session()
suite = session.query(Suite).filter_by(suite_name=options['Suite']).first()
if suite is None:
print "Unknown suite '{0}'".format(options['Suite'])
sys.exit(1)
directory = options.get('Directory')
if not directory:
print "No target directory."
sys.exit(1)
symlink = 'Copy' not in options
binaries = suite.binaries
sources = suite.sources
files = []
files.extend([ b.poolfile for b in binaries ])
for s in sources:
files.extend([ ds.poolfile for ds in s.srcfiles ])
with FilesystemTransaction() as fs:
for f in files:
af = session.query(ArchiveFile) \
.join(ArchiveFile.component).join(ArchiveFile.file) \
.filter(ArchiveFile.archive == suite.archive) \
.filter(ArchiveFile.file == f).first()
# XXX: Remove later. There was a bug that caused only the *.dsc to
# be installed in build queues and we do not want to break them.
# The bug was fixed in 55d2c7e6e2418518704623246021021e05b90e58
# on 2012-11-04
if af is None:
af = session.query(ArchiveFile) \
.join(ArchiveFile.component).join(ArchiveFile.file) \
.filter(ArchiveFile.file == f).first()
dst = os.path.join(directory, f.basename)
if not os.path.exists(dst):
fs.copy(af.path, dst, symlink=symlink)
fs.commit()
示例14: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main():
global Options, Logger, Sections, Priorities
cnf = Config()
session = DBConn().session()
Arguments = [('a',"automatic","Process-New::Options::Automatic"),
('b',"no-binaries","Process-New::Options::No-Binaries"),
('c',"comments","Process-New::Options::Comments"),
('h',"help","Process-New::Options::Help"),
('m',"manual-reject","Process-New::Options::Manual-Reject", "HasArg"),
('t',"trainee","Process-New::Options::Trainee"),
('n',"no-action","Process-New::Options::No-Action")]
for i in ["automatic", "no-binaries", "comments", "help", "manual-reject", "no-action", "version", "trainee"]:
if not cnf.has_key("Process-New::Options::%s" % (i)):
cnf["Process-New::Options::%s" % (i)] = ""
changes_files = apt_pkg.parse_commandline(cnf.Cnf,Arguments,sys.argv)
if len(changes_files) == 0:
new_queue = get_policy_queue('new', session );
changes_paths = [ os.path.join(new_queue.path, j) for j in utils.get_changes_files(new_queue.path) ]
else:
changes_paths = [ os.path.abspath(j) for j in changes_files ]
Options = cnf.subtree("Process-New::Options")
if Options["Help"]:
usage()
if not Options["No-Action"]:
try:
Logger = daklog.Logger("process-new")
except CantOpenError as e:
Options["Trainee"] = "True"
Sections = Section_Completer(session)
Priorities = Priority_Completer(session)
readline.parse_and_bind("tab: complete")
if len(changes_paths) > 1:
sys.stderr.write("Sorting changes...\n")
changes_files = sort_changes(changes_paths, session, Options["No-Binaries"])
if Options["Comments"]:
show_new_comments(changes_files, session)
else:
for changes_file in changes_files:
changes_file = utils.validate_changes_file_arg(changes_file, 0)
if not changes_file:
continue
print "\n" + os.path.basename(changes_file)
do_pkg (changes_file, session)
end()
示例15: main
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import subtree [as 别名]
def main(argv=None):
if argv is None:
argv = sys.argv
arguments = [('h', 'help', 'Process-Commands::Options::Help'),
('d', 'directory', 'Process-Commands::Options::Directory', 'HasArg')]
cnf = Config()
cnf['Process-Commands::Options::Dummy'] = ''
filenames = apt_pkg.parse_commandline(cnf.Cnf, arguments, argv)
options = cnf.subtree('Process-Commands::Options')
if 'Help' in options or (len(filenames) == 0 and 'Directory' not in options):
usage()
sys.exit(0)
log = Logger('command')
now = datetime.datetime.now()
donedir = os.path.join(cnf['Dir::Done'], now.strftime('%Y/%m/%d'))
rejectdir = cnf['Dir::Reject']
if len(filenames) == 0:
filenames = [ fn for fn in os.listdir(options['Directory']) if fn.endswith('.dak-commands') ]
for fn in filenames:
basename = os.path.basename(fn)
if not fn.endswith('.dak-commands'):
log.log(['unexpected filename', basename])
continue
with open(fn, 'r') as fh:
data = fh.read()
try:
command = CommandFile(basename, data, log)
command.evaluate()
except:
created = os.stat(fn).st_mtime
now = time.time()
too_new = (now - created < int(cnf.get('Dinstall::SkipTime', '60')))
if too_new:
log.log(['skipped (too new)'])
continue
log.log(['reject', basename])
dst = find_next_free(os.path.join(rejectdir, basename))
else:
log.log(['done', basename])
dst = find_next_free(os.path.join(donedir, basename))
with FilesystemTransaction() as fs:
fs.unlink(fn)
fs.create(dst, mode=0o644).write(data)
fs.commit()
log.close()