| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ | 2 # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ |
| 3 # | 3 # |
| 4 # Permission is hereby granted, free of charge, to any person obtaining a | 4 # Permission is hereby granted, free of charge, to any person obtaining a |
| 5 # copy of this software and associated documentation files (the | 5 # copy of this software and associated documentation files (the |
| 6 # "Software"), to deal in the Software without restriction, including | 6 # "Software"), to deal in the Software without restriction, including |
| 7 # without limitation the rights to use, copy, modify, merge, publish, dis- | 7 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 8 # tribute, sublicense, and/or sell copies of the Software, and to permit | 8 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 9 # persons to whom the Software is furnished to do so, subject to the fol- | 9 # persons to whom the Software is furnished to do so, subject to the fol- |
| 10 # lowing conditions: | 10 # lowing conditions: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if o in ('-o', '--output'): | 50 if o in ('-o', '--output'): |
| 51 output_file = a | 51 output_file = a |
| 52 if o in ('-c', '--clear'): | 52 if o in ('-c', '--clear'): |
| 53 clear = True | 53 clear = True |
| 54 if o in ('-t', '--timeout'): | 54 if o in ('-t', '--timeout'): |
| 55 timeout = int(a) | 55 timeout = int(a) |
| 56 if o in ('-r', '--region'): | 56 if o in ('-r', '--region'): |
| 57 region = a | 57 region = a |
| 58 if region: | 58 if region: |
| 59 c = boto.sqs.connect_to_region(region) | 59 c = boto.sqs.connect_to_region(region) |
| 60 if c is None: |
| 61 print 'Invalid region (%s)' % region |
| 62 sys.exit(1) |
| 60 else: | 63 else: |
| 61 c = SQSConnection() | 64 c = SQSConnection() |
| 62 if queue_name: | 65 if queue_name: |
| 63 try: | 66 try: |
| 64 rs = [c.create_queue(queue_name)] | 67 rs = [c.create_queue(queue_name)] |
| 65 except SQSError, e: | 68 except SQSError, e: |
| 66 print 'An Error Occurred:' | 69 print 'An Error Occurred:' |
| 67 print '%s: %s' % (e.status, e.reason) | 70 print '%s: %s' % (e.status, e.reason) |
| 68 print e.body | 71 print e.body |
| 69 sys.exit() | 72 sys.exit() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 80 n = q.clear() | 83 n = q.clear() |
| 81 print 'clearing %d messages from %s' % (n, q.id) | 84 print 'clearing %d messages from %s' % (n, q.id) |
| 82 elif output_file: | 85 elif output_file: |
| 83 q.dump(output_file) | 86 q.dump(output_file) |
| 84 else: | 87 else: |
| 85 print q.id, q.count(vtimeout=timeout) | 88 print q.id, q.count(vtimeout=timeout) |
| 86 | 89 |
| 87 if __name__ == "__main__": | 90 if __name__ == "__main__": |
| 88 main() | 91 main() |
| 89 | 92 |
| OLD | NEW |