From bb5dce6df4ac4f4425676a97933031bb9e26cd29 Mon Sep 17 00:00:00 2001 From: Jim Browne Date: Thu, 30 May 2013 17:24:18 -0700 Subject: [PATCH 1/2] Warn and exit if boto version is too old --- bin/boto-rsync | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/boto-rsync b/bin/boto-rsync index 76278b2..633e3f0 100644 --- a/bin/boto-rsync +++ b/bin/boto-rsync @@ -181,7 +181,18 @@ def main(): num_cb = 10 rename = False copy_file = True - + + # Boto < 2.0 missing __version__, hence try/except + # S3 encryption support present in 2.1.0 and later + boto_err = 'Boto version 2.1.0 or later is required\n' + boto_err += 'Try: sudo easy_install boto\n' + try: + if boto.__version__ < '2.1.0': + raise AttributeError + except AttributeError: + sys.stdout.write(boto_err) + sys.exit(1) + parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, usage='%(prog)s [OPTIONS] SOURCE DESTINATION', From 0e8842d6d8765e9a6a2dc1afd9fce7708a94ae83 Mon Sep 17 00:00:00 2001 From: Jim Browne Date: Fri, 1 Nov 2013 16:50:01 -0700 Subject: [PATCH 2/2] Fix naive version comparison code (e.g. 2.15 > 2.8) --- bin/boto-rsync | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/boto-rsync b/bin/boto-rsync index 633e3f0..7ed8e80 100644 --- a/bin/boto-rsync +++ b/bin/boto-rsync @@ -184,12 +184,16 @@ def main(): # Boto < 2.0 missing __version__, hence try/except # S3 encryption support present in 2.1.0 and later - boto_err = 'Boto version 2.1.0 or later is required\n' + desired_boto = '2.1.0' + boto_err = 'Boto version %s or later is required\n' % desired_boto boto_err += 'Try: sudo easy_install boto\n' + try: - if boto.__version__ < '2.1.0': - raise AttributeError - except AttributeError: + from pkg_resources import parse_version + if parse_version(boto.__version__) < parse_version(desired_boto): + sys.stdout.write(boto_err) + sys.exit(1) + except (AttributeError, NameError): sys.stdout.write(boto_err) sys.exit(1)