mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 11:48:07 -06:00
Merge branch 'master' of https://github.com/manuelcortez/TWBlue
This commit is contained in:
commit
a3fca4d2a0
@ -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](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
|
* [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)
|
* [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.
|
* 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.
|
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
|
This dependency has been built using pure basic 4.61. Its source can be found at http://hg.q-continuum.net/updater
|
||||||
|
@ -40,6 +40,8 @@ autoread_buffers = list(default=list())
|
|||||||
|
|
||||||
[mysc]
|
[mysc]
|
||||||
spelling_language = string(default="")
|
spelling_language = string(default="")
|
||||||
|
save_followers_in_autocompletion_db = boolean(default=False)
|
||||||
|
save_friends_in_autocompletion_db = boolean(default=False)
|
||||||
|
|
||||||
[services]
|
[services]
|
||||||
dropbox_token=string(default="")
|
dropbox_token=string(default="")
|
||||||
@ -86,3 +88,5 @@ search = string(default="control+win+-")
|
|||||||
edit_keystrokes = string(default="control+win+k")
|
edit_keystrokes = string(default="control+win+k")
|
||||||
view_user_lists = string(default="control+win+l")
|
view_user_lists = string(default="control+win+l")
|
||||||
get_more_items = string(default="alt+win+pageup")
|
get_more_items = string(default="alt+win+pageup")
|
||||||
|
reverse_geocode = string(default="control+win+g")
|
||||||
|
view_reverse_geocode = string(default="control+win+shift+g")
|
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import storage
|
import storage
|
||||||
import wx
|
import wx
|
||||||
|
import config
|
||||||
import wx_settings
|
import wx_settings
|
||||||
import output
|
import output
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
@ -10,20 +11,28 @@ class autocompletionSettings(object):
|
|||||||
super(autocompletionSettings, self).__init__()
|
super(autocompletionSettings, self).__init__()
|
||||||
self.window = window
|
self.window = window
|
||||||
self.dialog = wx_settings.autocompletionSettingsDialog()
|
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:
|
if self.dialog.ShowModal() == wx.ID_OK:
|
||||||
call_threaded(self.add_users_to_database)
|
call_threaded(self.add_users_to_database)
|
||||||
|
|
||||||
def add_users_to_database(self):
|
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."))
|
output.speak(_(u"Updating database... You can close this window now. A message will tell you when the process finishes."))
|
||||||
database = storage.storage()
|
database = storage.storage()
|
||||||
if self.dialog.followers_buffer.GetValue() == True:
|
if self.dialog.followers_buffer.GetValue() == True:
|
||||||
buffer = self.window.search_buffer("people", "followers")
|
buffer = self.window.search_buffer("people", "followers")
|
||||||
for i in buffer.db.settings[buffer.name_buffer]:
|
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:
|
if self.dialog.friends_buffer.GetValue() == True:
|
||||||
buffer = self.window.search_buffer("people", "friends")
|
buffer = self.window.search_buffer("people", "friends")
|
||||||
for i in buffer.db.settings[buffer.name_buffer]:
|
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()
|
wx_settings.show_success_dialog()
|
||||||
self.dialog.Destroy()
|
self.dialog.Destroy()
|
||||||
|
|
@ -21,19 +21,27 @@ class storage(object):
|
|||||||
self.cursor.execute("""SELECT * FROM users WHERE user LIKE ?""", ('{}%'.format(term),))
|
self.cursor.execute("""SELECT * FROM users WHERE user LIKE ?""", ('{}%'.format(term),))
|
||||||
return self.cursor.fetchall()
|
return self.cursor.fetchall()
|
||||||
|
|
||||||
def set_user(self, 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))
|
self.cursor.execute("""insert or ignore into users values(?, ?, ?)""", (screen_name, user_name, from_a_buffer))
|
||||||
self.connection.commit()
|
self.connection.commit()
|
||||||
|
|
||||||
def remove_user(self, user):
|
def remove_user(self, user):
|
||||||
self.cursor.execute("""DELETE FROM users WHERE user = ?""", (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()
|
return self.cursor.fetchone()
|
||||||
|
|
||||||
def create_table(self):
|
def create_table(self):
|
||||||
self.cursor.execute("""
|
self.cursor.execute("""
|
||||||
create table users(
|
create table users(
|
||||||
user TEXT UNIQUE,
|
user TEXT UNIQUE,
|
||||||
name TEXT
|
name TEXT,
|
||||||
|
from_a_buffer INTEGER
|
||||||
)""")
|
)""")
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
@ -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)))
|
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):
|
if twitter.utils.is_audio(tweet):
|
||||||
sound.player.play("audio.ogg", False)
|
sound.player.play("audio.ogg", False)
|
||||||
|
if twitter.utils.is_geocoded(tweet):
|
||||||
|
sound.player.play("geo.mp3", False)
|
||||||
|
|
||||||
def start_streams(self):
|
def start_streams(self):
|
||||||
if self.name_buffer == "sent":
|
if self.name_buffer == "sent":
|
||||||
@ -281,10 +283,15 @@ class basePanel(wx.Panel):
|
|||||||
if self.name_buffer in config.main["other_buffers"]["autoread_buffers"]:
|
if self.name_buffer in config.main["other_buffers"]["autoread_buffers"]:
|
||||||
output.speak(" ".join(tweet[:2]))
|
output.speak(" ".join(tweet[:2]))
|
||||||
|
|
||||||
def interact(self, ev):
|
def get_tweet(self):
|
||||||
try:
|
""" 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"]
|
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()]
|
else: tweet = self.db.settings[self.name_buffer][self.list.get_selected()]
|
||||||
|
return tweet
|
||||||
|
|
||||||
|
def interact(self, ev):
|
||||||
|
try:
|
||||||
|
tweet = self.get_tweet()
|
||||||
urls = twitter.utils.find_urls_in_text(tweet["text"])
|
urls = twitter.utils.find_urls_in_text(tweet["text"])
|
||||||
except:
|
except:
|
||||||
urls = []
|
urls = []
|
||||||
|
@ -345,7 +345,11 @@ class viewTweet(wx.Dialog):
|
|||||||
self.SetTitle(_(u"Tweet - %i characters ") % (len(tweet["text"])))
|
self.SetTitle(_(u"Tweet - %i characters ") % (len(tweet["text"])))
|
||||||
panel = wx.Panel(self)
|
panel = wx.Panel(self)
|
||||||
label = wx.StaticText(panel, -1, _(u"Tweet"))
|
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 = wx.WindowDC(self.text)
|
||||||
dc.SetFont(self.text.GetFont())
|
dc.SetFont(self.text.GetFont())
|
||||||
(x, y, z) = dc.GetMultiLineTextExtent("0"*140)
|
(x, y, z) = dc.GetMultiLineTextExtent("0"*140)
|
||||||
|
@ -34,6 +34,8 @@ import urllib2
|
|||||||
import sysTrayIcon
|
import sysTrayIcon
|
||||||
import switchModule
|
import switchModule
|
||||||
import languageHandler
|
import languageHandler
|
||||||
|
import pygeocoder
|
||||||
|
from pygeolib import GeocoderError
|
||||||
from sessionmanager import manager
|
from sessionmanager import manager
|
||||||
from mysc import event
|
from mysc import event
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
@ -47,6 +49,7 @@ from extra import SoundsTutorial
|
|||||||
from keystrokeEditor import gui as keystrokeEditorGUI
|
from keystrokeEditor import gui as keystrokeEditorGUI
|
||||||
log = original_logger.getLogger("gui.main")
|
log = original_logger.getLogger("gui.main")
|
||||||
|
|
||||||
|
geocoder = pygeocoder.Geocoder()
|
||||||
class mainFrame(wx.Frame):
|
class mainFrame(wx.Frame):
|
||||||
""" Main class of the Frame. This is the Main Window."""
|
""" 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)
|
self.Bind(wx.EVT_MENU, self.unfav, unfav)
|
||||||
view = tweet.Append(wx.NewId(), _(u"&Show tweet"))
|
view = tweet.Append(wx.NewId(), _(u"&Show tweet"))
|
||||||
self.Bind(wx.EVT_MENU, self.view, view)
|
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"))
|
delete = tweet.Append(wx.NewId(), _(u"&Delete"))
|
||||||
self.Bind(wx.EVT_MENU, self.delete, delete)
|
self.Bind(wx.EVT_MENU, self.delete, delete)
|
||||||
|
|
||||||
@ -976,6 +981,41 @@ class mainFrame(wx.Frame):
|
|||||||
def switch_account(self, ev):
|
def switch_account(self, ev):
|
||||||
switchModule.switcher(self)
|
switchModule.switcher(self)
|
||||||
|
|
||||||
|
def reverse_geocode(self, event=None):
|
||||||
|
try:
|
||||||
|
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()
|
||||||
|
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:
|
||||||
|
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:
|
||||||
|
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
|
### Close App
|
||||||
def Destroy(self):
|
def Destroy(self):
|
||||||
self.sysTray.Destroy()
|
self.sysTray.Destroy()
|
||||||
|
BIN
src/sounds/default/geo.mp3
Normal file
BIN
src/sounds/default/geo.mp3
Normal file
Binary file not shown.
@ -58,6 +58,10 @@ def is_audio(tweet):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_geocoded(tweet):
|
||||||
|
if tweet.has_key("coordinates") and tweet["coordinates"] != None:
|
||||||
|
return True
|
||||||
|
|
||||||
def get_all_mentioned(tweet, config):
|
def get_all_mentioned(tweet, config):
|
||||||
""" Gets all users that has been mentioned."""
|
""" Gets all users that has been mentioned."""
|
||||||
if tweet.has_key("retweeted_status"): tweet = tweet["retweeted_status"]
|
if tweet.has_key("retweeted_status"): tweet = tweet["retweeted_status"]
|
||||||
|
Loading…
Reference in New Issue
Block a user