提交 ce63c9c5 编写于 作者: F Frank Lichtenheld

process-upload: reorganise option parsing

Give more helpful error messages and log where we did get
the changes files from.
Signed-off-by: NFrank Lichtenheld <djpig@debian.org>
上级 94055d75
...@@ -149,11 +149,25 @@ Logger = None ...@@ -149,11 +149,25 @@ Logger = None
############################################################################### ###############################################################################
def init(): def usage (exit_code=0):
global Options print """Usage: dak process-upload [OPTION]... [CHANGES]...
-a, --automatic automatic run
-h, --help show this help and exit.
-n, --no-action don't do anything
-p, --no-lock don't check lockfile !! for cron.daily only !!
-s, --no-mail don't send any mail
-V, --version display the version number and exit"""
sys.exit(exit_code)
###############################################################################
def main():
global Options, Logger
# Initialize config and connection to db
cnf = Config() cnf = Config()
summarystats = SummaryStats()
log_urgency = False
DBConn() DBConn()
Arguments = [('a',"automatic","Dinstall::Options::Automatic"), Arguments = [('a',"automatic","Dinstall::Options::Automatic"),
...@@ -174,46 +188,10 @@ def init(): ...@@ -174,46 +188,10 @@ def init():
if Options["Help"]: if Options["Help"]:
usage() usage()
# If we have a directory flag, use it to find our files
if cnf["Dinstall::Options::Directory"] != "":
# Note that we clobber the list of files we were given in this case
# so warn if the user has done both
if len(changes_files) > 0:
utils.warn("Directory provided so ignoring files given on command line")
changes_files = utils.get_changes_files(cnf["Dinstall::Options::Directory"])
return changes_files
###############################################################################
def usage (exit_code=0):
print """Usage: dak process-upload [OPTION]... [CHANGES]...
-a, --automatic automatic run
-h, --help show this help and exit.
-n, --no-action don't do anything
-p, --no-lock don't check lockfile !! for cron.daily only !!
-s, --no-mail don't send any mail
-V, --version display the version number and exit"""
sys.exit(exit_code)
###############################################################################
def main():
global Logger
cnf = Config()
summarystats = SummaryStats()
changes_files = init()
log_urgency = False
stable_queue = None
# -n/--dry-run invalidates some other options which would involve things happening # -n/--dry-run invalidates some other options which would involve things happening
if Options["No-Action"]: if Options["No-Action"]:
Options["Automatic"] = "" Options["Automatic"] = ""
# Check that we aren't going to clash with the daily cron job
# Check that we aren't going to clash with the daily cron job # Check that we aren't going to clash with the daily cron job
if not Options["No-Action"] and os.path.exists("%s/daily.lock" % (cnf["Dir::Lock"])) and not Options["No-Lock"]: if not Options["No-Action"] and os.path.exists("%s/daily.lock" % (cnf["Dir::Lock"])) and not Options["No-Lock"]:
utils.fubar("Archive maintenance in progress. Try again later.") utils.fubar("Archive maintenance in progress. Try again later.")
...@@ -235,6 +213,20 @@ def main(): ...@@ -235,6 +213,20 @@ def main():
Logger = daklog.Logger(cnf, "process-upload", Options["No-Action"]) Logger = daklog.Logger(cnf, "process-upload", Options["No-Action"])
# If we have a directory flag, use it to find our files
if cnf["Dinstall::Options::Directory"] != "":
# Note that we clobber the list of files we were given in this case
# so warn if the user has done both
if len(changes_files) > 0:
utils.warn("Directory provided so ignoring files given on command line")
changes_files = utils.get_changes_files(cnf["Dinstall::Options::Directory"])
Logger.log(["Using changes files from directory", cnf["Dinstall::Options::Directory"], len(changes_files)])
elif not len(changes_files) > 0:
utils.fubar("No changes files given and no directory specified")
else:
Logger.log(["Using changes files from command-line", len(changes_files)])
# Sort the .changes files so that we process sourceful ones first # Sort the .changes files so that we process sourceful ones first
changes_files.sort(utils.changes_compare) changes_files.sort(utils.changes_compare)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册