| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
| 3 # Copyright (c) 2012 Miguel Olivares http://moliware.com/ | 3 # Copyright (c) 2012 Miguel Olivares http://moliware.com/ |
| 4 # | 4 # |
| 5 # Permission is hereby granted, free of charge, to any person obtaining a | 5 # Permission is hereby granted, free of charge, to any person obtaining a |
| 6 # copy of this software and associated documentation files (the | 6 # copy of this software and associated documentation files (the |
| 7 # "Software"), to deal in the Software without restriction, including | 7 # "Software"), to deal in the Software without restriction, including |
| 8 # without limitation the rights to use, copy, modify, merge, publish, dis- | 8 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 9 # tribute, sublicense, and/or sell copies of the Software, and to permit | 9 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 10 # persons to whom the Software is furnished to do so, subject to the fol- | 10 # persons to whom the Software is furnished to do so, subject to the fol- |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 Examples : | 78 Examples : |
| 79 glacier upload pics *.jpg | 79 glacier upload pics *.jpg |
| 80 glacier upload pics a.jpg b.jpg | 80 glacier upload pics a.jpg b.jpg |
| 81 """ | 81 """ |
| 82 sys.exit() | 82 sys.exit() |
| 83 | 83 |
| 84 | 84 |
| 85 def connect(region, debug_level=0, access_key=None, secret_key=None): | 85 def connect(region, debug_level=0, access_key=None, secret_key=None): |
| 86 """ Connect to a specific region """ | 86 """ Connect to a specific region """ |
| 87 return connect_to_region(region, | 87 layer2 = connect_to_region(region, |
| 88 aws_access_key_id=access_key, | 88 aws_access_key_id=access_key, |
| 89 aws_secret_access_key=secret_key, | 89 aws_secret_access_key=secret_key, |
| 90 debug=debug_level) | 90 debug=debug_level) |
| 91 if layer2 is None: |
| 92 print 'Invalid region (%s)' % region |
| 93 sys.exit(1) |
| 94 return layer2 |
| 91 | 95 |
| 92 | 96 |
| 93 def list_vaults(region, access_key=None, secret_key=None): | 97 def list_vaults(region, access_key=None, secret_key=None): |
| 94 layer2 = connect(region, access_key = access_key, secret_key = secret_key) | 98 layer2 = connect(region, access_key = access_key, secret_key = secret_key) |
| 95 for vault in layer2.list_vaults(): | 99 for vault in layer2.list_vaults(): |
| 96 print vault.arn | 100 print vault.arn |
| 97 | 101 |
| 98 | 102 |
| 99 def list_jobs(vault_name, region, access_key=None, secret_key=None): | 103 def list_jobs(vault_name, region, access_key=None, secret_key=None): |
| 100 layer2 = connect(region, access_key = access_key, secret_key = secret_key) | 104 layer2 = connect(region, access_key = access_key, secret_key = secret_key) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 usage() | 149 usage() |
| 146 list_jobs(args[0], region, access_key, secret_key) | 150 list_jobs(args[0], region, access_key, secret_key) |
| 147 elif command == 'upload': | 151 elif command == 'upload': |
| 148 if len(args) < 2: | 152 if len(args) < 2: |
| 149 usage() | 153 usage() |
| 150 upload_files(args[0], args[1:], region, access_key, secret_key) | 154 upload_files(args[0], args[1:], region, access_key, secret_key) |
| 151 | 155 |
| 152 | 156 |
| 153 if __name__ == '__main__': | 157 if __name__ == '__main__': |
| 154 main() | 158 main() |
| OLD | NEW |