Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: upload.py

Issue 115926: Use os.path.join() instead of hardcoding / (Closed)
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2007 Google Inc. 3 # Copyright 2007 Google Inc.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 def GetEmail(): 72 def GetEmail():
73 """Prompts the user for their email address and returns it. 73 """Prompts the user for their email address and returns it.
74 74
75 The last used email address is saved to a file and offered up as a suggestion 75 The last used email address is saved to a file and offered up as a suggestion
76 to the user. If the user presses enter without typing in anything the last 76 to the user. If the user presses enter without typing in anything the last
77 used email address is used. If the user enters a new address, it is saved 77 used email address is used. If the user enters a new address, it is saved
78 for next time we prompt. 78 for next time we prompt.
79 79
80 """ 80 """
81 last_email_file_name = os.path.expanduser("~/.last_codereview_email_address") 81 last_email_file_name = os.path.expanduser(
82 os.path.join("~", ".last_codereview_email_address"))
82 last_email = "" 83 last_email = ""
83 prompt = "Email: " 84 prompt = "Email: "
84 if os.path.exists(last_email_file_name): 85 if os.path.exists(last_email_file_name):
85 try: 86 try:
86 last_email_file = open(last_email_file_name, "r") 87 last_email_file = open(last_email_file_name, "r")
87 last_email = last_email_file.readline().strip("\n") 88 last_email = last_email_file.readline().strip("\n")
88 last_email_file.close() 89 last_email_file.close()
89 prompt = "Email [%s]: " % last_email 90 prompt = "Email [%s]: " % last_email
90 except IOError, e: 91 except IOError, e:
91 pass 92 pass
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 A urllib2.OpenerDirector object. 367 A urllib2.OpenerDirector object.
367 """ 368 """
368 opener = urllib2.OpenerDirector() 369 opener = urllib2.OpenerDirector()
369 opener.add_handler(urllib2.ProxyHandler()) 370 opener.add_handler(urllib2.ProxyHandler())
370 opener.add_handler(urllib2.UnknownHandler()) 371 opener.add_handler(urllib2.UnknownHandler())
371 opener.add_handler(urllib2.HTTPHandler()) 372 opener.add_handler(urllib2.HTTPHandler())
372 opener.add_handler(urllib2.HTTPDefaultErrorHandler()) 373 opener.add_handler(urllib2.HTTPDefaultErrorHandler())
373 opener.add_handler(urllib2.HTTPSHandler()) 374 opener.add_handler(urllib2.HTTPSHandler())
374 opener.add_handler(urllib2.HTTPErrorProcessor()) 375 opener.add_handler(urllib2.HTTPErrorProcessor())
375 if self.save_cookies: 376 if self.save_cookies:
376 self.cookie_file = os.path.expanduser("~/.codereview_upload_cookies") 377 self.cookie_file = os.path.expanduser(
378 os.path.join("~", ".codereview_upload_cookies"))
377 self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file) 379 self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file)
378 if os.path.exists(self.cookie_file): 380 if os.path.exists(self.cookie_file):
379 try: 381 try:
380 self.cookie_jar.load() 382 self.cookie_jar.load()
381 self.authenticated = True 383 self.authenticated = True
382 StatusUpdate("Loaded authentication cookies from %s" % 384 StatusUpdate("Loaded authentication cookies from %s" %
383 self.cookie_file) 385 self.cookie_file)
384 except (cookielib.LoadError, IOError): 386 except (cookielib.LoadError, IOError):
385 # Failed to load cookies - just ignore them. 387 # Failed to load cookies - just ignore them.
386 pass 388 pass
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 try: 1380 try:
1379 RealMain(sys.argv) 1381 RealMain(sys.argv)
1380 except KeyboardInterrupt: 1382 except KeyboardInterrupt:
1381 print 1383 print
1382 StatusUpdate("Interrupted.") 1384 StatusUpdate("Interrupted.")
1383 sys.exit(1) 1385 sys.exit(1)
1384 1386
1385 1387
1386 if __name__ == "__main__": 1388 if __name__ == "__main__":
1387 main() 1389 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698