proxygen
upload.AbstractRpcServer Class Reference
Inheritance diagram for upload.AbstractRpcServer:
upload.HttpRpcServer upload.HttpRpcServer upload.HttpRpcServer upload.HttpRpcServer upload.HttpRpcServer upload.HttpRpcServer

Public Member Functions

def __init__ (self, host, auth_function, host_override=None, extra_headers={}, save_cookies=False)
 
def Send (self, request_path, payload=None, content_type="application/octet-stream", timeout=None, kwargs)
 
def __init__ (self, host, auth_function, host_override=None, extra_headers={}, save_cookies=False)
 
def Send (self, request_path, payload=None, content_type="application/octet-stream", timeout=None, kwargs)
 
def __init__ (self, host, auth_function, host_override=None, extra_headers={}, save_cookies=False)
 
def Send (self, request_path, payload=None, content_type="application/octet-stream", timeout=None, kwargs)
 
def __init__ (self, host, auth_function, host_override=None, extra_headers={}, save_cookies=False)
 
def Send (self, request_path, payload=None, content_type="application/octet-stream", timeout=None, kwargs)
 
def __init__ (self, host, auth_function, host_override=None, extra_headers={}, save_cookies=False)
 
def Send (self, request_path, payload=None, content_type="application/octet-stream", timeout=None, kwargs)
 
def __init__ (self, host, auth_function, host_override=None, extra_headers={}, save_cookies=False)
 
def Send (self, request_path, payload=None, content_type="application/octet-stream", timeout=None, kwargs)
 

Public Attributes

 host
 
 host_override
 
 auth_function
 
 authenticated
 
 extra_headers
 
 save_cookies
 
 opener
 

Private Member Functions

def _GetOpener (self)
 
def _CreateRequest (self, url, data=None)
 
def _GetAuthToken (self, email, password)
 
def _GetAuthCookie (self, auth_token)
 
def _Authenticate (self)
 
def _GetOpener (self)
 
def _CreateRequest (self, url, data=None)
 
def _GetAuthToken (self, email, password)
 
def _GetAuthCookie (self, auth_token)
 
def _Authenticate (self)
 
def _GetOpener (self)
 
def _CreateRequest (self, url, data=None)
 
def _GetAuthToken (self, email, password)
 
def _GetAuthCookie (self, auth_token)
 
def _Authenticate (self)
 
def _GetOpener (self)
 
def _CreateRequest (self, url, data=None)
 
def _GetAuthToken (self, email, password)
 
def _GetAuthCookie (self, auth_token)
 
def _Authenticate (self)
 
def _GetOpener (self)
 
def _CreateRequest (self, url, data=None)
 
def _GetAuthToken (self, email, password)
 
def _GetAuthCookie (self, auth_token)
 
def _Authenticate (self)
 
def _GetOpener (self)
 
def _CreateRequest (self, url, data=None)
 
def _GetAuthToken (self, email, password)
 
def _GetAuthCookie (self, auth_token)
 
def _Authenticate (self)
 

Detailed Description

Provides a common interface for a simple RPC server.

Definition at line 124 of file upload.py.

Constructor & Destructor Documentation

def upload.AbstractRpcServer.__init__ (   self,
  host,
  auth_function,
  host_override = None,
  extra_headers = {},
  save_cookies = False 
)
Creates a new HttpRpcServer.

Args:
  host: The host to send requests to.
  auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. Will be called if authentication
is required.
  host_override: The host header to send to the server (defaults to host).
  extra_headers: A dict of extra headers to append to every request.
  save_cookies: If True, save the authentication cookies to local disk.
If False, use an in-memory cookiejar instead.  Subclasses must
implement this functionality.  Defaults to False.

Definition at line 128 of file upload.py.

128  save_cookies=False):
129  """Creates a new HttpRpcServer.
130 
131  Args:
132  host: The host to send requests to.
133  auth_function: A function that takes no arguments and returns an
134  (email, password) tuple when called. Will be called if authentication
135  is required.
136  host_override: The host header to send to the server (defaults to host).
137  extra_headers: A dict of extra headers to append to every request.
138  save_cookies: If True, save the authentication cookies to local disk.
139  If False, use an in-memory cookiejar instead. Subclasses must
140  implement this functionality. Defaults to False.
141  """
142  self.host = host
143  self.host_override = host_override
144  self.auth_function = auth_function
145  self.authenticated = False
146  self.extra_headers = extra_headers
147  self.save_cookies = save_cookies
148  self.opener = self._GetOpener()
149  if self.host_override:
150  logging.info("Server: %s; Host: %s", self.host, self.host_override)
151  else:
152  logging.info("Server: %s", self.host)
153 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer.__init__ (   self,
  host,
  auth_function,
  host_override = None,
  extra_headers = {},
  save_cookies = False 
)
Creates a new HttpRpcServer.

Args:
  host: The host to send requests to.
  auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. Will be called if authentication
is required.
  host_override: The host header to send to the server (defaults to host).
  extra_headers: A dict of extra headers to append to every request.
  save_cookies: If True, save the authentication cookies to local disk.
If False, use an in-memory cookiejar instead.  Subclasses must
implement this functionality.  Defaults to False.

Definition at line 128 of file upload.py.

References upload.AbstractRpcServer._GetOpener(), upload.AbstractRpcServer.auth_function, upload.AbstractRpcServer.authenticated, upload.AbstractRpcServer.extra_headers, upload.AbstractRpcServer.host, upload.AbstractRpcServer.host_override, upload.AbstractRpcServer.opener, and upload.AbstractRpcServer.save_cookies.

128  save_cookies=False):
129  """Creates a new HttpRpcServer.
130 
131  Args:
132  host: The host to send requests to.
133  auth_function: A function that takes no arguments and returns an
134  (email, password) tuple when called. Will be called if authentication
135  is required.
136  host_override: The host header to send to the server (defaults to host).
137  extra_headers: A dict of extra headers to append to every request.
138  save_cookies: If True, save the authentication cookies to local disk.
139  If False, use an in-memory cookiejar instead. Subclasses must
140  implement this functionality. Defaults to False.
141  """
142  self.host = host
143  self.host_override = host_override
144  self.auth_function = auth_function
145  self.authenticated = False
146  self.extra_headers = extra_headers
147  self.save_cookies = save_cookies
148  self.opener = self._GetOpener()
149  if self.host_override:
150  logging.info("Server: %s; Host: %s", self.host, self.host_override)
151  else:
152  logging.info("Server: %s", self.host)
153 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer.__init__ (   self,
  host,
  auth_function,
  host_override = None,
  extra_headers = {},
  save_cookies = False 
)
Creates a new HttpRpcServer.

Args:
  host: The host to send requests to.
  auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. Will be called if authentication
is required.
  host_override: The host header to send to the server (defaults to host).
  extra_headers: A dict of extra headers to append to every request.
  save_cookies: If True, save the authentication cookies to local disk.
If False, use an in-memory cookiejar instead.  Subclasses must
implement this functionality.  Defaults to False.

Definition at line 128 of file upload.py.

References upload.AbstractRpcServer._GetOpener(), upload.AbstractRpcServer.auth_function, upload.AbstractRpcServer.authenticated, upload.AbstractRpcServer.extra_headers, upload.AbstractRpcServer.host, upload.AbstractRpcServer.host_override, upload.AbstractRpcServer.opener, and upload.AbstractRpcServer.save_cookies.

128  save_cookies=False):
129  """Creates a new HttpRpcServer.
130 
131  Args:
132  host: The host to send requests to.
133  auth_function: A function that takes no arguments and returns an
134  (email, password) tuple when called. Will be called if authentication
135  is required.
136  host_override: The host header to send to the server (defaults to host).
137  extra_headers: A dict of extra headers to append to every request.
138  save_cookies: If True, save the authentication cookies to local disk.
139  If False, use an in-memory cookiejar instead. Subclasses must
140  implement this functionality. Defaults to False.
141  """
142  self.host = host
143  self.host_override = host_override
144  self.auth_function = auth_function
145  self.authenticated = False
146  self.extra_headers = extra_headers
147  self.save_cookies = save_cookies
148  self.opener = self._GetOpener()
149  if self.host_override:
150  logging.info("Server: %s; Host: %s", self.host, self.host_override)
151  else:
152  logging.info("Server: %s", self.host)
153 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer.__init__ (   self,
  host,
  auth_function,
  host_override = None,
  extra_headers = {},
  save_cookies = False 
)
Creates a new HttpRpcServer.

Args:
  host: The host to send requests to.
  auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. Will be called if authentication
is required.
  host_override: The host header to send to the server (defaults to host).
  extra_headers: A dict of extra headers to append to every request.
  save_cookies: If True, save the authentication cookies to local disk.
If False, use an in-memory cookiejar instead.  Subclasses must
implement this functionality.  Defaults to False.

Definition at line 128 of file upload.py.

References upload.AbstractRpcServer._GetOpener(), upload.AbstractRpcServer.auth_function, upload.AbstractRpcServer.authenticated, upload.AbstractRpcServer.extra_headers, upload.AbstractRpcServer.host, upload.AbstractRpcServer.host_override, upload.AbstractRpcServer.opener, and upload.AbstractRpcServer.save_cookies.

128  save_cookies=False):
129  """Creates a new HttpRpcServer.
130 
131  Args:
132  host: The host to send requests to.
133  auth_function: A function that takes no arguments and returns an
134  (email, password) tuple when called. Will be called if authentication
135  is required.
136  host_override: The host header to send to the server (defaults to host).
137  extra_headers: A dict of extra headers to append to every request.
138  save_cookies: If True, save the authentication cookies to local disk.
139  If False, use an in-memory cookiejar instead. Subclasses must
140  implement this functionality. Defaults to False.
141  """
142  self.host = host
143  self.host_override = host_override
144  self.auth_function = auth_function
145  self.authenticated = False
146  self.extra_headers = extra_headers
147  self.save_cookies = save_cookies
148  self.opener = self._GetOpener()
149  if self.host_override:
150  logging.info("Server: %s; Host: %s", self.host, self.host_override)
151  else:
152  logging.info("Server: %s", self.host)
153 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer.__init__ (   self,
  host,
  auth_function,
  host_override = None,
  extra_headers = {},
  save_cookies = False 
)
Creates a new HttpRpcServer.

Args:
  host: The host to send requests to.
  auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. Will be called if authentication
is required.
  host_override: The host header to send to the server (defaults to host).
  extra_headers: A dict of extra headers to append to every request.
  save_cookies: If True, save the authentication cookies to local disk.
If False, use an in-memory cookiejar instead.  Subclasses must
implement this functionality.  Defaults to False.

Definition at line 128 of file upload.py.

References upload.AbstractRpcServer._GetOpener(), upload.AbstractRpcServer.auth_function, upload.AbstractRpcServer.authenticated, upload.AbstractRpcServer.extra_headers, upload.AbstractRpcServer.host, upload.AbstractRpcServer.host_override, upload.AbstractRpcServer.opener, and upload.AbstractRpcServer.save_cookies.

128  save_cookies=False):
129  """Creates a new HttpRpcServer.
130 
131  Args:
132  host: The host to send requests to.
133  auth_function: A function that takes no arguments and returns an
134  (email, password) tuple when called. Will be called if authentication
135  is required.
136  host_override: The host header to send to the server (defaults to host).
137  extra_headers: A dict of extra headers to append to every request.
138  save_cookies: If True, save the authentication cookies to local disk.
139  If False, use an in-memory cookiejar instead. Subclasses must
140  implement this functionality. Defaults to False.
141  """
142  self.host = host
143  self.host_override = host_override
144  self.auth_function = auth_function
145  self.authenticated = False
146  self.extra_headers = extra_headers
147  self.save_cookies = save_cookies
148  self.opener = self._GetOpener()
149  if self.host_override:
150  logging.info("Server: %s; Host: %s", self.host, self.host_override)
151  else:
152  logging.info("Server: %s", self.host)
153 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer.__init__ (   self,
  host,
  auth_function,
  host_override = None,
  extra_headers = {},
  save_cookies = False 
)
Creates a new HttpRpcServer.

Args:
  host: The host to send requests to.
  auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. Will be called if authentication
is required.
  host_override: The host header to send to the server (defaults to host).
  extra_headers: A dict of extra headers to append to every request.
  save_cookies: If True, save the authentication cookies to local disk.
If False, use an in-memory cookiejar instead.  Subclasses must
implement this functionality.  Defaults to False.

Definition at line 128 of file upload.py.

References upload.AbstractRpcServer._GetOpener(), upload.AbstractRpcServer.auth_function, upload.AbstractRpcServer.authenticated, upload.AbstractRpcServer.extra_headers, upload.AbstractRpcServer.host, upload.AbstractRpcServer.host_override, upload.AbstractRpcServer.opener, and upload.AbstractRpcServer.save_cookies.

128  save_cookies=False):
129  """Creates a new HttpRpcServer.
130 
131  Args:
132  host: The host to send requests to.
133  auth_function: A function that takes no arguments and returns an
134  (email, password) tuple when called. Will be called if authentication
135  is required.
136  host_override: The host header to send to the server (defaults to host).
137  extra_headers: A dict of extra headers to append to every request.
138  save_cookies: If True, save the authentication cookies to local disk.
139  If False, use an in-memory cookiejar instead. Subclasses must
140  implement this functionality. Defaults to False.
141  """
142  self.host = host
143  self.host_override = host_override
144  self.auth_function = auth_function
145  self.authenticated = False
146  self.extra_headers = extra_headers
147  self.save_cookies = save_cookies
148  self.opener = self._GetOpener()
149  if self.host_override:
150  logging.info("Server: %s; Host: %s", self.host, self.host_override)
151  else:
152  logging.info("Server: %s", self.host)
153 
def _GetOpener(self)
Definition: upload.py:154

Member Function Documentation

def upload.AbstractRpcServer._Authenticate (   self)
private
Authenticates the user.

The authentication process works as follows:
 1) We get a username and password from the user
 2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
 3) We pass the auth token to /_ah/login on the server to obtain an
authentication cookie. If login was successful, it tries to redirect
us to the URL we provided.

If we attempt to access the upload API without first obtaining an
authentication cookie, it returns a 401 response and directs us to
authenticate ourselves with ClientLogin.

Definition at line 239 of file upload.py.

References upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), upload.AbstractRpcServer.auth_function, folly::gen.range(), and upload.AbstractRpcServer.Send().

Referenced by upload.AbstractRpcServer._Authenticate(), and upload.AbstractRpcServer.Send().

239  def _Authenticate(self):
240  """Authenticates the user.
241 
242  The authentication process works as follows:
243  1) We get a username and password from the user
244  2) We use ClientLogin to obtain an AUTH token for the user
245  (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
246  3) We pass the auth token to /_ah/login on the server to obtain an
247  authentication cookie. If login was successful, it tries to redirect
248  us to the URL we provided.
249 
250  If we attempt to access the upload API without first obtaining an
251  authentication cookie, it returns a 401 response and directs us to
252  authenticate ourselves with ClientLogin.
253  """
254  for i in range(3):
255  credentials = self.auth_function()
256  try:
257  auth_token = self._GetAuthToken(credentials[0], credentials[1])
258  except ClientLoginError, e:
259  if e.reason == "BadAuthentication":
260  print >>sys.stderr, "Invalid username or password."
261  continue
262  if e.reason == "CaptchaRequired":
263  print >>sys.stderr, (
264  "Please go to\n"
265  "https://www.google.com/accounts/DisplayUnlockCaptcha\n"
266  "and verify you are a human. Then try again.")
267  break
268  if e.reason == "NotVerified":
269  print >>sys.stderr, "Account not verified."
270  break
271  if e.reason == "TermsNotAgreed":
272  print >>sys.stderr, "User has not agreed to TOS."
273  break
274  if e.reason == "AccountDeleted":
275  print >>sys.stderr, "The user account has been deleted."
276  break
277  if e.reason == "AccountDisabled":
278  print >>sys.stderr, "The user account has been disabled."
279  break
280  if e.reason == "ServiceDisabled":
281  print >>sys.stderr, ("The user's access to the service has been "
282  "disabled.")
283  break
284  if e.reason == "ServiceUnavailable":
285  print >>sys.stderr, "The service is not available; try again later."
286  break
287  raise
288  self._GetAuthCookie(auth_token)
289  return
290 
def _Authenticate(self)
Definition: upload.py:239
Gen range(Value begin, Value end)
Definition: Base.h:467
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._Authenticate (   self)
private
Authenticates the user.

The authentication process works as follows:
 1) We get a username and password from the user
 2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
 3) We pass the auth token to /_ah/login on the server to obtain an
authentication cookie. If login was successful, it tries to redirect
us to the URL we provided.

If we attempt to access the upload API without first obtaining an
authentication cookie, it returns a 401 response and directs us to
authenticate ourselves with ClientLogin.

Definition at line 239 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), upload.AbstractRpcServer.auth_function, folly::gen.range(), and upload.AbstractRpcServer.Send().

239  def _Authenticate(self):
240  """Authenticates the user.
241 
242  The authentication process works as follows:
243  1) We get a username and password from the user
244  2) We use ClientLogin to obtain an AUTH token for the user
245  (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
246  3) We pass the auth token to /_ah/login on the server to obtain an
247  authentication cookie. If login was successful, it tries to redirect
248  us to the URL we provided.
249 
250  If we attempt to access the upload API without first obtaining an
251  authentication cookie, it returns a 401 response and directs us to
252  authenticate ourselves with ClientLogin.
253  """
254  for i in range(3):
255  credentials = self.auth_function()
256  try:
257  auth_token = self._GetAuthToken(credentials[0], credentials[1])
258  except ClientLoginError, e:
259  if e.reason == "BadAuthentication":
260  print >>sys.stderr, "Invalid username or password."
261  continue
262  if e.reason == "CaptchaRequired":
263  print >>sys.stderr, (
264  "Please go to\n"
265  "https://www.google.com/accounts/DisplayUnlockCaptcha\n"
266  "and verify you are a human. Then try again.")
267  break
268  if e.reason == "NotVerified":
269  print >>sys.stderr, "Account not verified."
270  break
271  if e.reason == "TermsNotAgreed":
272  print >>sys.stderr, "User has not agreed to TOS."
273  break
274  if e.reason == "AccountDeleted":
275  print >>sys.stderr, "The user account has been deleted."
276  break
277  if e.reason == "AccountDisabled":
278  print >>sys.stderr, "The user account has been disabled."
279  break
280  if e.reason == "ServiceDisabled":
281  print >>sys.stderr, ("The user's access to the service has been "
282  "disabled.")
283  break
284  if e.reason == "ServiceUnavailable":
285  print >>sys.stderr, "The service is not available; try again later."
286  break
287  raise
288  self._GetAuthCookie(auth_token)
289  return
290 
def _Authenticate(self)
Definition: upload.py:239
Gen range(Value begin, Value end)
Definition: Base.h:467
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._Authenticate (   self)
private
Authenticates the user.

The authentication process works as follows:
 1) We get a username and password from the user
 2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
 3) We pass the auth token to /_ah/login on the server to obtain an
authentication cookie. If login was successful, it tries to redirect
us to the URL we provided.

If we attempt to access the upload API without first obtaining an
authentication cookie, it returns a 401 response and directs us to
authenticate ourselves with ClientLogin.

Definition at line 239 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), upload.AbstractRpcServer.auth_function, folly::gen.range(), and upload.AbstractRpcServer.Send().

239  def _Authenticate(self):
240  """Authenticates the user.
241 
242  The authentication process works as follows:
243  1) We get a username and password from the user
244  2) We use ClientLogin to obtain an AUTH token for the user
245  (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
246  3) We pass the auth token to /_ah/login on the server to obtain an
247  authentication cookie. If login was successful, it tries to redirect
248  us to the URL we provided.
249 
250  If we attempt to access the upload API without first obtaining an
251  authentication cookie, it returns a 401 response and directs us to
252  authenticate ourselves with ClientLogin.
253  """
254  for i in range(3):
255  credentials = self.auth_function()
256  try:
257  auth_token = self._GetAuthToken(credentials[0], credentials[1])
258  except ClientLoginError, e:
259  if e.reason == "BadAuthentication":
260  print >>sys.stderr, "Invalid username or password."
261  continue
262  if e.reason == "CaptchaRequired":
263  print >>sys.stderr, (
264  "Please go to\n"
265  "https://www.google.com/accounts/DisplayUnlockCaptcha\n"
266  "and verify you are a human. Then try again.")
267  break
268  if e.reason == "NotVerified":
269  print >>sys.stderr, "Account not verified."
270  break
271  if e.reason == "TermsNotAgreed":
272  print >>sys.stderr, "User has not agreed to TOS."
273  break
274  if e.reason == "AccountDeleted":
275  print >>sys.stderr, "The user account has been deleted."
276  break
277  if e.reason == "AccountDisabled":
278  print >>sys.stderr, "The user account has been disabled."
279  break
280  if e.reason == "ServiceDisabled":
281  print >>sys.stderr, ("The user's access to the service has been "
282  "disabled.")
283  break
284  if e.reason == "ServiceUnavailable":
285  print >>sys.stderr, "The service is not available; try again later."
286  break
287  raise
288  self._GetAuthCookie(auth_token)
289  return
290 
def _Authenticate(self)
Definition: upload.py:239
Gen range(Value begin, Value end)
Definition: Base.h:467
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._Authenticate (   self)
private
Authenticates the user.

The authentication process works as follows:
 1) We get a username and password from the user
 2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
 3) We pass the auth token to /_ah/login on the server to obtain an
authentication cookie. If login was successful, it tries to redirect
us to the URL we provided.

If we attempt to access the upload API without first obtaining an
authentication cookie, it returns a 401 response and directs us to
authenticate ourselves with ClientLogin.

Definition at line 239 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), upload.AbstractRpcServer.auth_function, folly::gen.range(), and upload.AbstractRpcServer.Send().

239  def _Authenticate(self):
240  """Authenticates the user.
241 
242  The authentication process works as follows:
243  1) We get a username and password from the user
244  2) We use ClientLogin to obtain an AUTH token for the user
245  (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
246  3) We pass the auth token to /_ah/login on the server to obtain an
247  authentication cookie. If login was successful, it tries to redirect
248  us to the URL we provided.
249 
250  If we attempt to access the upload API without first obtaining an
251  authentication cookie, it returns a 401 response and directs us to
252  authenticate ourselves with ClientLogin.
253  """
254  for i in range(3):
255  credentials = self.auth_function()
256  try:
257  auth_token = self._GetAuthToken(credentials[0], credentials[1])
258  except ClientLoginError, e:
259  if e.reason == "BadAuthentication":
260  print >>sys.stderr, "Invalid username or password."
261  continue
262  if e.reason == "CaptchaRequired":
263  print >>sys.stderr, (
264  "Please go to\n"
265  "https://www.google.com/accounts/DisplayUnlockCaptcha\n"
266  "and verify you are a human. Then try again.")
267  break
268  if e.reason == "NotVerified":
269  print >>sys.stderr, "Account not verified."
270  break
271  if e.reason == "TermsNotAgreed":
272  print >>sys.stderr, "User has not agreed to TOS."
273  break
274  if e.reason == "AccountDeleted":
275  print >>sys.stderr, "The user account has been deleted."
276  break
277  if e.reason == "AccountDisabled":
278  print >>sys.stderr, "The user account has been disabled."
279  break
280  if e.reason == "ServiceDisabled":
281  print >>sys.stderr, ("The user's access to the service has been "
282  "disabled.")
283  break
284  if e.reason == "ServiceUnavailable":
285  print >>sys.stderr, "The service is not available; try again later."
286  break
287  raise
288  self._GetAuthCookie(auth_token)
289  return
290 
def _Authenticate(self)
Definition: upload.py:239
Gen range(Value begin, Value end)
Definition: Base.h:467
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._Authenticate (   self)
private
Authenticates the user.

The authentication process works as follows:
 1) We get a username and password from the user
 2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
 3) We pass the auth token to /_ah/login on the server to obtain an
authentication cookie. If login was successful, it tries to redirect
us to the URL we provided.

If we attempt to access the upload API without first obtaining an
authentication cookie, it returns a 401 response and directs us to
authenticate ourselves with ClientLogin.

Definition at line 239 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), upload.AbstractRpcServer.auth_function, folly::gen.range(), and upload.AbstractRpcServer.Send().

239  def _Authenticate(self):
240  """Authenticates the user.
241 
242  The authentication process works as follows:
243  1) We get a username and password from the user
244  2) We use ClientLogin to obtain an AUTH token for the user
245  (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
246  3) We pass the auth token to /_ah/login on the server to obtain an
247  authentication cookie. If login was successful, it tries to redirect
248  us to the URL we provided.
249 
250  If we attempt to access the upload API without first obtaining an
251  authentication cookie, it returns a 401 response and directs us to
252  authenticate ourselves with ClientLogin.
253  """
254  for i in range(3):
255  credentials = self.auth_function()
256  try:
257  auth_token = self._GetAuthToken(credentials[0], credentials[1])
258  except ClientLoginError, e:
259  if e.reason == "BadAuthentication":
260  print >>sys.stderr, "Invalid username or password."
261  continue
262  if e.reason == "CaptchaRequired":
263  print >>sys.stderr, (
264  "Please go to\n"
265  "https://www.google.com/accounts/DisplayUnlockCaptcha\n"
266  "and verify you are a human. Then try again.")
267  break
268  if e.reason == "NotVerified":
269  print >>sys.stderr, "Account not verified."
270  break
271  if e.reason == "TermsNotAgreed":
272  print >>sys.stderr, "User has not agreed to TOS."
273  break
274  if e.reason == "AccountDeleted":
275  print >>sys.stderr, "The user account has been deleted."
276  break
277  if e.reason == "AccountDisabled":
278  print >>sys.stderr, "The user account has been disabled."
279  break
280  if e.reason == "ServiceDisabled":
281  print >>sys.stderr, ("The user's access to the service has been "
282  "disabled.")
283  break
284  if e.reason == "ServiceUnavailable":
285  print >>sys.stderr, "The service is not available; try again later."
286  break
287  raise
288  self._GetAuthCookie(auth_token)
289  return
290 
def _Authenticate(self)
Definition: upload.py:239
Gen range(Value begin, Value end)
Definition: Base.h:467
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._Authenticate (   self)
private
Authenticates the user.

The authentication process works as follows:
 1) We get a username and password from the user
 2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
 3) We pass the auth token to /_ah/login on the server to obtain an
authentication cookie. If login was successful, it tries to redirect
us to the URL we provided.

If we attempt to access the upload API without first obtaining an
authentication cookie, it returns a 401 response and directs us to
authenticate ourselves with ClientLogin.

Definition at line 239 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), upload.AbstractRpcServer.auth_function, folly::gen.range(), and upload.AbstractRpcServer.Send().

239  def _Authenticate(self):
240  """Authenticates the user.
241 
242  The authentication process works as follows:
243  1) We get a username and password from the user
244  2) We use ClientLogin to obtain an AUTH token for the user
245  (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
246  3) We pass the auth token to /_ah/login on the server to obtain an
247  authentication cookie. If login was successful, it tries to redirect
248  us to the URL we provided.
249 
250  If we attempt to access the upload API without first obtaining an
251  authentication cookie, it returns a 401 response and directs us to
252  authenticate ourselves with ClientLogin.
253  """
254  for i in range(3):
255  credentials = self.auth_function()
256  try:
257  auth_token = self._GetAuthToken(credentials[0], credentials[1])
258  except ClientLoginError, e:
259  if e.reason == "BadAuthentication":
260  print >>sys.stderr, "Invalid username or password."
261  continue
262  if e.reason == "CaptchaRequired":
263  print >>sys.stderr, (
264  "Please go to\n"
265  "https://www.google.com/accounts/DisplayUnlockCaptcha\n"
266  "and verify you are a human. Then try again.")
267  break
268  if e.reason == "NotVerified":
269  print >>sys.stderr, "Account not verified."
270  break
271  if e.reason == "TermsNotAgreed":
272  print >>sys.stderr, "User has not agreed to TOS."
273  break
274  if e.reason == "AccountDeleted":
275  print >>sys.stderr, "The user account has been deleted."
276  break
277  if e.reason == "AccountDisabled":
278  print >>sys.stderr, "The user account has been disabled."
279  break
280  if e.reason == "ServiceDisabled":
281  print >>sys.stderr, ("The user's access to the service has been "
282  "disabled.")
283  break
284  if e.reason == "ServiceUnavailable":
285  print >>sys.stderr, "The service is not available; try again later."
286  break
287  raise
288  self._GetAuthCookie(auth_token)
289  return
290 
def _Authenticate(self)
Definition: upload.py:239
Gen range(Value begin, Value end)
Definition: Base.h:467
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._CreateRequest (   self,
  url,
  data = None 
)
private
Creates a new urllib request.

Definition at line 162 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer.host_override.

162  def _CreateRequest(self, url, data=None):
163  """Creates a new urllib request."""
164  logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
165  req = urllib2.Request(url, data=data)
166  if self.host_override:
167  req.add_header("Host", self.host_override)
168  for key, value in self.extra_headers.iteritems():
169  req.add_header(key, value)
170  return req
171 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def upload.AbstractRpcServer._CreateRequest (   self,
  url,
  data = None 
)
private
Creates a new urllib request.

Definition at line 162 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer.host_override.

162  def _CreateRequest(self, url, data=None):
163  """Creates a new urllib request."""
164  logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
165  req = urllib2.Request(url, data=data)
166  if self.host_override:
167  req.add_header("Host", self.host_override)
168  for key, value in self.extra_headers.iteritems():
169  req.add_header(key, value)
170  return req
171 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def upload.AbstractRpcServer._CreateRequest (   self,
  url,
  data = None 
)
private
Creates a new urllib request.

Definition at line 162 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer.host_override.

162  def _CreateRequest(self, url, data=None):
163  """Creates a new urllib request."""
164  logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
165  req = urllib2.Request(url, data=data)
166  if self.host_override:
167  req.add_header("Host", self.host_override)
168  for key, value in self.extra_headers.iteritems():
169  req.add_header(key, value)
170  return req
171 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def upload.AbstractRpcServer._CreateRequest (   self,
  url,
  data = None 
)
private
Creates a new urllib request.

Definition at line 162 of file upload.py.

References upload.AbstractRpcServer.host_override.

Referenced by upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer._GetAuthToken(), and upload.AbstractRpcServer.Send().

162  def _CreateRequest(self, url, data=None):
163  """Creates a new urllib request."""
164  logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
165  req = urllib2.Request(url, data=data)
166  if self.host_override:
167  req.add_header("Host", self.host_override)
168  for key, value in self.extra_headers.iteritems():
169  req.add_header(key, value)
170  return req
171 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def upload.AbstractRpcServer._CreateRequest (   self,
  url,
  data = None 
)
private
Creates a new urllib request.

Definition at line 162 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer.host_override.

162  def _CreateRequest(self, url, data=None):
163  """Creates a new urllib request."""
164  logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
165  req = urllib2.Request(url, data=data)
166  if self.host_override:
167  req.add_header("Host", self.host_override)
168  for key, value in self.extra_headers.iteritems():
169  req.add_header(key, value)
170  return req
171 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def upload.AbstractRpcServer._CreateRequest (   self,
  url,
  data = None 
)
private
Creates a new urllib request.

Definition at line 162 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer.host_override.

162  def _CreateRequest(self, url, data=None):
163  """Creates a new urllib request."""
164  logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
165  req = urllib2.Request(url, data=data)
166  if self.host_override:
167  req.add_header("Host", self.host_override)
168  for key, value in self.extra_headers.iteritems():
169  req.add_header(key, value)
170  return req
171 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def upload.AbstractRpcServer._GetAuthCookie (   self,
  auth_token 
)
private
Fetches authentication cookies for an authentication token.

Args:
  auth_token: The authentication token returned by ClientLogin.

Raises:
  HTTPError: If there was an error fetching the authentication cookies.

Definition at line 215 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

215  def _GetAuthCookie(self, auth_token):
216  """Fetches authentication cookies for an authentication token.
217 
218  Args:
219  auth_token: The authentication token returned by ClientLogin.
220 
221  Raises:
222  HTTPError: If there was an error fetching the authentication cookies.
223  """
224  # This is a dummy value to allow us to identify when we're successful.
225  continue_location = "http://localhost/"
226  args = {"continue": continue_location, "auth": auth_token}
227  req = self._CreateRequest("http://%s/_ah/login?%s" %
228  (self.host, urllib.urlencode(args)))
229  try:
230  response = self.opener.open(req)
231  except urllib2.HTTPError, e:
232  response = e
233  if (response.code != 302 or
234  response.info()["location"] != continue_location):
235  raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,
236  response.headers, response.fp)
237  self.authenticated = True
238 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def upload.AbstractRpcServer._GetAuthCookie (   self,
  auth_token 
)
private
Fetches authentication cookies for an authentication token.

Args:
  auth_token: The authentication token returned by ClientLogin.

Raises:
  HTTPError: If there was an error fetching the authentication cookies.

Definition at line 215 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

215  def _GetAuthCookie(self, auth_token):
216  """Fetches authentication cookies for an authentication token.
217 
218  Args:
219  auth_token: The authentication token returned by ClientLogin.
220 
221  Raises:
222  HTTPError: If there was an error fetching the authentication cookies.
223  """
224  # This is a dummy value to allow us to identify when we're successful.
225  continue_location = "http://localhost/"
226  args = {"continue": continue_location, "auth": auth_token}
227  req = self._CreateRequest("http://%s/_ah/login?%s" %
228  (self.host, urllib.urlencode(args)))
229  try:
230  response = self.opener.open(req)
231  except urllib2.HTTPError, e:
232  response = e
233  if (response.code != 302 or
234  response.info()["location"] != continue_location):
235  raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,
236  response.headers, response.fp)
237  self.authenticated = True
238 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def upload.AbstractRpcServer._GetAuthCookie (   self,
  auth_token 
)
private
Fetches authentication cookies for an authentication token.

Args:
  auth_token: The authentication token returned by ClientLogin.

Raises:
  HTTPError: If there was an error fetching the authentication cookies.

Definition at line 215 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

215  def _GetAuthCookie(self, auth_token):
216  """Fetches authentication cookies for an authentication token.
217 
218  Args:
219  auth_token: The authentication token returned by ClientLogin.
220 
221  Raises:
222  HTTPError: If there was an error fetching the authentication cookies.
223  """
224  # This is a dummy value to allow us to identify when we're successful.
225  continue_location = "http://localhost/"
226  args = {"continue": continue_location, "auth": auth_token}
227  req = self._CreateRequest("http://%s/_ah/login?%s" %
228  (self.host, urllib.urlencode(args)))
229  try:
230  response = self.opener.open(req)
231  except urllib2.HTTPError, e:
232  response = e
233  if (response.code != 302 or
234  response.info()["location"] != continue_location):
235  raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,
236  response.headers, response.fp)
237  self.authenticated = True
238 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def upload.AbstractRpcServer._GetAuthCookie (   self,
  auth_token 
)
private
Fetches authentication cookies for an authentication token.

Args:
  auth_token: The authentication token returned by ClientLogin.

Raises:
  HTTPError: If there was an error fetching the authentication cookies.

Definition at line 215 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

215  def _GetAuthCookie(self, auth_token):
216  """Fetches authentication cookies for an authentication token.
217 
218  Args:
219  auth_token: The authentication token returned by ClientLogin.
220 
221  Raises:
222  HTTPError: If there was an error fetching the authentication cookies.
223  """
224  # This is a dummy value to allow us to identify when we're successful.
225  continue_location = "http://localhost/"
226  args = {"continue": continue_location, "auth": auth_token}
227  req = self._CreateRequest("http://%s/_ah/login?%s" %
228  (self.host, urllib.urlencode(args)))
229  try:
230  response = self.opener.open(req)
231  except urllib2.HTTPError, e:
232  response = e
233  if (response.code != 302 or
234  response.info()["location"] != continue_location):
235  raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,
236  response.headers, response.fp)
237  self.authenticated = True
238 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def upload.AbstractRpcServer._GetAuthCookie (   self,
  auth_token 
)
private
Fetches authentication cookies for an authentication token.

Args:
  auth_token: The authentication token returned by ClientLogin.

Raises:
  HTTPError: If there was an error fetching the authentication cookies.

Definition at line 215 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

Referenced by upload.AbstractRpcServer._Authenticate(), and upload.AbstractRpcServer._GetAuthCookie().

215  def _GetAuthCookie(self, auth_token):
216  """Fetches authentication cookies for an authentication token.
217 
218  Args:
219  auth_token: The authentication token returned by ClientLogin.
220 
221  Raises:
222  HTTPError: If there was an error fetching the authentication cookies.
223  """
224  # This is a dummy value to allow us to identify when we're successful.
225  continue_location = "http://localhost/"
226  args = {"continue": continue_location, "auth": auth_token}
227  req = self._CreateRequest("http://%s/_ah/login?%s" %
228  (self.host, urllib.urlencode(args)))
229  try:
230  response = self.opener.open(req)
231  except urllib2.HTTPError, e:
232  response = e
233  if (response.code != 302 or
234  response.info()["location"] != continue_location):
235  raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,
236  response.headers, response.fp)
237  self.authenticated = True
238 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def upload.AbstractRpcServer._GetAuthCookie (   self,
  auth_token 
)
private
Fetches authentication cookies for an authentication token.

Args:
  auth_token: The authentication token returned by ClientLogin.

Raises:
  HTTPError: If there was an error fetching the authentication cookies.

Definition at line 215 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer._GetAuthCookie(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

215  def _GetAuthCookie(self, auth_token):
216  """Fetches authentication cookies for an authentication token.
217 
218  Args:
219  auth_token: The authentication token returned by ClientLogin.
220 
221  Raises:
222  HTTPError: If there was an error fetching the authentication cookies.
223  """
224  # This is a dummy value to allow us to identify when we're successful.
225  continue_location = "http://localhost/"
226  args = {"continue": continue_location, "auth": auth_token}
227  req = self._CreateRequest("http://%s/_ah/login?%s" %
228  (self.host, urllib.urlencode(args)))
229  try:
230  response = self.opener.open(req)
231  except urllib2.HTTPError, e:
232  response = e
233  if (response.code != 302 or
234  response.info()["location"] != continue_location):
235  raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,
236  response.headers, response.fp)
237  self.authenticated = True
238 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthCookie(self, auth_token)
Definition: upload.py:215
def upload.AbstractRpcServer._GetAuthToken (   self,
  email,
  password 
)
private
Uses ClientLogin to authenticate the user, returning an auth token.

Args:
  email:    The user's email address
  password: The user's password

Raises:
  ClientLoginError: If there was an error authenticating with ClientLogin.
  HTTPError: If there was some other form of HTTP error.

Returns:
  The authentication token returned by ClientLogin.

Definition at line 172 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer._GetAuthToken().

172  def _GetAuthToken(self, email, password):
173  """Uses ClientLogin to authenticate the user, returning an auth token.
174 
175  Args:
176  email: The user's email address
177  password: The user's password
178 
179  Raises:
180  ClientLoginError: If there was an error authenticating with ClientLogin.
181  HTTPError: If there was some other form of HTTP error.
182 
183  Returns:
184  The authentication token returned by ClientLogin.
185  """
186  account_type = "GOOGLE"
187  if self.host.endswith(".google.com"):
188  # Needed for use inside Google.
189  account_type = "HOSTED"
190  req = self._CreateRequest(
191  url="https://www.google.com/accounts/ClientLogin",
192  data=urllib.urlencode({
193  "Email": email,
194  "Passwd": password,
195  "service": "ah",
196  "source": "rietveld-codereview-upload",
197  "accountType": account_type,
198  }),
199  )
200  try:
201  response = self.opener.open(req)
202  response_body = response.read()
203  response_dict = dict(x.split("=")
204  for x in response_body.split("\n") if x)
205  return response_dict["Auth"]
206  except urllib2.HTTPError, e:
207  if e.code == 403:
208  body = e.read()
209  response_dict = dict(x.split("=", 1) for x in body.split("\n") if x)
210  raise ClientLoginError(req.get_full_url(), e.code, e.msg,
211  e.headers, response_dict)
212  else:
213  raise
214 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._GetAuthToken (   self,
  email,
  password 
)
private
Uses ClientLogin to authenticate the user, returning an auth token.

Args:
  email:    The user's email address
  password: The user's password

Raises:
  ClientLoginError: If there was an error authenticating with ClientLogin.
  HTTPError: If there was some other form of HTTP error.

Returns:
  The authentication token returned by ClientLogin.

Definition at line 172 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer._GetAuthToken().

172  def _GetAuthToken(self, email, password):
173  """Uses ClientLogin to authenticate the user, returning an auth token.
174 
175  Args:
176  email: The user's email address
177  password: The user's password
178 
179  Raises:
180  ClientLoginError: If there was an error authenticating with ClientLogin.
181  HTTPError: If there was some other form of HTTP error.
182 
183  Returns:
184  The authentication token returned by ClientLogin.
185  """
186  account_type = "GOOGLE"
187  if self.host.endswith(".google.com"):
188  # Needed for use inside Google.
189  account_type = "HOSTED"
190  req = self._CreateRequest(
191  url="https://www.google.com/accounts/ClientLogin",
192  data=urllib.urlencode({
193  "Email": email,
194  "Passwd": password,
195  "service": "ah",
196  "source": "rietveld-codereview-upload",
197  "accountType": account_type,
198  }),
199  )
200  try:
201  response = self.opener.open(req)
202  response_body = response.read()
203  response_dict = dict(x.split("=")
204  for x in response_body.split("\n") if x)
205  return response_dict["Auth"]
206  except urllib2.HTTPError, e:
207  if e.code == 403:
208  body = e.read()
209  response_dict = dict(x.split("=", 1) for x in body.split("\n") if x)
210  raise ClientLoginError(req.get_full_url(), e.code, e.msg,
211  e.headers, response_dict)
212  else:
213  raise
214 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._GetAuthToken (   self,
  email,
  password 
)
private
Uses ClientLogin to authenticate the user, returning an auth token.

Args:
  email:    The user's email address
  password: The user's password

Raises:
  ClientLoginError: If there was an error authenticating with ClientLogin.
  HTTPError: If there was some other form of HTTP error.

Returns:
  The authentication token returned by ClientLogin.

Definition at line 172 of file upload.py.

References upload.AbstractRpcServer._CreateRequest().

Referenced by upload.AbstractRpcServer._Authenticate(), and upload.AbstractRpcServer._GetAuthToken().

172  def _GetAuthToken(self, email, password):
173  """Uses ClientLogin to authenticate the user, returning an auth token.
174 
175  Args:
176  email: The user's email address
177  password: The user's password
178 
179  Raises:
180  ClientLoginError: If there was an error authenticating with ClientLogin.
181  HTTPError: If there was some other form of HTTP error.
182 
183  Returns:
184  The authentication token returned by ClientLogin.
185  """
186  account_type = "GOOGLE"
187  if self.host.endswith(".google.com"):
188  # Needed for use inside Google.
189  account_type = "HOSTED"
190  req = self._CreateRequest(
191  url="https://www.google.com/accounts/ClientLogin",
192  data=urllib.urlencode({
193  "Email": email,
194  "Passwd": password,
195  "service": "ah",
196  "source": "rietveld-codereview-upload",
197  "accountType": account_type,
198  }),
199  )
200  try:
201  response = self.opener.open(req)
202  response_body = response.read()
203  response_dict = dict(x.split("=")
204  for x in response_body.split("\n") if x)
205  return response_dict["Auth"]
206  except urllib2.HTTPError, e:
207  if e.code == 403:
208  body = e.read()
209  response_dict = dict(x.split("=", 1) for x in body.split("\n") if x)
210  raise ClientLoginError(req.get_full_url(), e.code, e.msg,
211  e.headers, response_dict)
212  else:
213  raise
214 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._GetAuthToken (   self,
  email,
  password 
)
private
Uses ClientLogin to authenticate the user, returning an auth token.

Args:
  email:    The user's email address
  password: The user's password

Raises:
  ClientLoginError: If there was an error authenticating with ClientLogin.
  HTTPError: If there was some other form of HTTP error.

Returns:
  The authentication token returned by ClientLogin.

Definition at line 172 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer._GetAuthToken().

172  def _GetAuthToken(self, email, password):
173  """Uses ClientLogin to authenticate the user, returning an auth token.
174 
175  Args:
176  email: The user's email address
177  password: The user's password
178 
179  Raises:
180  ClientLoginError: If there was an error authenticating with ClientLogin.
181  HTTPError: If there was some other form of HTTP error.
182 
183  Returns:
184  The authentication token returned by ClientLogin.
185  """
186  account_type = "GOOGLE"
187  if self.host.endswith(".google.com"):
188  # Needed for use inside Google.
189  account_type = "HOSTED"
190  req = self._CreateRequest(
191  url="https://www.google.com/accounts/ClientLogin",
192  data=urllib.urlencode({
193  "Email": email,
194  "Passwd": password,
195  "service": "ah",
196  "source": "rietveld-codereview-upload",
197  "accountType": account_type,
198  }),
199  )
200  try:
201  response = self.opener.open(req)
202  response_body = response.read()
203  response_dict = dict(x.split("=")
204  for x in response_body.split("\n") if x)
205  return response_dict["Auth"]
206  except urllib2.HTTPError, e:
207  if e.code == 403:
208  body = e.read()
209  response_dict = dict(x.split("=", 1) for x in body.split("\n") if x)
210  raise ClientLoginError(req.get_full_url(), e.code, e.msg,
211  e.headers, response_dict)
212  else:
213  raise
214 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._GetAuthToken (   self,
  email,
  password 
)
private
Uses ClientLogin to authenticate the user, returning an auth token.

Args:
  email:    The user's email address
  password: The user's password

Raises:
  ClientLoginError: If there was an error authenticating with ClientLogin.
  HTTPError: If there was some other form of HTTP error.

Returns:
  The authentication token returned by ClientLogin.

Definition at line 172 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer._GetAuthToken().

172  def _GetAuthToken(self, email, password):
173  """Uses ClientLogin to authenticate the user, returning an auth token.
174 
175  Args:
176  email: The user's email address
177  password: The user's password
178 
179  Raises:
180  ClientLoginError: If there was an error authenticating with ClientLogin.
181  HTTPError: If there was some other form of HTTP error.
182 
183  Returns:
184  The authentication token returned by ClientLogin.
185  """
186  account_type = "GOOGLE"
187  if self.host.endswith(".google.com"):
188  # Needed for use inside Google.
189  account_type = "HOSTED"
190  req = self._CreateRequest(
191  url="https://www.google.com/accounts/ClientLogin",
192  data=urllib.urlencode({
193  "Email": email,
194  "Passwd": password,
195  "service": "ah",
196  "source": "rietveld-codereview-upload",
197  "accountType": account_type,
198  }),
199  )
200  try:
201  response = self.opener.open(req)
202  response_body = response.read()
203  response_dict = dict(x.split("=")
204  for x in response_body.split("\n") if x)
205  return response_dict["Auth"]
206  except urllib2.HTTPError, e:
207  if e.code == 403:
208  body = e.read()
209  response_dict = dict(x.split("=", 1) for x in body.split("\n") if x)
210  raise ClientLoginError(req.get_full_url(), e.code, e.msg,
211  e.headers, response_dict)
212  else:
213  raise
214 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._GetAuthToken (   self,
  email,
  password 
)
private
Uses ClientLogin to authenticate the user, returning an auth token.

Args:
  email:    The user's email address
  password: The user's password

Raises:
  ClientLoginError: If there was an error authenticating with ClientLogin.
  HTTPError: If there was some other form of HTTP error.

Returns:
  The authentication token returned by ClientLogin.

Definition at line 172 of file upload.py.

References upload.AbstractRpcServer._CreateRequest(), and upload.AbstractRpcServer._GetAuthToken().

172  def _GetAuthToken(self, email, password):
173  """Uses ClientLogin to authenticate the user, returning an auth token.
174 
175  Args:
176  email: The user's email address
177  password: The user's password
178 
179  Raises:
180  ClientLoginError: If there was an error authenticating with ClientLogin.
181  HTTPError: If there was some other form of HTTP error.
182 
183  Returns:
184  The authentication token returned by ClientLogin.
185  """
186  account_type = "GOOGLE"
187  if self.host.endswith(".google.com"):
188  # Needed for use inside Google.
189  account_type = "HOSTED"
190  req = self._CreateRequest(
191  url="https://www.google.com/accounts/ClientLogin",
192  data=urllib.urlencode({
193  "Email": email,
194  "Passwd": password,
195  "service": "ah",
196  "source": "rietveld-codereview-upload",
197  "accountType": account_type,
198  }),
199  )
200  try:
201  response = self.opener.open(req)
202  response_body = response.read()
203  response_dict = dict(x.split("=")
204  for x in response_body.split("\n") if x)
205  return response_dict["Auth"]
206  except urllib2.HTTPError, e:
207  if e.code == 403:
208  body = e.read()
209  response_dict = dict(x.split("=", 1) for x in body.split("\n") if x)
210  raise ClientLoginError(req.get_full_url(), e.code, e.msg,
211  e.headers, response_dict)
212  else:
213  raise
214 
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _GetAuthToken(self, email, password)
Definition: upload.py:172
def upload.AbstractRpcServer._GetOpener (   self)
private
Returns an OpenerDirector for making HTTP requests.

Returns:
  A urllib2.OpenerDirector object.

Definition at line 154 of file upload.py.

References upload.AbstractRpcServer._GetOpener().

154  def _GetOpener(self):
155  """Returns an OpenerDirector for making HTTP requests.
156 
157  Returns:
158  A urllib2.OpenerDirector object.
159  """
160  raise NotImplementedError()
161 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer._GetOpener (   self)
private
Returns an OpenerDirector for making HTTP requests.

Returns:
  A urllib2.OpenerDirector object.

Definition at line 154 of file upload.py.

References upload.AbstractRpcServer._GetOpener().

154  def _GetOpener(self):
155  """Returns an OpenerDirector for making HTTP requests.
156 
157  Returns:
158  A urllib2.OpenerDirector object.
159  """
160  raise NotImplementedError()
161 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer._GetOpener (   self)
private
Returns an OpenerDirector for making HTTP requests.

Returns:
  A urllib2.OpenerDirector object.

Definition at line 154 of file upload.py.

References upload.AbstractRpcServer._GetOpener().

154  def _GetOpener(self):
155  """Returns an OpenerDirector for making HTTP requests.
156 
157  Returns:
158  A urllib2.OpenerDirector object.
159  """
160  raise NotImplementedError()
161 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer._GetOpener (   self)
private
Returns an OpenerDirector for making HTTP requests.

Returns:
  A urllib2.OpenerDirector object.

Definition at line 154 of file upload.py.

References upload.AbstractRpcServer._GetOpener().

154  def _GetOpener(self):
155  """Returns an OpenerDirector for making HTTP requests.
156 
157  Returns:
158  A urllib2.OpenerDirector object.
159  """
160  raise NotImplementedError()
161 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer._GetOpener (   self)
private
Returns an OpenerDirector for making HTTP requests.

Returns:
  A urllib2.OpenerDirector object.

Definition at line 154 of file upload.py.

Referenced by upload.AbstractRpcServer.__init__(), and upload.AbstractRpcServer._GetOpener().

154  def _GetOpener(self):
155  """Returns an OpenerDirector for making HTTP requests.
156 
157  Returns:
158  A urllib2.OpenerDirector object.
159  """
160  raise NotImplementedError()
161 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer._GetOpener (   self)
private
Returns an OpenerDirector for making HTTP requests.

Returns:
  A urllib2.OpenerDirector object.

Definition at line 154 of file upload.py.

References upload.AbstractRpcServer._GetOpener().

154  def _GetOpener(self):
155  """Returns an OpenerDirector for making HTTP requests.
156 
157  Returns:
158  A urllib2.OpenerDirector object.
159  """
160  raise NotImplementedError()
161 
def _GetOpener(self)
Definition: upload.py:154
def upload.AbstractRpcServer.Send (   self,
  request_path,
  payload = None,
  content_type = "application/octet-stream",
  timeout = None,
  kwargs 
)
Sends an RPC and returns the response.

Args:
  request_path: The path to send the request to, eg /api/appversion/create.
  payload: The body of the request, or None to send an empty request.
  content_type: The Content-Type header to use.
  timeout: timeout in seconds; default None i.e. no timeout.
(Note: for large requests on OS X, the timeout doesn't work right.)
  kwargs: Any keyword arguments are converted into query string parameters.

Returns:
  The response body, as a string.

Definition at line 294 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

Referenced by upload.AbstractRpcServer._Authenticate().

294  **kwargs):
295  """Sends an RPC and returns the response.
296 
297  Args:
298  request_path: The path to send the request to, eg /api/appversion/create.
299  payload: The body of the request, or None to send an empty request.
300  content_type: The Content-Type header to use.
301  timeout: timeout in seconds; default None i.e. no timeout.
302  (Note: for large requests on OS X, the timeout doesn't work right.)
303  kwargs: Any keyword arguments are converted into query string parameters.
304 
305  Returns:
306  The response body, as a string.
307  """
308  # TODO: Don't require authentication. Let the server say
309  # whether it is necessary.
310  if not self.authenticated:
311  self._Authenticate()
312 
313  old_timeout = socket.getdefaulttimeout()
314  socket.setdefaulttimeout(timeout)
315  try:
316  tries = 0
317  while True:
318  tries += 1
319  args = dict(kwargs)
320  url = "http://%s%s" % (self.host, request_path)
321  if args:
322  url += "?" + urllib.urlencode(args)
323  req = self._CreateRequest(url=url, data=payload)
324  req.add_header("Content-Type", content_type)
325  try:
326  f = self.opener.open(req)
327  response = f.read()
328  f.close()
329  return response
330  except urllib2.HTTPError, e:
331  if tries > 3:
332  raise
333  elif e.code == 401:
334  self._Authenticate()
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _Authenticate(self)
Definition: upload.py:239
def upload.AbstractRpcServer.Send (   self,
  request_path,
  payload = None,
  content_type = "application/octet-stream",
  timeout = None,
  kwargs 
)
Sends an RPC and returns the response.

Args:
  request_path: The path to send the request to, eg /api/appversion/create.
  payload: The body of the request, or None to send an empty request.
  content_type: The Content-Type header to use.
  timeout: timeout in seconds; default None i.e. no timeout.
(Note: for large requests on OS X, the timeout doesn't work right.)
  kwargs: Any keyword arguments are converted into query string parameters.

Returns:
  The response body, as a string.

Definition at line 294 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

294  **kwargs):
295  """Sends an RPC and returns the response.
296 
297  Args:
298  request_path: The path to send the request to, eg /api/appversion/create.
299  payload: The body of the request, or None to send an empty request.
300  content_type: The Content-Type header to use.
301  timeout: timeout in seconds; default None i.e. no timeout.
302  (Note: for large requests on OS X, the timeout doesn't work right.)
303  kwargs: Any keyword arguments are converted into query string parameters.
304 
305  Returns:
306  The response body, as a string.
307  """
308  # TODO: Don't require authentication. Let the server say
309  # whether it is necessary.
310  if not self.authenticated:
311  self._Authenticate()
312 
313  old_timeout = socket.getdefaulttimeout()
314  socket.setdefaulttimeout(timeout)
315  try:
316  tries = 0
317  while True:
318  tries += 1
319  args = dict(kwargs)
320  url = "http://%s%s" % (self.host, request_path)
321  if args:
322  url += "?" + urllib.urlencode(args)
323  req = self._CreateRequest(url=url, data=payload)
324  req.add_header("Content-Type", content_type)
325  try:
326  f = self.opener.open(req)
327  response = f.read()
328  f.close()
329  return response
330  except urllib2.HTTPError, e:
331  if tries > 3:
332  raise
333  elif e.code == 401:
334  self._Authenticate()
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _Authenticate(self)
Definition: upload.py:239
def upload.AbstractRpcServer.Send (   self,
  request_path,
  payload = None,
  content_type = "application/octet-stream",
  timeout = None,
  kwargs 
)
Sends an RPC and returns the response.

Args:
  request_path: The path to send the request to, eg /api/appversion/create.
  payload: The body of the request, or None to send an empty request.
  content_type: The Content-Type header to use.
  timeout: timeout in seconds; default None i.e. no timeout.
(Note: for large requests on OS X, the timeout doesn't work right.)
  kwargs: Any keyword arguments are converted into query string parameters.

Returns:
  The response body, as a string.

Definition at line 294 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

294  **kwargs):
295  """Sends an RPC and returns the response.
296 
297  Args:
298  request_path: The path to send the request to, eg /api/appversion/create.
299  payload: The body of the request, or None to send an empty request.
300  content_type: The Content-Type header to use.
301  timeout: timeout in seconds; default None i.e. no timeout.
302  (Note: for large requests on OS X, the timeout doesn't work right.)
303  kwargs: Any keyword arguments are converted into query string parameters.
304 
305  Returns:
306  The response body, as a string.
307  """
308  # TODO: Don't require authentication. Let the server say
309  # whether it is necessary.
310  if not self.authenticated:
311  self._Authenticate()
312 
313  old_timeout = socket.getdefaulttimeout()
314  socket.setdefaulttimeout(timeout)
315  try:
316  tries = 0
317  while True:
318  tries += 1
319  args = dict(kwargs)
320  url = "http://%s%s" % (self.host, request_path)
321  if args:
322  url += "?" + urllib.urlencode(args)
323  req = self._CreateRequest(url=url, data=payload)
324  req.add_header("Content-Type", content_type)
325  try:
326  f = self.opener.open(req)
327  response = f.read()
328  f.close()
329  return response
330  except urllib2.HTTPError, e:
331  if tries > 3:
332  raise
333  elif e.code == 401:
334  self._Authenticate()
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _Authenticate(self)
Definition: upload.py:239
def upload.AbstractRpcServer.Send (   self,
  request_path,
  payload = None,
  content_type = "application/octet-stream",
  timeout = None,
  kwargs 
)
Sends an RPC and returns the response.

Args:
  request_path: The path to send the request to, eg /api/appversion/create.
  payload: The body of the request, or None to send an empty request.
  content_type: The Content-Type header to use.
  timeout: timeout in seconds; default None i.e. no timeout.
(Note: for large requests on OS X, the timeout doesn't work right.)
  kwargs: Any keyword arguments are converted into query string parameters.

Returns:
  The response body, as a string.

Definition at line 294 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

294  **kwargs):
295  """Sends an RPC and returns the response.
296 
297  Args:
298  request_path: The path to send the request to, eg /api/appversion/create.
299  payload: The body of the request, or None to send an empty request.
300  content_type: The Content-Type header to use.
301  timeout: timeout in seconds; default None i.e. no timeout.
302  (Note: for large requests on OS X, the timeout doesn't work right.)
303  kwargs: Any keyword arguments are converted into query string parameters.
304 
305  Returns:
306  The response body, as a string.
307  """
308  # TODO: Don't require authentication. Let the server say
309  # whether it is necessary.
310  if not self.authenticated:
311  self._Authenticate()
312 
313  old_timeout = socket.getdefaulttimeout()
314  socket.setdefaulttimeout(timeout)
315  try:
316  tries = 0
317  while True:
318  tries += 1
319  args = dict(kwargs)
320  url = "http://%s%s" % (self.host, request_path)
321  if args:
322  url += "?" + urllib.urlencode(args)
323  req = self._CreateRequest(url=url, data=payload)
324  req.add_header("Content-Type", content_type)
325  try:
326  f = self.opener.open(req)
327  response = f.read()
328  f.close()
329  return response
330  except urllib2.HTTPError, e:
331  if tries > 3:
332  raise
333  elif e.code == 401:
334  self._Authenticate()
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _Authenticate(self)
Definition: upload.py:239
def upload.AbstractRpcServer.Send (   self,
  request_path,
  payload = None,
  content_type = "application/octet-stream",
  timeout = None,
  kwargs 
)
Sends an RPC and returns the response.

Args:
  request_path: The path to send the request to, eg /api/appversion/create.
  payload: The body of the request, or None to send an empty request.
  content_type: The Content-Type header to use.
  timeout: timeout in seconds; default None i.e. no timeout.
(Note: for large requests on OS X, the timeout doesn't work right.)
  kwargs: Any keyword arguments are converted into query string parameters.

Returns:
  The response body, as a string.

Definition at line 294 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

294  **kwargs):
295  """Sends an RPC and returns the response.
296 
297  Args:
298  request_path: The path to send the request to, eg /api/appversion/create.
299  payload: The body of the request, or None to send an empty request.
300  content_type: The Content-Type header to use.
301  timeout: timeout in seconds; default None i.e. no timeout.
302  (Note: for large requests on OS X, the timeout doesn't work right.)
303  kwargs: Any keyword arguments are converted into query string parameters.
304 
305  Returns:
306  The response body, as a string.
307  """
308  # TODO: Don't require authentication. Let the server say
309  # whether it is necessary.
310  if not self.authenticated:
311  self._Authenticate()
312 
313  old_timeout = socket.getdefaulttimeout()
314  socket.setdefaulttimeout(timeout)
315  try:
316  tries = 0
317  while True:
318  tries += 1
319  args = dict(kwargs)
320  url = "http://%s%s" % (self.host, request_path)
321  if args:
322  url += "?" + urllib.urlencode(args)
323  req = self._CreateRequest(url=url, data=payload)
324  req.add_header("Content-Type", content_type)
325  try:
326  f = self.opener.open(req)
327  response = f.read()
328  f.close()
329  return response
330  except urllib2.HTTPError, e:
331  if tries > 3:
332  raise
333  elif e.code == 401:
334  self._Authenticate()
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _Authenticate(self)
Definition: upload.py:239
def upload.AbstractRpcServer.Send (   self,
  request_path,
  payload = None,
  content_type = "application/octet-stream",
  timeout = None,
  kwargs 
)
Sends an RPC and returns the response.

Args:
  request_path: The path to send the request to, eg /api/appversion/create.
  payload: The body of the request, or None to send an empty request.
  content_type: The Content-Type header to use.
  timeout: timeout in seconds; default None i.e. no timeout.
(Note: for large requests on OS X, the timeout doesn't work right.)
  kwargs: Any keyword arguments are converted into query string parameters.

Returns:
  The response body, as a string.

Definition at line 294 of file upload.py.

References upload.AbstractRpcServer._Authenticate(), upload.AbstractRpcServer._CreateRequest(), upload.AbstractRpcServer.authenticated, and upload.AbstractRpcServer.host.

294  **kwargs):
295  """Sends an RPC and returns the response.
296 
297  Args:
298  request_path: The path to send the request to, eg /api/appversion/create.
299  payload: The body of the request, or None to send an empty request.
300  content_type: The Content-Type header to use.
301  timeout: timeout in seconds; default None i.e. no timeout.
302  (Note: for large requests on OS X, the timeout doesn't work right.)
303  kwargs: Any keyword arguments are converted into query string parameters.
304 
305  Returns:
306  The response body, as a string.
307  """
308  # TODO: Don't require authentication. Let the server say
309  # whether it is necessary.
310  if not self.authenticated:
311  self._Authenticate()
312 
313  old_timeout = socket.getdefaulttimeout()
314  socket.setdefaulttimeout(timeout)
315  try:
316  tries = 0
317  while True:
318  tries += 1
319  args = dict(kwargs)
320  url = "http://%s%s" % (self.host, request_path)
321  if args:
322  url += "?" + urllib.urlencode(args)
323  req = self._CreateRequest(url=url, data=payload)
324  req.add_header("Content-Type", content_type)
325  try:
326  f = self.opener.open(req)
327  response = f.read()
328  f.close()
329  return response
330  except urllib2.HTTPError, e:
331  if tries > 3:
332  raise
333  elif e.code == 401:
334  self._Authenticate()
def _CreateRequest(self, url, data=None)
Definition: upload.py:162
def _Authenticate(self)
Definition: upload.py:239

Member Data Documentation

upload.AbstractRpcServer.auth_function
upload.AbstractRpcServer.extra_headers

Definition at line 146 of file upload.py.

Referenced by upload.AbstractRpcServer.__init__().

upload.AbstractRpcServer.host
upload.AbstractRpcServer.host_override
upload.AbstractRpcServer.opener

Definition at line 148 of file upload.py.

Referenced by upload.AbstractRpcServer.__init__().

upload.AbstractRpcServer.save_cookies

The documentation for this class was generated from the following file: