From 356c5d182742327a2c728e4836ab37b19b6b71fc Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 17 Dec 2013 21:38:57 +0100 Subject: [PATCH 1/2] Better error reporting when config file is not found --- AUTHORS.txt | 3 ++- depl/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 8a51e5b..c528bad 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -6,5 +6,6 @@ David Halter (@davidhalter) Code Contributors ================= - Note: (@user) means a github user name. + +Danilo Bargen (@dbrgn) diff --git a/depl/__init__.py b/depl/__init__.py index 6a00017..a3eaac9 100644 --- a/depl/__init__.py +++ b/depl/__init__.py @@ -30,10 +30,10 @@ def main(): try: c = config.Config(args['--config'], args[''], args['--pool']) except IOError: - sys.stderr.write("Couldn't find config file.") + sys.stderr.write("Couldn't find depl config file ({0}).\n".format(args['--config'])) sys.exit(1) except config.ValidationError as e: - sys.stderr.write("Config file is invalid: " + e.message) + sys.stderr.write("Config file is invalid: {0}\n".format(e.message)) sys.exit(2) for pool in c.pools: From 10ecb463f593243e63e059709b4d4dec45b31459 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 17 Dec 2013 22:12:07 +0100 Subject: [PATCH 2/2] Use awk through find When the `sources.list.d` directory is empty, the glob expansion fails. Using `find` solves this problem. --- depl/deploy/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depl/deploy/__init__.py b/depl/deploy/__init__.py index 30e8abc..a25ffcb 100644 --- a/depl/deploy/__init__.py +++ b/depl/deploy/__init__.py @@ -26,8 +26,8 @@ def install_packages(): with hide('stdout'): # Need a new line after sources.list, which sometimes doesn't end # with one, easiest option: awk. - apt_txt = run('awk \'FNR==1{print ""}1\' ' - '/etc/apt/sources.list /etc/apt/sources.list.d/*') + apt_txt = run('find /etc/apt/sources.list{,.d} -type f ' + '-exec awk \'FNR==1{print ""}1\' {} \;') force_update = False for package in packages: