Koulio / rietveld

Automatically exported from code.google.com/p/rietveld
Apache License 2.0
0 stars 0 forks source link

upload.py fails with 302 #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is Rietveld instance hosted on Google Apps. Let's say the server is
cr.mycorp.com. We have svn+ssh://svn.mycorp.com repository but for the sake
of Rietveld I had to configure it with a dummy http://svn.mycorp.com
repository link (since it insists on having it).

I do:
python ${path-to-upload}/upload.py -s cr.mycorp.com -e me@mycorp.com -r
reviewer@mycorp.com

I get:

Traceback (most recent call last):
  File "/Users/kkowalczyk/.bin/upload.py", line 1387, in <module>
    main()
  File "/Users/kkowalczyk/.bin/upload.py", line 1379, in main
    RealMain(sys.argv)
  File "/Users/kkowalczyk/.bin/upload.py", line 1347, in RealMain
    response_body = rpc_server.Send("/upload", body, content_type=ctype)
  File "/Users/kkowalczyk/.bin/upload.py", line 326, in Send
    f = self.opener.open(req)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 380, in open
    response = meth(req, response)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 491, in http_response
    'http', request, response, code, msg, hdrs)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 418, in error
    return self._call_chain(*args)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 353, in _call_chain
    result = func(*args)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 499, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 302: Found

Note: it might or might not matter but DNS CNAME mapping of cr.mycorp.com
to ghs.google.com isn't set up yet (as per instructions of setting this app
with Google Apps account) so I have a local over-ride in my /etc/hosts on
my mac:

209.85.171.121 cr.mycorp.com

(209.85.171.121 is ghs.google.com).

I can access cr.mycorp.com through the web and submit diffs through web
interface but previewing such diffs in web ui doesn't work due to lack of
svn+ssh support repositories (see issue 80)

upload.py was downloaded yesterday from
http://codereview.appspot.com/static/upload.py

Original issue reported on code.google.com by kkowalczyk@gmail.com on 3 Feb 2009 at 7:18

GoogleCodeExporter commented 9 years ago
I just finished the DNS setup and it didn't change anything.

I've ran with --noise but there was no useful information related to upload 
process 
(although I can upload the output if that would help).

Original comment by kkowalczyk@gmail.com on 3 Feb 2009 at 7:50

GoogleCodeExporter commented 9 years ago
More information: I fixed this particular problem by adding RedirectHandler:

    opener.add_handler(urllib2.HTTPRedirectHandler())

However, it still doesn't work, probably due to auth problems. upload.py asks 
me 3
times for a password. I enter my Google Apps password and it says "Invalid 
username
or password" twice but silently accepts (invalid?) password the third time.

I no longer get any error but my diff is not uploaded to the server.

I tried giving both "-e me" and "-e me@mycorp.com" to upload.py, but it fails 
in both
cases.

I can login to web ui using that e-mail/password in the browser.

Original comment by kkowalczyk@gmail.com on 3 Feb 2009 at 11:06

GoogleCodeExporter commented 9 years ago
Apparently user error.

I was using http://codereview.appspot.com/static/upload.py while apparently with
account hosted with Google Apps, I have to download upload.py from my domain. 
Once I
did that, it worked.

I don't think it's clearly documented anywhere, so it would be nice to add 
explicit
note to wiki about this gotcha.

Even better would be if http://codereview.appspot.com/static/upload.py would 
detect
it's being used against Google Apps account and print a note that a user needs
account-specific upload.py

Silently accepting invalid password after third attempt in upload.py is 
probably a
valid bug (it should just exit at that point with relevant error message)

Original comment by kkowalczyk@gmail.com on 3 Feb 2009 at 11:43

GoogleCodeExporter commented 9 years ago
I appear to have your problem (fail on 302). However, it did infact work 
perfectly 
fine earlier and downloading it from wherever doesn't do anything to help.

Considering that 302 is a temporary redirection, I'm somewhat baffled by the 
fact 
that it does fail... Just to be sure I tried running it on both python 2.5.1 
(OSX 
10.5 default) and 2.6.1, but that again changed nothing (aside from giving a 
deprication warning)

Original comment by L7xLo...@gmail.com on 4 Feb 2009 at 1:47

GoogleCodeExporter commented 9 years ago
Hello, 

After adding the suggested line: 
opener.add_handler(urllib2.HTTPRedirectHandler())
and providing the correct password, I got 'connection refused' error instead of 
302.
I'm using Leopard + python 2.5.1 and my repository is svn+ssh too. Also, I'm 
trying
to use the Rietveld instance on Google Apps.    

The traceback follows:

Traceback (most recent call last):
  File "./upload.py", line 1339, in <module>
    main()
  File "./upload.py", line 1331, in main
    RealMain(sys.argv)
  File "./upload.py", line 1300, in RealMain
    response_body = rpc_server.Send("/upload", body, content_type=ctype)
  File "./upload.py", line 280, in Send
    self._Authenticate()
  File "./upload.py", line 318, in _Authenticate
    super(HttpRpcServer, self)._Authenticate()
  File "./upload.py", line 257, in _Authenticate
    self._GetAuthCookie(auth_token)
  File "./upload.py", line 199, in _GetAuthCookie
    response = self.opener.open(req)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 380, in open
    response = meth(req, response)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 491, in http_response
    'http', request, response, code, msg, hdrs)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 412, in error
    result = self._call_chain(*args)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 353, in _call_chain
    result = func(*args)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 575, in http_error_302
    return self.parent.open(new)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 374, in open
    response = self._open(req, data)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 392, in _open
    '_open', req)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 353, in _call_chain
    result = func(*args)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 1100, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.
py",
line 1075, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error (61, 'Connection refused')>

Original comment by germog...@gmail.com on 14 Feb 2009 at 12:56

GoogleCodeExporter commented 9 years ago
When you get 302, try deleting ~/.codereview_upload_cookies. I found that I 
often get
302 and that deleting saved auth info is often needed. Still seems like a bug in
upload.py, but that's the workaround.

Original comment by kkowalczyk@gmail.com on 14 Feb 2009 at 1:21

GoogleCodeExporter commented 9 years ago
Ah, that was it, thanks! :D

Original comment by L7xLo...@gmail.com on 16 Feb 2009 at 6:04

GoogleCodeExporter commented 9 years ago

Original comment by gvanrossum@gmail.com on 16 Feb 2009 at 3:35

GoogleCodeExporter commented 9 years ago
This bit me too. The problem was that I had used codereview on a different 
hosted app domain and i think 
upload just used my email from the other hosted app. i deleted the cookies file 
and it started asking for my 
email where it didn't before.

i'm not so sure about the invalid status here.

Original comment by moweitz...@gmail.com on 12 Jun 2009 at 8:15

GoogleCodeExporter commented 9 years ago
I see your point.  Can you come up with a fix?

Original comment by gvanrossum@gmail.com on 12 Jun 2009 at 8:30

GoogleCodeExporter commented 9 years ago
The attached patch (by James Willcox) fixes the problem for us.

Original comment by canan...@gmail.com on 5 Aug 2009 at 3:00

Attachments:

GoogleCodeExporter commented 9 years ago
Ok, submitted (r432) and made live.  Thanks!

Original comment by gvanrossum@gmail.com on 5 Aug 2009 at 4:48