From 7f666168b375073c6d751ad47369410de713c9aa Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Sat, 21 Feb 2009 21:00:38 +0000 Subject: [PATCH] move logic into a function Signed-off-by: Mark Hymers --- dak/process_accepted.py | 8 +------- dak/process_unchecked.py | 8 +------- daklib/utils.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dak/process_accepted.py b/dak/process_accepted.py index 07d611d5..e53a969f 100755 --- a/dak/process_accepted.py +++ b/dak/process_accepted.py @@ -183,13 +183,7 @@ def init(): if len(changes_files) > 0: utils.warn("Directory provided so ignoring files given on command line") - dir = Cnf["Dinstall::Options::Directory"] - try: - # Much of the rest of p-a depends on being in the right place - os.chdir(dir) - changes_files = [x for x in os.listdir(dir) if x.endswith('.changes')] - except OSError, e: - utils.fubar("Failed to read list from directory %s (%s)" % (dir, e)) + changes_files = utils.get_changes_files(Cnf["Dinstall::Options::Directory"]) Upload = queue.Upload(Cnf) projectB = Upload.projectB diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index e0457260..c2adb639 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -98,13 +98,7 @@ def init(): if len(changes_files) > 0: utils.warn("Directory provided so ignoring files given on command line") - dir = Cnf["Dinstall::Options::Directory"] - try: - # Much of the rest of p-u depends on being in the right place - os.chdir(dir) - changes_files = [x for x in os.listdir(dir) if x.endswith('.changes')] - except OSError, e: - utils.fubar("Failed to read list from directory %s (%s)" % (dir, e)) + changes_files = utils.get_changes_files(Cnf["Dinstall::Options::Directory"]) Upload = queue.Upload(Cnf) diff --git a/daklib/utils.py b/daklib/utils.py index e0bdfe84..963abd5d 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -1498,6 +1498,18 @@ def is_email_alias(email): ################################################################################ +def get_changes_files(dir): + try: + # Much of the rest of p-u/p-a depends on being in the right place + os.chdir(dir) + changes_files = [x for x in os.listdir(dir) if x.endswith('.changes')] + except OSError, e: + fubar("Failed to read list from directory %s (%s)" % (dir, e)) + + return changes_files + +################################################################################ + apt_pkg.init() Cnf = apt_pkg.newConfiguration() -- 2.39.2