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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 try: | 518 try: |
519 self.cookie_jar.load() | 519 self.cookie_jar.load() |
520 self.authenticated = True | 520 self.authenticated = True |
521 StatusUpdate("Loaded authentication cookies from %s" % | 521 StatusUpdate("Loaded authentication cookies from %s" % |
522 self.cookie_file) | 522 self.cookie_file) |
523 except (cookielib.LoadError, IOError): | 523 except (cookielib.LoadError, IOError): |
524 # Failed to load cookies - just ignore them. | 524 # Failed to load cookies - just ignore them. |
525 pass | 525 pass |
526 else: | 526 else: |
527 # Create an empty cookie file with mode 600 | 527 # Create an empty cookie file with mode 600 |
528 fd = os.open(self.cookie_file, os.O_CREAT, 0600) | 528 fd = os.open(self.cookie_file, os.O_CREAT, 0o0600) |
529 os.close(fd) | 529 os.close(fd) |
530 # Always chmod the cookie file | 530 # Always chmod the cookie file |
531 os.chmod(self.cookie_file, 0600) | 531 os.chmod(self.cookie_file, 0o0600) |
532 else: | 532 else: |
533 # Don't save cookies across runs of update.py. | 533 # Don't save cookies across runs of update.py. |
534 self.cookie_jar = cookielib.CookieJar() | 534 self.cookie_jar = cookielib.CookieJar() |
535 opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar)) | 535 opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar)) |
536 return opener | 536 return opener |
537 | 537 |
538 | 538 |
539 class CondensedHelpFormatter(optparse.IndentedHelpFormatter): | 539 class CondensedHelpFormatter(optparse.IndentedHelpFormatter): |
540 """Frees more horizontal space by removing indentation from group | 540 """Frees more horizontal space by removing indentation from group |
541 options and collapsing arguments between short and long, e.g. | 541 options and collapsing arguments between short and long, e.g. |
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2543 print | 2543 print |
2544 StatusUpdate("Interrupted.") | 2544 StatusUpdate("Interrupted.") |
2545 sys.exit(1) | 2545 sys.exit(1) |
2546 except auth.AuthenticationError as e: | 2546 except auth.AuthenticationError as e: |
2547 print >> sys.stderr, e | 2547 print >> sys.stderr, e |
2548 sys.exit(1) | 2548 sys.exit(1) |
2549 | 2549 |
2550 | 2550 |
2551 if __name__ == "__main__": | 2551 if __name__ == "__main__": |
2552 main() | 2552 main() |
OLD | NEW |