OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Manages cached OAuth2 tokens used by other depot_tools scripts. | 6 """Manages cached OAuth2 tokens used by other depot_tools scripts. |
7 | 7 |
8 Usage: | 8 Usage: |
9 depot-tools-auth login codereview.chromium.org | 9 depot-tools-auth login codereview.chromium.org |
10 depot-tools-auth info codereview.chromium.org | 10 depot-tools-auth info codereview.chromium.org |
11 depot-tools-auth logout codereview.chromium.org | 11 depot-tools-auth logout codereview.chromium.org |
12 """ | 12 """ |
13 | 13 |
14 import logging | 14 import logging |
15 import optparse | 15 import optparse |
16 import sys | 16 import sys |
| 17 import os |
17 | 18 |
18 from third_party import colorama | 19 from third_party import colorama |
19 | 20 |
20 import auth | 21 import auth |
21 import subcommand | 22 import subcommand |
22 | 23 |
23 __version__ = '1.0' | 24 __version__ = '1.0' |
24 | 25 |
25 | 26 |
26 @subcommand.usage('<hostname>') | 27 @subcommand.usage('<hostname>') |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 def main(argv): | 88 def main(argv): |
88 dispatcher = subcommand.CommandDispatcher(__name__) | 89 dispatcher = subcommand.CommandDispatcher(__name__) |
89 try: | 90 try: |
90 return dispatcher.execute(OptionParser(), argv) | 91 return dispatcher.execute(OptionParser(), argv) |
91 except auth.AuthenticationError as e: | 92 except auth.AuthenticationError as e: |
92 print >> sys.stderr, e | 93 print >> sys.stderr, e |
93 return 1 | 94 return 1 |
94 | 95 |
95 | 96 |
96 if __name__ == '__main__': | 97 if __name__ == '__main__': |
97 colorama.init() | 98 colorama.init(wrap="TERM" not in os.environ) |
98 try: | 99 try: |
99 sys.exit(main(sys.argv[1:])) | 100 sys.exit(main(sys.argv[1:])) |
100 except KeyboardInterrupt: | 101 except KeyboardInterrupt: |
101 sys.stderr.write('interrupted\n') | 102 sys.stderr.write('interrupted\n') |
102 sys.exit(1) | 103 sys.exit(1) |
OLD | NEW |