Graphical option for setting a proxy

Bug #1248672 reported by Danial Behzadi
44
This bug affects 9 people
Affects Status Importance Assigned to Milestone
Variety
Triaged
Wishlist
Unassigned

Bug Description

Hey,
Unfortunately many of wallpaper websites are banned in countries like Iran, China, etc. and people connect to them via proxies. It would result in variety's disability in downloading wallpaper from those sites like flickr and wallbase. If there were an option to download wallpapers via proxy, tis problem would be solved.

Tags: proxy
Revision history for this message
Peter Levi (peterlevi) wrote :

Variety works with Ubuntu's global proxy setting (it needs restarting after you change this setting). Also, if you set HTTP_PROXY variable, it will use it - for example, run it with:
HTTP_PROXY=10.10.10.10 /opt/extras.ubuntu.com/variety/bin/variety -v
Replace 10.10.10.10 with the IP of a proxy server you'd like to use.

Revision history for this message
Danial Behzadi (dani.behzi) wrote :

I know that, but it would be great if there was a graphical, in app tab for proxy, because many people use variety in startup and don't want to bypass all the Ubuntu traffic to the proxy.

Peter Levi (peterlevi)
Changed in variety:
importance: Undecided → Wishlist
summary: - [wishlist] Option for downloading wallpapers through proxy
+ Graphical option for setting a proxy
Revision history for this message
Atit Anand (atit-anand-cs) wrote :

HIi Peter. I am really interested on working on this. Can I go forward with it?

Revision history for this message
Peter Levi (peterlevi) wrote :

@atit-anand-cs:

Let's first investigate some more the necessity for this and the proper way to do it.

I am definitely not a fan of duplicating existing working functionality. The fact that a major browser like Chrome does not provide separate proxy settings, but redirects to Ubuntu's default Settings/Network/Proxy settings makes me very reluctant to implement our own proxy settings. So we will have our own GUI for this only if we are absolutely certain we need one.

The very first step is to make sure Variety adheres and uses Ubuntu's manual proxy settings, and preferably takes changes to them into account immediately. This also includes checking why when launched on startup Variety does not honor these global settings and how this can be fixed.

Daniel says that many people might want to redirect only Variety's traffic trough a proxy, not all of the traffic. This is possible to achieve using an automatic proxy configuration: http://en.wikipedia.org/wiki/Proxy_auto-config, combined with this Python library: https://code.google.com/p/pacparser/. This needs to be evaluated - is the library available in Universe repository of both 12.04 and 14.04, does it work OK. Also, is it easy to get the URL of the configured PAC in Ubuntu's proxy's settings, etc. If this can work, we would just need to provide an out-of-the box PAC file that people can use and instruct them to edit it in order to change the proxy servers.

How does this plan sound to you?

Revision history for this message
Peter Levi (peterlevi) wrote :

For everybody who needs to set a proxy right now, try this (based on: http://askubuntu.com/questions/144968/set-variable-in-desktop-file):

cp /usr/share/applications/extras-variety.desktop ~/.local/share/applications/
gedit ~/.local/share/applications/extras-variety.desktop

Find the line
Exec=/opt/extras.ubuntu.com/variety/bin/variety %U

and change it to:
Exec=env HTTP_PROXY=1.1.1.1 HTTPS_PROXY=1.1.1.1 /opt/extras.ubuntu.com/variety/bin/variety %U

Change the IPs above to point to the correct proxies. Save.

Make the same change to the Exec line in ~/.config/autostart/variety.desktop

This should ensure that Variety runs with the proper proxies set regardless of the time it is launched. Please report on your success here.

Revision history for this message
Atit Anand (atit-anand-cs) wrote :

@Peter The plan seems alright to me. But I was really wondering about one thing. Don't you think modifying PAC file would not be so user friendly and intuitive?

As soon as ubuntu's manual proxy setting changes, we need to take it into account immediately. I guess this would be little difficult to implement.

Revision history for this message
Peter Levi (peterlevi) wrote :

@Atit
If it is not intuitive enough, we may eventually provide an editing tool, or a webservice for this, or do it from inside Variety's GUI.
The benefit is that when proxies are configured this way, the wallpaper sites will work everywhere - in Variety and in the browser. Otherwise we'll have Variety working and when you click "View at Wallbase.cc/Flickr/whatever" you get no connection.

But leave the PAC thing alone for now. In the end it might end up easier to be able to simply set a proxy specifically for Variety, but this does not relieve us from fallbacking to the global proxy setting when the user decides he wants to use it. So the most immediate task here is to try and make Variety work live with the currently configured global proxy.

The way I would do this is this:
1. Check how from Python to get the manual proxy configuration for HTTP, HTTPS from Ubuntu's settings. It must be some gconf call or something.
2. Check where Variety makes requests - most of these end up calling Util.urlopen in the end, maybe there are a couple of more places (FacebookHelper was using Curl for some reason)
3. Change those few "core" places like Util.urlopen to query what the current proxy is (if any) and use the appropriate proxy for the request (http vs https).

I.e. there is no need to listen for change events here, just use whatever the current proxy is when you need it.

Revision history for this message
Peter Levi (peterlevi) wrote :

And, of course - avoid copy/paste code duplication please - if you have several places that need to obtain the current proxy, you need a function in Util for this.

Revision history for this message
Atit Anand (atit-anand-cs) wrote :

@Peter So you mean I should start working on this according to the points you stated right?

How do I see the changes that I made to codebase in variety? Do I have to install again from source to see the changes that I made to codebase appear in variety?

Revision history for this message
Peter Levi (peterlevi) wrote :

How much professional programming experience do you have? If you are not familiar with version control systems, specifically distributed VSC systems like bzr and git, this is your first step.

More specifically: you gotta get yourself familiar with Bazaar. You need to create a branch of Variety's trunk (bzr help branch, bzr branch lp:variety ./variety-proxy), you then code inside your branch, to run it you need the dependencies installed (you should have them if Variety is already running on your machine) and simply call bin/variety from inside the branch directory. After you create the branch, you need to push it to Launchpad (bzr push, and I think it will ask to specify some remote name). When finishing small self-contained pieces of changes, you commit with "bzr commit -m <commit msg>", and push with "bzr push" so the changes are pushed to Launchpad where I can monitor your progress. At some point, when you think you are ready we'll review the code and then merge it into the main trunk.

I personally recommend PyCharm for coding in Python (but it provides no Bazaar integration). Code style: 4 spaces indentation, no tabs.

Revision history for this message
Atit Anand (atit-anand-cs) wrote :

@Peter Thanks for replying back. I haven't done much open source contributions. I have fixed 2 bugs for https://launchpad.net/gtg . I am familiar with bzr and git. Thanks for the recommendation. Hopefully I start working on this soon and will let you know.

James Lu (jlu5)
Changed in variety:
status: New → Triaged
Revision history for this message
Pro (proturm) wrote :

Hi,
how is the current status on using variety with a proxy? The above proposal didnt work for me.

Revision history for this message
Pro (proturm) wrote :

export http_proxy=proxy:port
export https_proxy=proxy:port
sudo -E variety
Traceback (most recent call last):
  File "/usr/bin/variety", line 39, in <module>
    variety.main()
  File "/usr/lib/python2.7/dist-packages/variety/__init__.py", line 197, in main
    bus = dbus.SessionBus()
  File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 211, in __new__
    mainloop=mainloop)
  File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 100, in __new__
    bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
  File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 122, in __new__
    bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

Revision history for this message
Pro (proturm) wrote :

HTTP_PROXY vs http_proxy (with capital letters worked)

Revision history for this message
James Lu (jlu5) wrote :

Please don't run Variety as root. Run it as your regular user instead.

Revision history for this message
hamidi (hamidi) wrote :

I use a socks 5 proxy to connect to the filtered urls. So specifying a http or https proxy can't help. Besides, I'm not going to pass all the traffics via the proxy server, because it's not required and it'll get slow. You referred to Google Chrome as an example. It's not a good example. Why don't you refer to Firefox or Telegram instead? Regardless of the whole system settings, it's a good idea to have particular settings for different applications inside them. Maybe I need to set different proxy servers for the applications. I persist the goodness of such an option for the Variety and will be glad if you prepare for it.
Thank you
A poor man from Iran!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.