My 2 cents.

Modifying the registry and then restoring is not a great idea. I can see 
why you are doing it but I'd encourage you to NOT do this. There is a 
potential here for a background web app to fail (e.g. web browser based 
IM tool).

I'd be tempted to monkey patch urllib(2), presumably that is the beast 
causing the issue here if you want a quick solution. Either monkey patch 
urllib OR monkey patch _winreg lookup that urllib relies on.

As the "real" Chris said, improving postreview and getting the code into 
the main git repo is the ideal solution here. You may be the first to 
hit this but you are not going to be the last :-) so it it would be good 
to get a more robust solution.

Chris

Christian Hammond wrote:
> Yeah, modifying postreview.py isn't ideal. It was just one suggestion. 
> What I'd like to see, I think, is an optional configuration variable 
> in the user's .reviewboardrc that allows users to control 
> post-review's proxy settings manually.
>
> Christian
>
> -- 
> Christian Hammond - chip...@chipx86.com <mailto:chip...@chipx86.com>
> Review Board - http://www.reviewboard.org
> VMware, Inc. - http://www.vmware.com
>
>
> On Wed, Dec 2, 2009 at 11:42 AM, Akhilesh <akhileshjo...@gmail.com 
> <mailto:akhileshjo...@gmail.com>> wrote:
>
>     thanks Christian for suggestion. I thought if I modify postreview.py
>     then it will be difficult for me to roll out official updates to
>     individual users.
>     I did a workaround. Wrote following wrapper script to disable/enable
>     proxy. It's dirty but serves my purpose:
>
>     import _winreg, os, sys
>
>     if len(sys.argv) != 2:
>        print "Usage: rr ChangeListId"
>        sys.exit(0)
>
>     root = _winreg.HKEY_CURRENT_USER
>     keypath = "Software\Microsoft\Windows\CurrentVersion\Internet
>     Settings"
>     value_name = "ProxyEnable"
>     hKey = _winreg.OpenKey (root, keypath, 0, _winreg.KEY_READ |
>     _winreg.KEY_SET_VALUE)
>
>     existingValue, type = _winreg.QueryValueEx (hKey, value_name)
>     #Disable Proxy setting if ON.
>     if existingValue == 1:
>        _winreg.SetValueEx (hKey, value_name, 0, _winreg.REG_DWORD, 0)
>
>     # Call post-review.exe
>     command = "post-review " + sys.argv[1]
>     os.system(command)
>
>     # If original setting was PROXY ON then turn it ON.
>     if existingValue == 1:
>        _winreg.SetValueEx (hKey, value_name, 0, _winreg.REG_DWORD, 1)
>     _winreg.CloseKey(hKey)
>
>
>
>
>
>     On Nov 24, 4:45 pm, Christian Hammond <chip...@chipx86.com
>     <mailto:chip...@chipx86.com>> wrote:
>     > Is the Review Board server on HTTP or HTTPS?
>     >
>     > It sounds like custom code would need to be added to
>     specifically disable
>     > the proxy server. It's also possible that a 2.6 release would
>     fix this
>     > issue, but I don't know.
>     >
>     > If you were to modify postreview.py , you could try adding some
>     code like:
>     >
>     > proxy_support = urllib2.ProxyHandler({})
>     > opener = urllib2.build_opener(proxy_support)
>     > urllib2.install_opener(opener)
>     >
>     > in ReviewBoardServer.__init__ probably at the end.
>     >
>     > Christian
>     >
>     > --
>     > Christian Hammond - chip...@chipx86.com <mailto:chip...@chipx86.com>
>     > Review Board -http://www.reviewboard.org
>     > VMware, Inc. -http://www.vmware.com
>     >
>     >
>     >
>     > On Tue, Nov 24, 2009 at 4:30 PM, Akhilesh
>     <akhileshjo...@gmail.com <mailto:akhileshjo...@gmail.com>> wrote:
>     > > Thanks Christian. I tried setting http_proxy environment
>     variable to
>     > > empty string but Windows wouldn't allow me. I set it to " " (with
>     > > space) - but as expected it didn't work.
>     >
>     > > Is there any work-around? The problem is that one of the sites
>     in our
>     > > organization uses proxy and all developers from that site have to
>     > > toggle Proxy settings to access Reviewboard/Internet as
>     by-pass proxy
>     > > option is not working for them.
>     >
>     > > I appreciate any help. I'm ready to test private code for
>     post-review
>     > > as well if needed.
>     >
>     > > Regards,
>     > > Akhilesh
>     >
>     > > On Nov 24, 1:57 pm, Christian Hammond <chip...@chipx86.com
>     <mailto:chip...@chipx86.com>> wrote:
>     > > > Sadly, this is due to Python's usage of the system proxy
>     settings. I'd
>     > > have
>     > > > to see if there's anything we can do for this. On Linux, I
>     know you can
>     > > set
>     > > > the HTTP_PROXY variable to an empty string to work around
>     it, but I doubt
>     > > > that works on Windows...
>     >
>     > > > Christian
>     >
>     > > > --
>     > > > Christian Hammond - chip...@chipx86.com
>     <mailto:chip...@chipx86.com>
>     > > > Review Board -http://www.reviewboard.org
>     > > > VMware, Inc. -http://www.vmware.com
>     >
>     > > > On Tue, Nov 24, 2009 at 8:16 AM, Akhilesh
>     <akhileshjo...@gmail.com <mailto:akhileshjo...@gmail.com>>
>     > > wrote:
>     > > > > We are facing a problem where if proxy settings are enabled in
>     > > > > Internet Explorer, post-review doesn't work (Proxy Error
>     502) but I we
>     > > > > disabled proxy settings, it works perfectly. so we added
>     reviewboard
>     > > > > site under 'bypass proxy' settings ("Exceptions") but
>     still same
>     > > > > problem. It appears that post-review doesn't honor the
>     bypass proxy
>     > > > > settings. We have Python 2.5 installed.
>     >
>     > > > > Further, reviewboard site is accessible using Internet
>     Explorer
>     > > > > whether proxy settings are on/off.
>     >
>     > > > > Here is trace of the error that we get from post-review -
>     I see the
>     > > > > error returned by Proxy. Point is that we want to bypass
>     the proxy but
>     > > > > that setting in IE is not honored. any ideas?
>     >
>     > > > >      <UL class=adminList>
>     > > > >        <LI id=L_10060_11>Error Code 10060: Connection timeout
>     > > > > <LI id=L_10060_12>Background: The gateway could not
>     receive a timely
>     > > > > response fr
>     > > > > om the website you are trying to access. This might
>     indicate that the
>     > > > > network is
>     > > > >  congested, or that the website is experiencing technical
>     > > > > difficulties.
>     > > > > <LI id=L_10060_13>Date: 11/16/2009 9:44:32 PM
>     > > > > <LI id=L_10060_14>Server: Server.Company.Com
>     <http://Server.Company.Com> <<==Replaced
>     > > > > <LI id=L_10060_15>Source: Firewall
>     > > > >      </UL>
>     > > > >    </TD>
>     > > > >  </TR>
>     > > > >  </TBODY>
>     > > > > </TABLE>
>     > > > > </BODY>
>     > > > > </HTML>
>     >
>     > > > > Unable to accesshttp://10.0.3.83/api/json/accounts/login/
>     <http://10.0.3.83/api/json/accounts/login/>. The host
>     > > > > path may be
>     > > > >  invalid
>     > > > > HTTP Error 504: Proxy Timeout ( The connection timed out.
>     For more
>     > > > > information a
>     > > > > bout this event, see ISA Server Help.  )
>     >
>     > > > > --
>     > > > > Want to help the Review Board project? Donate today at
>     > > > >http://www.reviewboard.org/donate/
>     > > > > Happy user? Let us know
>     athttp://www.reviewboard.org/users/
>     <http://www.reviewboard.org/users/>
>     > > > > -~----------~----~----~----~------~----~------~--~---
>     > > > > To unsubscribe from this group, send email to
>     > > > > reviewboard+unsubscr...@googlegroups.com
>     
> <mailto:reviewboard%2bunsubscr...@googlegroups.com><reviewboard%2bunsubscr...@googlegr
>     oups.com <http://oups.com>>
>     > > <reviewboard%2bunsubscr...@googlegr oups.com <http://oups.com>>
>     > > > > For more options, visit this group at
>     > > > >http://groups.google.com/group/reviewboard?hl=en
>     >
>     > > --
>     > > Want to help the Review Board project? Donate today at
>     > >http://www.reviewboard.org/donate/
>     > > Happy user? Let us know athttp://www.reviewboard.org/users/
>     <http://www.reviewboard.org/users/>
>     > > -~----------~----~----~----~------~----~------~--~---
>     > > To unsubscribe from this group, send email to
>     > > reviewboard+unsubscr...@googlegroups.com
>     
> <mailto:reviewboard%2bunsubscr...@googlegroups.com><reviewboard%2bunsubscr...@googlegr
>     oups.com <http://oups.com>>
>     > > For more options, visit this group at
>     > >http://groups.google.com/group/reviewboard?hl=en
>
>     --
>     Want to help the Review Board project? Donate today at
>     http://www.reviewboard.org/donate/
>     Happy user? Let us know at http://www.reviewboard.org/users/
>     -~----------~----~----~----~------~----~------~--~---
>     To unsubscribe from this group, send email to
>     reviewboard+unsubscr...@googlegroups.com
>     <mailto:reviewboard%2bunsubscr...@googlegroups.com>
>     For more options, visit this group at
>     http://groups.google.com/group/reviewboard?hl=en
>
>
> -- 
> Want to help the Review Board project? Donate today at 
> http://www.reviewboard.org/donate/
> Happy user? Let us know at http://www.reviewboard.org/users/
> -~----------~----~----~----~------~----~------~--~---
> To unsubscribe from this group, send email to 
> reviewboard+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/reviewboard?hl=en 

-- 
Want to help the Review Board project? Donate today at 
http://www.reviewboard.org/donate/
Happy user? Let us know at http://www.reviewboard.org/users/
-~----------~----~----~----~------~----~------~--~---
To unsubscribe from this group, send email to 
reviewboard+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/reviewboard?hl=en

Reply via email to