Exemplo n.º 1
0
 def __init__ (self,
               domain="twitter.com",
               update_url=TWITTER_UPDATE_URL,
               realm="Twitter API",
               extra_widget_factory=None):
     self._account = Account (domain, realm)
     self._opener = MateURLopener (self._account,
                                    extra_widget_factory=extra_widget_factory)
     self._thread = None
     self._update_url = update_url
     self._domain = domain
Exemplo n.º 2
0
class TwitterClient :
    """
    Client capable of talking to a twitter-like API.
    
    Note on proxies: The URLopener used here will not reflect changes done
                     to the Mate proxy configuration. Therefore preferably
                     use the TwitterClientFactory and create a new TwitterClient
                     instance each time you need it
    """
    def __init__ (self,
                  domain="twitter.com",
                  update_url=TWITTER_UPDATE_URL,
                  realm="Twitter API",
                  extra_widget_factory=None):
        self._account = Account (domain, realm)
        self._opener = MateURLopener (self._account,
                                       extra_widget_factory=extra_widget_factory)
        self._thread = None
        self._update_url = update_url
        self._domain = domain
        
    def update (self, msg):
        try:
            post_payload = urllib.urlencode({"status" : msg, "source" : "deskbar"})
            self._opener.open_async (self._update_url, post_payload, self._on_opener_done)
        except ConcurrentRequestsException :
            LOGGER.warning ("Attempting to post while another post is already running. Ignoring")
            error = gtk.MessageDialog (None,
                                       type=gtk.MESSAGE_WARNING,
                                       buttons=gtk.BUTTONS_OK)
            error.set_markup (_("A post is already awaiting submission; please wait before you post another message"))
            error.set_title (_("Error posting to %s" % self._domain))
            error.show_all()
            error.run()
            error.destroy()
            return
            
    def _on_opener_done (self, opener, info):
        LOGGER.debug ("Got reply from %s. Success: %s" % (self._update_url, self._opener.get_success()))
        if not self._opener.get_success() :
            error = gtk.MessageDialog (None,
                                       type=gtk.MESSAGE_WARNING,
                                       buttons=gtk.BUTTONS_OK)
            error.set_markup (_FAIL_POST % {"domain" : self._domain})
            error.set_title (_("Error posting to %s" % self._domain))
            error.show_all()
            error.run()
            error.destroy()
Exemplo n.º 3
0
 def __init__(
     self, domain="twitter.com", update_url=TWITTER_UPDATE_URL, realm="Twitter API", extra_widget_factory=None
 ):
     self._account = Account(domain, realm)
     self._opener = MateURLopener(self._account, extra_widget_factory=extra_widget_factory)
     self._thread = None
     self._update_url = update_url
     self._domain = domain
Exemplo n.º 4
0
class TwitterClient:
    """
    Client capable of talking to a twitter-like API.
    
    Note on proxies: The URLopener used here will not reflect changes done
                     to the Mate proxy configuration. Therefore preferably
                     use the TwitterClientFactory and create a new TwitterClient
                     instance each time you need it
    """

    def __init__(
        self, domain="twitter.com", update_url=TWITTER_UPDATE_URL, realm="Twitter API", extra_widget_factory=None
    ):
        self._account = Account(domain, realm)
        self._opener = MateURLopener(self._account, extra_widget_factory=extra_widget_factory)
        self._thread = None
        self._update_url = update_url
        self._domain = domain

    def update(self, msg):
        try:
            post_payload = urllib.urlencode({"status": msg, "source": "deskbar"})
            self._opener.open_async(self._update_url, post_payload, self._on_opener_done)
        except ConcurrentRequestsException:
            LOGGER.warning("Attempting to post while another post is already running. Ignoring")
            error = gtk.MessageDialog(None, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK)
            error.set_markup(_("A post is already awaiting submission; please wait before you post another message"))
            error.set_title(_("Error posting to %s" % self._domain))
            error.show_all()
            error.run()
            error.destroy()
            return

    def _on_opener_done(self, opener, info):
        LOGGER.debug("Got reply from %s. Success: %s" % (self._update_url, self._opener.get_success()))
        if not self._opener.get_success():
            error = gtk.MessageDialog(None, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK)
            error.set_markup(_FAIL_POST % {"domain": self._domain})
            error.set_title(_("Error posting to %s" % self._domain))
            error.show_all()
            error.run()
            error.destroy()