|
|
|
@ -34,6 +34,8 @@ against by using the '--rev' option.
|
|
|
|
|
# This code is derived from appcfg.py in the App Engine SDK (open source),
|
|
|
|
|
# and from ASPN recipe #146306.
|
|
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
|
|
import ConfigParser
|
|
|
|
|
import cookielib
|
|
|
|
|
import errno
|
|
|
|
@ -168,12 +170,12 @@ def StatusUpdate(msg):
|
|
|
|
|
msg: The string to print.
|
|
|
|
|
"""
|
|
|
|
|
if verbosity > 0:
|
|
|
|
|
print msg
|
|
|
|
|
print(msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ErrorExit(msg):
|
|
|
|
|
"""Print an error message to stderr and exit."""
|
|
|
|
|
print >> sys.stderr, msg
|
|
|
|
|
print(msg, file=sys.stderr)
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -358,7 +360,7 @@ class AbstractRpcServer(object):
|
|
|
|
|
except ClientLoginError, exc:
|
|
|
|
|
e = exc
|
|
|
|
|
if e:
|
|
|
|
|
print >> sys.stderr, ''
|
|
|
|
|
print('', file=sys.stderr)
|
|
|
|
|
error_message = e.reason
|
|
|
|
|
if error_map:
|
|
|
|
|
error_message = error_map.get(error_message, error_message)
|
|
|
|
@ -370,7 +372,7 @@ class AbstractRpcServer(object):
|
|
|
|
|
"See http://www.google.com/"
|
|
|
|
|
"support/accounts/bin/answer.py?answer=185833")
|
|
|
|
|
else:
|
|
|
|
|
print >> sys.stderr, "Invalid username or password."
|
|
|
|
|
print("Invalid username or password.", file=sys.stderr)
|
|
|
|
|
elif error_message == "CaptchaRequired":
|
|
|
|
|
print >> sys.stderr, (
|
|
|
|
|
"Please go to\n"
|
|
|
|
@ -379,23 +381,24 @@ class AbstractRpcServer(object):
|
|
|
|
|
"If you are using a Google Apps account the URL is:\n"
|
|
|
|
|
"https://www.google.com/a/yourdomain.com/UnlockCaptcha")
|
|
|
|
|
elif error_message == "NotVerified":
|
|
|
|
|
print >> sys.stderr, "Account not verified."
|
|
|
|
|
print("Account not verified.", file=sys.stderr)
|
|
|
|
|
elif error_message == "TermsNotAgreed":
|
|
|
|
|
print >> sys.stderr, "User has not agreed to TOS."
|
|
|
|
|
print("User has not agreed to TOS.", file=sys.stderr)
|
|
|
|
|
elif error_message == "AccountDeleted":
|
|
|
|
|
print >> sys.stderr, "The user account has been deleted."
|
|
|
|
|
print("The user account has been deleted.", file=sys.stderr)
|
|
|
|
|
elif error_message == "AccountDisabled":
|
|
|
|
|
print >> sys.stderr, "The user account has been disabled."
|
|
|
|
|
print("The user account has been disabled.", file=sys.stderr)
|
|
|
|
|
break
|
|
|
|
|
elif error_message == "ServiceDisabled":
|
|
|
|
|
print >> sys.stderr, ("The user's access to the service has been "
|
|
|
|
|
"disabled.")
|
|
|
|
|
print("The user's access to the service has been disabled.",
|
|
|
|
|
file=sys.stderr)
|
|
|
|
|
elif error_message == "ServiceUnavailable":
|
|
|
|
|
print >> sys.stderr, "The service is not available; try again later."
|
|
|
|
|
print("The service is not available; try again later.",
|
|
|
|
|
file=sys.stderr)
|
|
|
|
|
else:
|
|
|
|
|
# Unknown error.
|
|
|
|
|
raise e
|
|
|
|
|
print >> sys.stderr, ''
|
|
|
|
|
print('', file=sys.stderr)
|
|
|
|
|
continue
|
|
|
|
|
self._GetAuthCookie(auth_token)
|
|
|
|
|
return
|
|
|
|
@ -720,10 +723,10 @@ class KeyringCreds(object):
|
|
|
|
|
except:
|
|
|
|
|
# Sadly, we have to trap all errors here as
|
|
|
|
|
# gnomekeyring.IOError inherits from object. :/
|
|
|
|
|
print "Failed to get password from keyring"
|
|
|
|
|
print("Failed to get password from keyring")
|
|
|
|
|
keyring = None
|
|
|
|
|
if password is not None:
|
|
|
|
|
print "Using password from system keyring."
|
|
|
|
|
print("Using password from system keyring.")
|
|
|
|
|
self.accounts_seen.add(email)
|
|
|
|
|
else:
|
|
|
|
|
password = getpass.getpass("Password for %s: " % email)
|
|
|
|
@ -920,9 +923,9 @@ class VersionControlSystem(object):
|
|
|
|
|
"""Show an "are you sure?" prompt if there are unknown files."""
|
|
|
|
|
unknown_files = self.GetUnknownFiles()
|
|
|
|
|
if unknown_files:
|
|
|
|
|
print "The following files are not added to version control:"
|
|
|
|
|
print("The following files are not added to version control:")
|
|
|
|
|
for line in unknown_files:
|
|
|
|
|
print line
|
|
|
|
|
print(line)
|
|
|
|
|
prompt = "Are you sure to continue?(y/N) "
|
|
|
|
|
answer = raw_input(prompt).strip()
|
|
|
|
|
if answer != "y":
|
|
|
|
@ -1029,7 +1032,7 @@ class VersionControlSystem(object):
|
|
|
|
|
threads.append(t)
|
|
|
|
|
|
|
|
|
|
for t in threads:
|
|
|
|
|
print t.get(timeout=60)
|
|
|
|
|
print(t.get(timeout=60))
|
|
|
|
|
|
|
|
|
|
def IsImage(self, filename):
|
|
|
|
|
"""Returns true if the filename has an image extension."""
|
|
|
|
@ -1703,7 +1706,7 @@ class PerforceVCS(VersionControlSystem):
|
|
|
|
|
ErrorExit("Error checking perforce login")
|
|
|
|
|
if not retcode and (not "code" in data or data["code"] != "error"):
|
|
|
|
|
break
|
|
|
|
|
print "Enter perforce password: "
|
|
|
|
|
print("Enter perforce password: ")
|
|
|
|
|
self.RunPerforceCommandWithReturnCode(["login"])
|
|
|
|
|
|
|
|
|
|
super(PerforceVCS, self).__init__(options)
|
|
|
|
@ -2083,8 +2086,8 @@ def UploadSeparatePatches(issue, rpc_server, patchset, data, options):
|
|
|
|
|
rv = []
|
|
|
|
|
for patch in patches:
|
|
|
|
|
if len(patch[1]) > MAX_UPLOAD_SIZE:
|
|
|
|
|
print ("Not uploading the patch for " + patch[0] +
|
|
|
|
|
" because the file is too large.")
|
|
|
|
|
print("Not uploading the patch for %s because the file is too large." %
|
|
|
|
|
(patch[0],))
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
filename = patch[0]
|
|
|
|
@ -2095,7 +2098,7 @@ def UploadSeparatePatches(issue, rpc_server, patchset, data, options):
|
|
|
|
|
|
|
|
|
|
for t in threads:
|
|
|
|
|
result = t.get(timeout=60)
|
|
|
|
|
print result[0]
|
|
|
|
|
print(result[0])
|
|
|
|
|
rv.append(result[1])
|
|
|
|
|
|
|
|
|
|
return rv
|
|
|
|
@ -2372,8 +2375,8 @@ def RealMain(argv, data=None):
|
|
|
|
|
guessed_base = vcs.GuessBase(options.download_base)
|
|
|
|
|
if base:
|
|
|
|
|
if guessed_base and base != guessed_base:
|
|
|
|
|
print "Using base URL \"%s\" from --base_url instead of \"%s\"" % \
|
|
|
|
|
(base, guessed_base)
|
|
|
|
|
print("Using base URL \"%s\" from --base_url instead of \"%s\"" %
|
|
|
|
|
(base, guessed_base))
|
|
|
|
|
else:
|
|
|
|
|
base = guessed_base
|
|
|
|
|
|
|
|
|
@ -2386,12 +2389,12 @@ def RealMain(argv, data=None):
|
|
|
|
|
data = vcs.GenerateDiff(args)
|
|
|
|
|
data = vcs.PostProcessDiff(data)
|
|
|
|
|
if options.print_diffs:
|
|
|
|
|
print "Rietveld diff start:*****"
|
|
|
|
|
print data
|
|
|
|
|
print "Rietveld diff end:*****"
|
|
|
|
|
print("Rietveld diff start:*****")
|
|
|
|
|
print(data)
|
|
|
|
|
print("Rietveld diff end:*****")
|
|
|
|
|
files = vcs.GetBaseFiles(data)
|
|
|
|
|
if verbosity >= 1:
|
|
|
|
|
print "Upload server:", options.server, "(change with -s/--server)"
|
|
|
|
|
print("Upload server:", options.server, "(change with -s/--server)")
|
|
|
|
|
|
|
|
|
|
auth_config = auth.extract_auth_config_from_options(options)
|
|
|
|
|
rpc_server = GetRpcServer(options.server, auth_config, options.email)
|
|
|
|
@ -2477,7 +2480,7 @@ def RealMain(argv, data=None):
|
|
|
|
|
form_fields.append(("base_hashes", base_hashes))
|
|
|
|
|
if options.private:
|
|
|
|
|
if options.issue:
|
|
|
|
|
print "Warning: Private flag ignored when updating an existing issue."
|
|
|
|
|
print("Warning: Private flag ignored when updating an existing issue.")
|
|
|
|
|
else:
|
|
|
|
|
form_fields.append(("private", "1"))
|
|
|
|
|
if options.send_patch:
|
|
|
|
@ -2485,7 +2488,7 @@ def RealMain(argv, data=None):
|
|
|
|
|
if not options.download_base:
|
|
|
|
|
form_fields.append(("content_upload", "1"))
|
|
|
|
|
if len(data) > MAX_UPLOAD_SIZE:
|
|
|
|
|
print "Patch is large, so uploading file patches separately."
|
|
|
|
|
print("Patch is large, so uploading file patches separately.")
|
|
|
|
|
uploaded_diff_file = []
|
|
|
|
|
form_fields.append(("separate_patches", "1"))
|
|
|
|
|
else:
|
|
|
|
@ -2544,7 +2547,7 @@ def main():
|
|
|
|
|
StatusUpdate("Interrupted.")
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
except auth.AuthenticationError as e:
|
|
|
|
|
print >> sys.stderr, e
|
|
|
|
|
print(e, file=sys.stderr)
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|