From f795b83c8e1af77208c0d610ddf578c271668b5c Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 24 May 2012 15:15:38 +0200 Subject: [PATCH] prevent a hen/egg problem when handling unsupported python versions Signed-off-by: Steven Armstrong --- bin/cdist | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/cdist b/bin/cdist index c6467477..8d0dfc76 100755 --- a/bin/cdist +++ b/bin/cdist @@ -194,6 +194,13 @@ if __name__ == "__main__": # Sys is needed for sys.exit() import sys + cdistpythonversion = '3.2' + if sys.version < cdistpythonversion: + print('Cdist requires Python >= ' + cdistpythonversion + + ' on the source host.', file=sys.stderr) + sys.exit(1) + + exit_code = 0 try: @@ -201,11 +208,6 @@ if __name__ == "__main__": import os import re - cdistpythonversion = '3.2' - if sys.version < cdistpythonversion: - raise cdist.Error('Cdist requires Python >= ' + cdistpythonversion + - ' on the source host.') - # Ensure our /lib/ is included into PYTHON_PATH sys.path.insert(0, os.path.abspath( os.path.join(os.path.dirname(os.path.realpath(__file__)), '../lib')))