OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 # | 3 # |
4 # Copyright 2007 Google Inc. | 4 # Copyright 2007 Google Inc. |
5 # | 5 # |
6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
9 # | 9 # |
10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 try: | 521 try: |
522 self.cookie_jar.load() | 522 self.cookie_jar.load() |
523 self.authenticated = True | 523 self.authenticated = True |
524 StatusUpdate("Loaded authentication cookies from %s" % | 524 StatusUpdate("Loaded authentication cookies from %s" % |
525 self.cookie_file) | 525 self.cookie_file) |
526 except (cookielib.LoadError, IOError): | 526 except (cookielib.LoadError, IOError): |
527 # Failed to load cookies - just ignore them. | 527 # Failed to load cookies - just ignore them. |
528 pass | 528 pass |
529 else: | 529 else: |
530 # Create an empty cookie file with mode 600 | 530 # Create an empty cookie file with mode 600 |
531 fd = os.open(self.cookie_file, os.O_CREAT, 0o0600) | 531 fd = os.open(self.cookie_file, os.O_CREAT, 0o600) |
532 os.close(fd) | 532 os.close(fd) |
533 # Always chmod the cookie file | 533 # Always chmod the cookie file |
534 os.chmod(self.cookie_file, 0o0600) | 534 os.chmod(self.cookie_file, 0o600) |
535 else: | 535 else: |
536 # Don't save cookies across runs of update.py. | 536 # Don't save cookies across runs of update.py. |
537 self.cookie_jar = cookielib.CookieJar() | 537 self.cookie_jar = cookielib.CookieJar() |
538 opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar)) | 538 opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar)) |
539 return opener | 539 return opener |
540 | 540 |
541 | 541 |
542 class CondensedHelpFormatter(optparse.IndentedHelpFormatter): | 542 class CondensedHelpFormatter(optparse.IndentedHelpFormatter): |
543 """Frees more horizontal space by removing indentation from group | 543 """Frees more horizontal space by removing indentation from group |
544 options and collapsing arguments between short and long, e.g. | 544 options and collapsing arguments between short and long, e.g. |
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2546 print | 2546 print |
2547 StatusUpdate("Interrupted.") | 2547 StatusUpdate("Interrupted.") |
2548 sys.exit(1) | 2548 sys.exit(1) |
2549 except auth.AuthenticationError as e: | 2549 except auth.AuthenticationError as e: |
2550 print(e, file=sys.stderr) | 2550 print(e, file=sys.stderr) |
2551 sys.exit(1) | 2551 sys.exit(1) |
2552 | 2552 |
2553 | 2553 |
2554 if __name__ == "__main__": | 2554 if __name__ == "__main__": |
2555 main() | 2555 main() |
OLD | NEW |