def _download_user_icon_with_callback(self, gui, entry): icon_uri = str(entry['image_uri']) icon = tempfile.NamedTemporaryFile() urlget = UrlGetWithAutoProxy(icon_uri) d = urlget.downloadPage(icon_uri, icon.name) d.addCallback(self._run, gui, entry, icon).addErrback(self._on_error)
def notify(self, entry, api): icon_uri = str(entry['image_uri']) entry.update({'source': api.account.source, 'user_account': api.account.user_name}) urlget = UrlGetWithAutoProxy(icon_uri) self.icon_file = os.path.join(ICON_CACHE_HOME, CACHE_PREFIX+entry['user_name']+'.jpg') d = urlget.downloadPage(icon_uri, self.icon_file) d.addCallback(self._notify, entry).addErrback(self._error, entry)
def notify(self, entry, api): icon_uri = str(entry['image_uri']) entry.update({ 'source': api.account.source, 'user_account': api.account.user_name }) urlget = UrlGetWithAutoProxy(icon_uri) self.icon_file = os.path.join( ICON_CACHE_HOME, CACHE_PREFIX + entry['user_name'] + '.jpg') d = urlget.downloadPage(icon_uri, self.icon_file) d.addCallback(self._notify, entry).addErrback(self._error, entry)
def set_profile(self, entry): label_name = self.gui.get_object("label_name") label_name.set_label("<b><big>%s</big></b>" % entry.get("name")) label_screen_name = self.gui.get_object("label_screen_name") label_screen_name.set_label("@" + entry.get("screen_name")) description = "" if entry.get("description"): entities = entry.get("entities")["description"] description = self._convert(entry["description"], entities) self._set_label("label_description", description) location = "" if entry.get("location"): location += entry.get("location") if entry.get("url"): location += " · " if entry.get("url"): url = entry["entities"]["url"]["urls"][0] location += '<a href="%s">%s</a>' % ( url.get("expanded_url") or url.get("url"), url.get("display_url") or url.get("url"), ) self._set_label("label_location", location) dic = { "count_tweets": entry["statuses_count"], "count_following": entry["friends_count"], "count_followers": entry["followers_count"], } for label, text in dic.items(): self.gui.get_object(label).set_label(str(text)) self.widget.show() icon_uri = str(entry["profile_image_url"]).replace("_normal.", "_bigger.") icon_file = os.path.join(CACHE_HOME, "profile_icon.jpg") urlget = UrlGetWithAutoProxy(icon_uri) d = urlget.downloadPage(icon_uri, icon_file) d.addCallback(self._set_profile_icon, icon_file)
def set_profile(self, entry): label_name = self.gui.get_object('label_name') label_name.set_label('<b><big>%s</big></b>' % entry.get('name')) label_screen_name = self.gui.get_object('label_screen_name') label_screen_name.set_label("@"+entry.get('screen_name')) description = '' if entry.get('description'): entities = entry.get('entities')['description'] description = self._convert(entry['description'], entities) self._set_label('label_description', description) location = '' if entry.get('location'): location += entry.get('location') if entry.get('url'): location += ' · ' if entry.get('url'): url = entry['entities']['url']['urls'][0] location += '<a href="%s">%s</a>' % ( url.get('expanded_url') or url.get('url'), url.get('display_url') or url.get('url')) self._set_label('label_location', location) dic = {'count_tweets': entry['statuses_count'], 'count_following': entry['friends_count'], 'count_followers': entry['followers_count']} for label, text in dic.items(): self.gui.get_object(label).set_label(str(text)) self.widget.show() icon_uri = str(entry['profile_image_url']).replace('_normal.', '_bigger.') icon_file = os.path.join(CACHE_HOME, 'profile_icon.jpg') urlget = UrlGetWithAutoProxy(icon_uri) d = urlget.downloadPage(icon_uri, icon_file) d.addCallback(self._set_profile_icon, icon_file)