From fee7254d5588dd3349936eaac78be382f4ea16df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Mon, 1 Dec 2014 15:21:25 -0600 Subject: [PATCH 1/3] Configuration for autocompletion users --- src/Conf.defaults | 2 ++ src/extra/autocompletionUsers/settings.py | 13 +++++++++++-- src/extra/autocompletionUsers/storage.py | 14 +++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/Conf.defaults b/src/Conf.defaults index 75fb4238..3c73f0ae 100644 --- a/src/Conf.defaults +++ b/src/Conf.defaults @@ -40,6 +40,8 @@ autoread_buffers = list(default=list()) [mysc] spelling_language = string(default="") +save_followers_in_autocompletion_db = boolean(default=False) +save_friends_in_autocompletion_db = boolean(default=False) [services] dropbox_token=string(default="") diff --git a/src/extra/autocompletionUsers/settings.py b/src/extra/autocompletionUsers/settings.py index 0737a121..cd19be8b 100644 --- a/src/extra/autocompletionUsers/settings.py +++ b/src/extra/autocompletionUsers/settings.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import storage import wx +import config import wx_settings import output from mysc.thread_utils import call_threaded @@ -10,20 +11,28 @@ class autocompletionSettings(object): super(autocompletionSettings, self).__init__() self.window = window self.dialog = wx_settings.autocompletionSettingsDialog() + self.dialog.friends_buffer.SetValue(config.main["mysc"]["save_friends_in_autocompletion_db"]) + self.dialog.followers_buffer.SetValue(config.main["mysc"]["save_followers_in_autocompletion_db"]) if self.dialog.ShowModal() == wx.ID_OK: call_threaded(self.add_users_to_database) def add_users_to_database(self): + config.main["mysc"]["save_friends_in_autocompletion_db"] = self.dialog.friends_buffer.GetValue() + config.main["mysc"]["save_followers_in_autocompletion_db"] = self.dialog.friends_buffer.GetValue() output.speak(_(u"Updating database... You can close this window now. A message will tell you when the process finishes.")) database = storage.storage() if self.dialog.followers_buffer.GetValue() == True: buffer = self.window.search_buffer("people", "followers") for i in buffer.db.settings[buffer.name_buffer]: - database.set_user(i["screen_name"], i["name"]) + database.set_user(i["screen_name"], i["name"], 1) + else: + database.remove_by_buffer(1) if self.dialog.friends_buffer.GetValue() == True: buffer = self.window.search_buffer("people", "friends") for i in buffer.db.settings[buffer.name_buffer]: - database.set_user(i["screen_name"], i["name"]) + database.set_user(i["screen_name"], i["name"], 2) + else: + database.remove_by_buffer(2) wx_settings.show_success_dialog() self.dialog.Destroy() \ No newline at end of file diff --git a/src/extra/autocompletionUsers/storage.py b/src/extra/autocompletionUsers/storage.py index b5eb410a..a2af1c1e 100644 --- a/src/extra/autocompletionUsers/storage.py +++ b/src/extra/autocompletionUsers/storage.py @@ -21,19 +21,27 @@ class storage(object): self.cursor.execute("""SELECT * FROM users WHERE user LIKE ?""", ('{}%'.format(term),)) return self.cursor.fetchall() - def set_user(self, screen_name, user_name): - self.cursor.execute("""insert or ignore into users values(?, ?)""", (screen_name, user_name)) + def set_user(self, screen_name, user_name, from_a_buffer): + self.cursor.execute("""insert or ignore into users values(?, ?, ?)""", (screen_name, user_name, from_a_buffer)) self.connection.commit() def remove_user(self, user): self.cursor.execute("""DELETE FROM users WHERE user = ?""", (user,)) + self.connection.commit() + return self.cursor.fetchone() + + def remove_by_buffer(self, bufferType): + """ Removes all users saved on a buffer. BufferType is 0 for no buffer, 1 for friends and 2 for followers""" + self.cursor.execute("""DELETE FROM users WHERE from_a_buffer = ?""", (bufferType,)) + self.connection.commit() return self.cursor.fetchone() def create_table(self): self.cursor.execute(""" create table users( user TEXT UNIQUE, -name TEXT +name TEXT, +from_a_buffer INTEGER )""") def __del__(self): From 79124810b01b06ccc6f066ed8ad5bd6e0e40385c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Mon, 1 Dec 2014 17:19:03 -0600 Subject: [PATCH 2/3] Reverse geocode is now in TWBlue. Ctrl+win+g and CTRL+Shift+Win+G and in the tweet menu on the menu bar --- README.md | 1 + src/Conf.defaults | 2 ++ src/gui/buffers/base.py | 2 ++ src/gui/main.py | 38 +++++++++++++++++++++++++++++++++++++ src/sounds/default/geo.mp3 | Bin 0 -> 70134 bytes src/twitter/utils.py | 4 ++++ 6 files changed, 47 insertions(+) create mode 100644 src/sounds/default/geo.mp3 diff --git a/README.md b/README.md index b4aee675..6ec78a04 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Dependencies list: * [Requests](http://www.python-requests.org/en/latest/) 2.2.1: [Recommended download site](https://pypi.python.org/pypi/requests/2.2.1) * [Requests-oauthlib](https://github.com/requests/requests-oauthlib) 0.4.0 * [Suds](https://fedorahosted.org/suds) 0.4: [Recommended download site](https://pypi.python.org/pypi/suds/0.4) +* [Pygeocoder: ](http://code.xster.net/pygeocoder/wiki/Home) You can install this dependency by using pip or easy_install. * Bootstrap 1.2.1: included in dependencies directory. Copy the bootstrap.exe file corresponding to the desired platform in the windows folder, inside this repository. This dependency has been built using pure basic 4.61. Its source can be found at http://hg.q-continuum.net/updater diff --git a/src/Conf.defaults b/src/Conf.defaults index 3c73f0ae..f70612f0 100644 --- a/src/Conf.defaults +++ b/src/Conf.defaults @@ -88,3 +88,5 @@ search = string(default="control+win+-") edit_keystrokes = string(default="control+win+k") view_user_lists = string(default="control+win+l") get_more_items = string(default="alt+win+pageup") +reverse_geocode = string(default="control+win+g") +view_reverse_geocode = string(default="control+win+shift+g") \ No newline at end of file diff --git a/src/gui/buffers/base.py b/src/gui/buffers/base.py index 2c85a5fe..acd2a35c 100644 --- a/src/gui/buffers/base.py +++ b/src/gui/buffers/base.py @@ -158,6 +158,8 @@ class basePanel(wx.Panel): self.list.list.SetString(self.list.get_selected(), " ".join(self.compose_function(self.db.settings[self.name_buffer][self.list.get_selected()], self.db))) if twitter.utils.is_audio(tweet): sound.player.play("audio.ogg", False) + if twitter.utils.is_geocoded(tweet): + sound.player.play("geo.mp3", False) def start_streams(self): if self.name_buffer == "sent": diff --git a/src/gui/main.py b/src/gui/main.py index b718ac54..bc9ede38 100644 --- a/src/gui/main.py +++ b/src/gui/main.py @@ -34,6 +34,8 @@ import urllib2 import sysTrayIcon import switchModule import languageHandler +import pygeocoder +from pygeolib import GeocoderError from sessionmanager import manager from mysc import event from mysc.thread_utils import call_threaded @@ -47,6 +49,7 @@ from extra import SoundsTutorial from keystrokeEditor import gui as keystrokeEditorGUI log = original_logger.getLogger("gui.main") +geocoder = pygeocoder.Geocoder() class mainFrame(wx.Frame): """ Main class of the Frame. This is the Main Window.""" @@ -90,6 +93,8 @@ class mainFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.unfav, unfav) view = tweet.Append(wx.NewId(), _(u"&Show tweet")) self.Bind(wx.EVT_MENU, self.view, view) + view_coordinates = tweet.Append(wx.NewId(), _(u"View &address")) + self.Bind(wx.EVT_MENU, self.reverse_geocode, view_coordinates) delete = tweet.Append(wx.NewId(), _(u"&Delete")) self.Bind(wx.EVT_MENU, self.delete, delete) @@ -976,6 +981,39 @@ class mainFrame(wx.Frame): def switch_account(self, ev): switchModule.switcher(self) + def reverse_geocode(self, event=None): + try: + if self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"] != None: + x = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][0] + y = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][1] + address = geocoder.reverse_geocode(y, x) + if event == None: output.speak(address[0].__str__().decode("utf-8")) + else: wx.MessageDialog(self, address[0].__str__().decode("utf-8"), _(u"Address"), wx.OK).ShowModal() + else: + output.speak(_(u"There are no coordinates in this tweet")) + except GeocoderError: + output.speak(_(u"There are no results for the coordinates in this tweet")) + except ValueError: + output.speak(_(u"Error decoding coordinates. Try again later.")) + except KeyError: + pass + + def view_reverse_geocode(self, event=None): + try: + if self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"] != None: + x = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][0] + y = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][1] + address = geocoder.reverse_geocode(y, x) + dialogs.message.viewNonTweet(address[0].__str__().decode("utf-8")).ShowModal() + else: + output.speak(_(u"There are no coordinates in this tweet")) + except GeocoderError: + output.speak(_(u"There are no results for the coordinates in this tweet")) + except ValueError: + output.speak(_(u"Error decoding coordinates. Try again later.")) + except KeyError: + pass + ### Close App def Destroy(self): self.sysTray.Destroy() diff --git a/src/sounds/default/geo.mp3 b/src/sounds/default/geo.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..32d2db81db2e4a7dc0c7dd7df1343e9d1a3966db GIT binary patch literal 70134 zcmeIa1yEekqNdxp2X_hX5Zp;{cXxMp4-(wnC3vug;O-LK-4a{_0YV7cL(VyOZq0o) zuijM6olD;It_s;S-Ftui{rtVwhSf-mu|oo$x7QwOs;U403P8@$(%O`im4%swnO#&- z9ssZcm^)ZntGPQUD5}T{_h8Pekdy^&wo6kIJX%0|MMLG zUvBwh1H6F^fDM2RfDM2RfDM2RfDM2RfDM2RfDM2R{Qt`U=zdlR0D$IlnTCM?0Fsz> z0Qrmnf< zSXemT=;jb>j43{&DV~*;wIT-x2M@dq!E`{{S{$giRiG&hN_--9o zS(95aPk4BBsVW{!+A^5@P3TwkEO#k!_^=P`6gfIVTF8v~rBRr6uV5)qNT z;$J+q%gd8Q>47#p`lQ>5gdaS46wo2(N`uT2w5j>yvBd10ejg-axW}uq3TV&~L^UMf zFNr629McgO>kDIPyETgpGh9IveNkalw@Eoo)fE3}w^7mA=^y?B?N3gD_=CvgRxM?2 zle=&@IBM%hKPTv!35kR)kn2@oHH8jK(>KgGeC6kyWB3k9nPXOznW>WH**TKiCNoo$ zsyc$>v`WT;Gu$#*@%o?*nF~$yuy;x@q~}FLlkmnhhos6RqH{*r4owog5w1<&(okTx z)F2og3<_*ORPzrTw*pLus|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{TzEwQLzz9uHr(khm*;-UFEOAH~t z4p*&3bQCzfI?9r$4<67@!Ak$J|gbU~uVdTD|QkMNfVl;xMcN3$gOf9F3 zhmIGVnk#qU$ZmRX;a}<-FmKqy_iJ&*Z2kjW%9!K$>QI3@{NSKyNR&xGY0sq}3YxJM z@+cJax5PfajNryp)X0#jpTXG;p0i0N2d26Q@1Gvun^JzK=Ic+cZ)aTc)2NtK@G9aJ_eIXw6vQ z#OmO!gBK$g3TfFoPDVnCDuOCKA)^vVLYJ?Ts7&J2a!bjoGAB<+_|9Qd%EPBFI7-?& z45^fm>F>alp!ClUK@>ta2gBl_dG1sHuries;(*?S2?PKdKIrzA!o#z|u;&-+dKJD& zt9&YyOQ-!DHts|f2hEd6Syr2*uY2vN=*it_7yx?S9yT81pPAUFT~_#GLr*7GCq|1c5wbYKJj>js>qb2$Ik zAN9ZI5&!BC^mB(upWk!UL;d5=xPS(^`R6YMzyNf6oc{Nm2YeK;f&WYcB;WoskN*FD z?0_ zg(d{Xdg%thQ@NL(5SZ_!8vu9cr6&aDd+7$i9eU{rf%#s#0dR+2dO~2nmu>*up_iTz znD3<<0C(u6Cj{nu=?1_Zdg%#)`ChsKaED%cLSVj^ZUEe&m!1%q@1+|6cj%=j1m=6` z2EfbZUV1`cz87xbAHz`KGbDJq+zU?%jQ3IvfTwaVH5oA1-(mpVp}!?5Fy~7(0PfIB zO$N;Mw-^9-=x<31%=uCcfIIY3lL2%6Ee60H`dg9$bG}pq;10diWWZd1ive(l{+6V` zoG;Y?xI-^B88Fx1VgTHsza=R!=SwvJUM}}ilL2%6B?kU63 Date: Tue, 2 Dec 2014 11:40:39 -0600 Subject: [PATCH 3/3] Fixing some issues with tweets and retweets --- src/gui/buffers/base.py | 9 +++++++-- src/gui/dialogs/message.py | 6 +++++- src/gui/main.py | 14 ++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/gui/buffers/base.py b/src/gui/buffers/base.py index acd2a35c..4c657987 100644 --- a/src/gui/buffers/base.py +++ b/src/gui/buffers/base.py @@ -283,10 +283,15 @@ class basePanel(wx.Panel): if self.name_buffer in config.main["other_buffers"]["autoread_buffers"]: output.speak(" ".join(tweet[:2])) + def get_tweet(self): + """ Gets a tweet or retweet.""" + if self.db.settings[self.name_buffer][self.list.get_selected()].has_key("retweeted_status"): tweet = self.db.settings[self.name_buffer][self.list.get_selected()]["retweeted_status"] + else: tweet = self.db.settings[self.name_buffer][self.list.get_selected()] + return tweet + def interact(self, ev): try: - if self.db.settings[self.name_buffer][self.list.get_selected()].has_key("retweeted_status"): tweet = self.db.settings[self.name_buffer][self.list.get_selected()]["retweeted_status"] - else: tweet = self.db.settings[self.name_buffer][self.list.get_selected()] + tweet = self.get_tweet() urls = twitter.utils.find_urls_in_text(tweet["text"]) except: urls = [] diff --git a/src/gui/dialogs/message.py b/src/gui/dialogs/message.py index c4d670b7..d18a297c 100644 --- a/src/gui/dialogs/message.py +++ b/src/gui/dialogs/message.py @@ -345,7 +345,11 @@ class viewTweet(wx.Dialog): self.SetTitle(_(u"Tweet - %i characters ") % (len(tweet["text"]))) panel = wx.Panel(self) label = wx.StaticText(panel, -1, _(u"Tweet")) - self.text = wx.TextCtrl(panel, -1, tweet["text"], style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180)) + if tweet.has_key("retweeted_status"): + text = "rt @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], tweet["retweeted_status"]["text"]) + else: + text = tweet["text"] + self.text = wx.TextCtrl(panel, -1, text, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180)) dc = wx.WindowDC(self.text) dc.SetFont(self.text.GetFont()) (x, y, z) = dc.GetMultiLineTextExtent("0"*140) diff --git a/src/gui/main.py b/src/gui/main.py index bc9ede38..374fedc4 100644 --- a/src/gui/main.py +++ b/src/gui/main.py @@ -983,9 +983,10 @@ class mainFrame(wx.Frame): def reverse_geocode(self, event=None): try: - if self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"] != None: - x = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][0] - y = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][1] + tweet = self.nb.GetCurrentPage().get_tweet() + if tweet["coordinates"] != None: + x = tweet["coordinates"]["coordinates"][0] + y = tweet["coordinates"]["coordinates"][1] address = geocoder.reverse_geocode(y, x) if event == None: output.speak(address[0].__str__().decode("utf-8")) else: wx.MessageDialog(self, address[0].__str__().decode("utf-8"), _(u"Address"), wx.OK).ShowModal() @@ -1000,9 +1001,10 @@ class mainFrame(wx.Frame): def view_reverse_geocode(self, event=None): try: - if self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"] != None: - x = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][0] - y = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][1] + tweet = self.nb.GetCurrentPage().get_tweet() + if tweet["coordinates"] != None: + x = tweet["coordinates"]["coordinates"][0] + y = tweet["coordinates"]["coordinates"][1] address = geocoder.reverse_geocode(y, x) dialogs.message.viewNonTweet(address[0].__str__().decode("utf-8")).ShowModal() else: