def execute(request, test_case): try: handle = urllib2.urlopen(request) response = handle.read() if not FlickrApi.isSuccessfulResponse(response): print test_case + " failed" print response return None else: print test_case + " success" return response except urllib2.HTTPError as e: print e.read() raise
from gi.repository import Gio, Gtk, GObject, Gdk, Pango, GLib import dbus import imtools import gettext import subprocess import tempfile import commands flickr = Gtk.Dialog() flickr.set_title"Add Flickr Source") flickr.value = Gtk.Entry() flickr.label = Gtk.Label("Author's url: ") flickr.box = Gtk.HBox() flickr.box.pack_start(flickr.label, False, 0, 5,) flickr.box.pack_start(flickr.value, False, 0, 5,) flickr.get_content_area().pack_start(flickr.box, False, 0 ,5) flickr.show_all() flickr.add_buttons(Gtk.STOCK_OK, Gtk.ResponseType.OK, Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE) res = flickr.run() if res == Gtk.ResponseType.OK: user = FlickrApi.get_user_from_url(flickr.value.get_text()) if user is not None: Popen(["./flickrapi.py", 'author', 'photos', user['user_id']]) path = FlickrApi.path + FlickrApi.service + "/" + user['user_name'] else: print("User not found!") flickr.hide() else: flickr.hide() print ("ERROR")