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

Unified Diff: remoting/tools/gettoken.py

Issue 8665013: Fix many* python scripts in src/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed chrome_frame/tools/test/page_cycler/cf_cycler.py Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « printing/cups_config_helper.py ('k') | remoting/tools/register_host.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/tools/gettoken.py
diff --git a/remoting/tools/gettoken.py b/remoting/tools/gettoken.py
index a36408bd009b8ccc5cabf6a0fe2a18e024213769..4f867bfcc476ed73ca4e5e9e359d1af0bab57a46 100755
--- a/remoting/tools/gettoken.py
+++ b/remoting/tools/gettoken.py
@@ -1,11 +1,12 @@
#!/usr/bin/env python
-#
-# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# gettoken.py can be used to get auth token from Gaia. It asks username and
-# password and then prints token on the screen.
+
+"""Get auth token from Gaia.
+
+It asks username and password and then prints token on the screen.
+"""
import getpass
import os
@@ -13,46 +14,53 @@ import urllib
import gaia_auth
-chromoting_auth_filepath = os.path.join(os.path.expanduser('~'),
- '.chromotingAuthToken')
-chromoting_dir_auth_filepath = os.path.join(os.path.expanduser('~'),
- '.chromotingDirectoryAuthToken')
-
-print "Email:",
-email = raw_input()
-
-passwd = getpass.getpass("Password: ")
-
-chromoting_authenticator = gaia_auth.GaiaAuthenticator('chromiumsync');
-chromoting_auth_token = chromoting_authenticator.authenticate(email, passwd)
-
-chromoting_dir_authenticator = gaia_auth.GaiaAuthenticator('chromoting');
-chromoting_dir_auth_token = \
- chromoting_dir_authenticator.authenticate(email, passwd)
-
-# Set permission mask for created files.
-os.umask(0066)
-
-chromoting_auth_file = open(chromoting_auth_filepath, 'w')
-chromoting_auth_file.write(email)
-chromoting_auth_file.write('\n')
-chromoting_auth_file.write(chromoting_auth_token)
-chromoting_auth_file.close()
-
-print
-print 'Chromoting (sync) Auth Token:'
-print
-print chromoting_auth_token
-print '...saved in', chromoting_auth_filepath
-
-chromoting_dir_auth_file = open(chromoting_dir_auth_filepath, 'w')
-chromoting_dir_auth_file.write(email)
-chromoting_dir_auth_file.write('\n')
-chromoting_dir_auth_file.write(chromoting_dir_auth_token)
-chromoting_dir_auth_file.close()
-
-print
-print 'Chromoting Directory Auth Token:'
-print
-print chromoting_dir_auth_token
-print '...saved in', chromoting_dir_auth_filepath
+
+def main():
+ basepath = os.path.expanduser('~')
+ chromoting_auth_filepath = os.path.join(basepath, '.chromotingAuthToken')
+ chromoting_dir_auth_filepath = os.path.join(
+ basepath, '.chromotingDirectoryAuthToken')
+
+ print "Email:",
+ email = raw_input()
+
+ passwd = getpass.getpass("Password: ")
+
+ chromoting_authenticator = gaia_auth.GaiaAuthenticator('chromiumsync');
+ chromoting_auth_token = chromoting_authenticator.authenticate(email, passwd)
+
+ chromoting_dir_authenticator = gaia_auth.GaiaAuthenticator('chromoting');
+ chromoting_dir_auth_token = chromoting_dir_authenticator.authenticate(
+ email, passwd)
+
+ # Set permission mask for created files.
+ os.umask(0066)
+
+ chromoting_auth_file = open(chromoting_auth_filepath, 'w')
+ chromoting_auth_file.write(email)
+ chromoting_auth_file.write('\n')
+ chromoting_auth_file.write(chromoting_auth_token)
+ chromoting_auth_file.close()
+
+ print
+ print 'Chromoting (sync) Auth Token:'
+ print
+ print chromoting_auth_token
+ print '...saved in', chromoting_auth_filepath
+
+ chromoting_dir_auth_file = open(chromoting_dir_auth_filepath, 'w')
+ chromoting_dir_auth_file.write(email)
+ chromoting_dir_auth_file.write('\n')
+ chromoting_dir_auth_file.write(chromoting_dir_auth_token)
+ chromoting_dir_auth_file.close()
+
+ print
+ print 'Chromoting Directory Auth Token:'
+ print
+ print chromoting_dir_auth_token
+ print '...saved in', chromoting_dir_auth_filepath
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « printing/cups_config_helper.py ('k') | remoting/tools/register_host.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698