mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Merge branch 'next-gen' of https://github.com/manuelcortez/TWBlue into next-gen
This commit is contained in:
commit
ce5498ff94
@ -1,9 +1,9 @@
|
|||||||
from base import Output, OutputError
|
from base import Output, OutputError
|
||||||
import atexit
|
import atexit
|
||||||
|
import application
|
||||||
class SpeechDispatcher(Output):
|
class SpeechDispatcher(Output):
|
||||||
"""Supports speech dispatcher on Linux.
|
"""Supports speech dispatcher on Linux.
|
||||||
Note that it will take the configuration from the speech dispatcher, the user will need configure voice, language, punctuation and rate before use this module.
|
Note that this module will use the configuration of speech dispatcher, the user will need to configure the voice, language, punctuation and rate before using this module.
|
||||||
"""
|
"""
|
||||||
name = 'SpeechDispatcher'
|
name = 'SpeechDispatcher'
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ class SpeechDispatcher(Output):
|
|||||||
super(SpeechDispatcher, self).__init__(*args, **kwargs)
|
super(SpeechDispatcher, self).__init__(*args, **kwargs)
|
||||||
try:
|
try:
|
||||||
import speechd
|
import speechd
|
||||||
self.spd = speechd.SSIPClient("TWBlue")
|
self.spd = speechd.SSIPClient(application.name)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise OutputError
|
raise OutputError
|
||||||
atexit.register(self.on_exit_event)
|
atexit.register(self.on_exit_event)
|
||||||
|
@ -530,6 +530,9 @@ class Controller(object):
|
|||||||
if hasattr(session_.sessions[item], "main_stream"): session_.sessions[item].main_stream.disconnect()
|
if hasattr(session_.sessions[item], "main_stream"): session_.sessions[item].main_stream.disconnect()
|
||||||
if hasattr(session_.sessions[item], "timelinesStream"): session_.sessions[item].timelinesStream.disconnect()
|
if hasattr(session_.sessions[item], "timelinesStream"): session_.sessions[item].timelinesStream.disconnect()
|
||||||
session_.sessions[item].sound.cleaner.cancel()
|
session_.sessions[item].sound.cleaner.cancel()
|
||||||
|
log.debug("Shelving database for " + session_.sessions[item].session_id)
|
||||||
|
session_.sessions[item].shelve()
|
||||||
|
|
||||||
if system == "Windows":
|
if system == "Windows":
|
||||||
self.systrayIcon.RemoveIcon()
|
self.systrayIcon.RemoveIcon()
|
||||||
widgetUtils.exit_application()
|
widgetUtils.exit_application()
|
||||||
@ -853,7 +856,7 @@ class Controller(object):
|
|||||||
def up(self, *args, **kwargs):
|
def up(self, *args, **kwargs):
|
||||||
page = self.get_current_buffer()
|
page = self.get_current_buffer()
|
||||||
if not hasattr(page.buffer, "list"):
|
if not hasattr(page.buffer, "list"):
|
||||||
output.speak(_(u"This account is not logged in twitter."), True)
|
output.speak(_(u"No session is currently in focus. Focus a session with the next or previous session shortcut."), True)
|
||||||
return
|
return
|
||||||
position = page.buffer.list.get_selected()
|
position = page.buffer.list.get_selected()
|
||||||
index = position-1
|
index = position-1
|
||||||
@ -871,7 +874,7 @@ class Controller(object):
|
|||||||
def down(self, *args, **kwargs):
|
def down(self, *args, **kwargs):
|
||||||
page = self.get_current_buffer()
|
page = self.get_current_buffer()
|
||||||
if not hasattr(page.buffer, "list"):
|
if not hasattr(page.buffer, "list"):
|
||||||
output.speak(_(u"This account is not logged in twitter."), True)
|
output.speak(_(u"No session is currently in focus. Focus a session with the next or previous session shortcut."), True)
|
||||||
return
|
return
|
||||||
position = page.buffer.list.get_selected()
|
position = page.buffer.list.get_selected()
|
||||||
index = position+1
|
index = position+1
|
||||||
@ -890,7 +893,7 @@ class Controller(object):
|
|||||||
buff = self.view.get_current_buffer_pos()
|
buff = self.view.get_current_buffer_pos()
|
||||||
buffer = self.get_current_buffer()
|
buffer = self.get_current_buffer()
|
||||||
if not hasattr(buffer.buffer, "list"):
|
if not hasattr(buffer.buffer, "list"):
|
||||||
output.speak(_(u"This account is not logged in twitter."), True)
|
output.speak(_(u"No session is currently in focus. Focus a session with the next or previous session shortcut."), True)
|
||||||
return
|
return
|
||||||
if buff == self.get_first_buffer(buffer.account) or buff == 0:
|
if buff == self.get_first_buffer(buffer.account) or buff == 0:
|
||||||
self.view.change_buffer(self.get_last_buffer(buffer.account))
|
self.view.change_buffer(self.get_last_buffer(buffer.account))
|
||||||
@ -908,7 +911,7 @@ class Controller(object):
|
|||||||
buff = self.view.get_current_buffer_pos()
|
buff = self.view.get_current_buffer_pos()
|
||||||
buffer = self.get_current_buffer()
|
buffer = self.get_current_buffer()
|
||||||
if not hasattr(buffer.buffer, "list"):
|
if not hasattr(buffer.buffer, "list"):
|
||||||
output.speak(_(u"This account is not logged in twitter."), True)
|
output.speak(_(u"No session is currently in focus. Focus a session with the next or previous session shortcut."), True)
|
||||||
return
|
return
|
||||||
if buff == self.get_last_buffer(buffer.account) or buff+1 == self.view.get_buffer_count():
|
if buff == self.get_last_buffer(buffer.account) or buff+1 == self.view.get_buffer_count():
|
||||||
self.view.change_buffer(self.get_first_buffer(buffer.account))
|
self.view.change_buffer(self.get_first_buffer(buffer.account))
|
||||||
@ -932,7 +935,7 @@ class Controller(object):
|
|||||||
self.current_account = account
|
self.current_account = account
|
||||||
buff = self.view.search("home_timeline", account)
|
buff = self.view.search("home_timeline", account)
|
||||||
if buff == None:
|
if buff == None:
|
||||||
output.speak(_(u"{0}: This account is not logged in twitter.").format(account), True)
|
output.speak(_(u"{0}: This account is not logged into Twitter.").format(account), True)
|
||||||
return
|
return
|
||||||
self.view.change_buffer(buff)
|
self.view.change_buffer(buff)
|
||||||
buffer = self.get_current_buffer()
|
buffer = self.get_current_buffer()
|
||||||
@ -952,7 +955,7 @@ class Controller(object):
|
|||||||
self.current_account = account
|
self.current_account = account
|
||||||
buff = self.view.search("home_timeline", account)
|
buff = self.view.search("home_timeline", account)
|
||||||
if buff == None:
|
if buff == None:
|
||||||
output.speak(_(u"{0}: This account is not logged in twitter.").format(account), True)
|
output.speak(_(u"{0}: This account is not logged into twitter.").format(account), True)
|
||||||
return
|
return
|
||||||
self.view.change_buffer(buff)
|
self.view.change_buffer(buff)
|
||||||
buffer = self.get_current_buffer()
|
buffer = self.get_current_buffer()
|
||||||
|
@ -73,21 +73,21 @@ class mainFrame(Gtk.Window):
|
|||||||
self.removeFromList = Gtk.MenuItem(label="Remove from list")
|
self.removeFromList = Gtk.MenuItem(label="Remove from list")
|
||||||
self.viewLists = Gtk.MenuItem(label="View lists")
|
self.viewLists = Gtk.MenuItem(label="View lists")
|
||||||
self.details = Gtk.MenuItem(label="Show user profile")
|
self.details = Gtk.MenuItem(label="Show user profile")
|
||||||
self.timeline = Gtk.MenuItem(label="Timeline")
|
|
||||||
self.favs = Gtk.MenuItem(label="View favourites")
|
self.favs = Gtk.MenuItem(label="View favourites")
|
||||||
self.append_to_menu(user, self.follow, self.unfollow, self.mute, self.unmute, self.report, self.block, self.unblock, self.dm, self.addToList, self.removeFromList, self.viewLists, self.details, self.timeline, self.favs)
|
self.append_to_menu(user, self.follow, self.unfollow, self.mute, self.unmute, self.report, self.block, self.unblock, self.dm, self.addToList, self.removeFromList, self.viewLists, self.details, self.favs)
|
||||||
user_menu = Gtk.MenuItem(label="User")
|
user_menu = Gtk.MenuItem(label="User")
|
||||||
user_menu.set_submenu(user)
|
user_menu.set_submenu(user)
|
||||||
menuBar.append(user_menu)
|
menuBar.append(user_menu)
|
||||||
|
|
||||||
# buffer menu
|
# buffer menu
|
||||||
buffer = Gtk.Menu()
|
buffer = Gtk.Menu()
|
||||||
|
self.timeline = Gtk.MenuItem(label="New buffer...")
|
||||||
self.load_previous_items = Gtk.MenuItem(label="Load previous items")
|
self.load_previous_items = Gtk.MenuItem(label="Load previous items")
|
||||||
self.mute_buffer = Gtk.MenuItem(label="Mute")
|
self.mute_buffer = Gtk.MenuItem(label="Mute")
|
||||||
self.autoread = Gtk.MenuItem(label="Autoread tweets for this buffer")
|
self.autoread = Gtk.MenuItem(label="Autoread")
|
||||||
self.clear = Gtk.MenuItem(label="Clear buffer")
|
self.clear = Gtk.MenuItem(label="Clear buffer")
|
||||||
self.deleteTl = Gtk.MenuItem(label="Remove buffer")
|
self.deleteTl = Gtk.MenuItem(label="Destroy")
|
||||||
self.append_to_menu(buffer, self.load_previous_items, self.mute_buffer, self.autoread, self.clear, self.deleteTl)
|
self.append_to_menu(buffer, self.timeline, self.load_previous_items, self.mute_buffer, self.autoread, self.clear, self.deleteTl)
|
||||||
buffer_menu = Gtk.MenuItem(label="Buffer")
|
buffer_menu = Gtk.MenuItem(label="Buffer")
|
||||||
buffer_menu.set_submenu(buffer)
|
buffer_menu.set_submenu(buffer)
|
||||||
menuBar.append(buffer_menu)
|
menuBar.append(buffer_menu)
|
||||||
|
@ -4,8 +4,8 @@ actions = {
|
|||||||
"down": _(u"Go down in the current buffer"),
|
"down": _(u"Go down in the current buffer"),
|
||||||
"left": _(u"Go to the previous buffer"),
|
"left": _(u"Go to the previous buffer"),
|
||||||
"right": _(u"Go to the next buffer"),
|
"right": _(u"Go to the next buffer"),
|
||||||
"next_account": _(u"Change to the next account"),
|
"next_account": _(u"Focus the next session"),
|
||||||
"previous_account": _(u"Change to the previous account"),
|
"previous_account": _(u"Focus the previous session"),
|
||||||
"show_hide": _(u"Show or hide the GUI"),
|
"show_hide": _(u"Show or hide the GUI"),
|
||||||
"post_tweet": _(u"New tweet"),
|
"post_tweet": _(u"New tweet"),
|
||||||
"post_reply": _(u"Reply"),
|
"post_reply": _(u"Reply"),
|
||||||
@ -18,29 +18,29 @@ actions = {
|
|||||||
"view_item": _(u"Show tweet"),
|
"view_item": _(u"Show tweet"),
|
||||||
"exit": _(u"Quit"),
|
"exit": _(u"Quit"),
|
||||||
"open_timeline": _(u"Open user timeline"),
|
"open_timeline": _(u"Open user timeline"),
|
||||||
"remove_buffer": _(u"Remove buffer"),
|
"remove_buffer": _(u"Destroy buffer"),
|
||||||
"url": _(u"Open URL on the current tweet, or further information for a friend or follower"),
|
"url": _(u"Open URL on the current tweet, or further information for a friend or follower"),
|
||||||
"audio": _(u"Attempt to play audio"),
|
"audio": _(u"Attempt to play audio"),
|
||||||
"volume_up": _(u"Increase volume by 5%"),
|
"volume_up": _(u"Increase volume by 5%"),
|
||||||
"volume_down": _(u"Decrease volume by 5%"),
|
"volume_down": _(u"Decrease volume by 5%"),
|
||||||
"go_home": _(u"Go to the first element on the list"),
|
"go_home": _(u"Jump to the first element of a buffer"),
|
||||||
"go_end": _(u"Go to the last element on the list"),
|
"go_end": _(u"Jump to the last element of the current buffer"),
|
||||||
"go_page_up": _(u"Move 20 elements up on the current list"),
|
"go_page_up": _(u"Jump 20 elements up in the current buffer"),
|
||||||
"go_page_down": _(u"Move 20 elements down on the current list"),
|
"go_page_down": _(u"Jump 20 elements down in the current buffer"),
|
||||||
"update_profile": _(u"Edit profile"),
|
"update_profile": _(u"Edit profile"),
|
||||||
"delete": _(u"Remove a tweet or direct message"),
|
"delete": _(u"Delete a tweet or direct message"),
|
||||||
"clear_buffer": _(u"Empty the current buffer"),
|
"clear_buffer": _(u"Empty the current buffer"),
|
||||||
"repeat_item": _(u"Repeat last item"),
|
"repeat_item": _(u"Repeat last item"),
|
||||||
"copy_to_clipboard": _(u"Copy to clipboard"),
|
"copy_to_clipboard": _(u"Copy to clipboard"),
|
||||||
"add_to_list": _(u"Add to list"),
|
"add_to_list": _(u"Add to list"),
|
||||||
"remove_from_list": _(u"Remove from list"),
|
"remove_from_list": _(u"Remove from list"),
|
||||||
"toggle_buffer_mute": _(u"Mute/unmute the active buffer"),
|
"toggle_buffer_mute": _(u"Mute/unmute the active buffer"),
|
||||||
"toggle_session_mute": _(u"Globally mute/unmute the current account"),
|
"toggle_session_mute": _(u"Mute/unmute the current session"),
|
||||||
"toggle_autoread": _(u"toggle the automatic reading of incoming tweets in the active buffer"),
|
"toggle_autoread": _(u"toggle the automatic reading of incoming tweets in the active buffer"),
|
||||||
"search": _(u"Search on twitter"),
|
"search": _(u"Search on twitter"),
|
||||||
"edit_keystrokes": _(u"Show the keystroke editor"),
|
"edit_keystrokes": _(u"Show the keystroke editor"),
|
||||||
"view_user_lists": _(u"Show lists for a specified user"),
|
"view_user_lists": _(u"Show lists for a specified user"),
|
||||||
"get_more_items": _(u"load previous items to any buffer"),
|
"get_more_items": _(u"load previous items"),
|
||||||
"reverse_geocode": _(u"Get geolocation"),
|
"reverse_geocode": _(u"Get geolocation"),
|
||||||
"view_reverse_geocode": _(u"Display the tweet's geolocation in a dialog"),
|
"view_reverse_geocode": _(u"Display the tweet's geolocation in a dialog"),
|
||||||
"get_trending_topics": _(u"Create a trending topics buffer"),
|
"get_trending_topics": _(u"Create a trending topics buffer"),
|
||||||
|
@ -12,6 +12,9 @@ import logging
|
|||||||
from twitter import utils
|
from twitter import utils
|
||||||
from twython import TwythonError, TwythonRateLimitError, TwythonAuthError
|
from twython import TwythonError, TwythonRateLimitError, TwythonAuthError
|
||||||
import config_utils
|
import config_utils
|
||||||
|
import shelve
|
||||||
|
import application
|
||||||
|
import os
|
||||||
from mysc.thread_utils import stream_threaded
|
from mysc.thread_utils import stream_threaded
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
log = logging.getLogger("sessionmanager.session")
|
log = logging.getLogger("sessionmanager.session")
|
||||||
@ -91,7 +94,8 @@ class Session(object):
|
|||||||
self.logged = False
|
self.logged = False
|
||||||
self.settings = None
|
self.settings = None
|
||||||
self.twitter = twitter.twitter.twitter()
|
self.twitter = twitter.twitter.twitter()
|
||||||
self.db = {}
|
self.db={}
|
||||||
|
self.deshelve()
|
||||||
self.reconnection_function_active = False
|
self.reconnection_function_active = False
|
||||||
self.counter = 0
|
self.counter = 0
|
||||||
self.lists = []
|
self.lists = []
|
||||||
@ -362,3 +366,34 @@ class Session(object):
|
|||||||
else:
|
else:
|
||||||
self.main_stream.disconnect()
|
self.main_stream.disconnect()
|
||||||
del self.main_stream
|
del self.main_stream
|
||||||
|
|
||||||
|
def shelve(self):
|
||||||
|
"Shelve the database to allow for persistance."
|
||||||
|
shelfname=paths.config_path(str(self.session_id)+".db")
|
||||||
|
try:
|
||||||
|
if not os.path.exists(shelfname):
|
||||||
|
output.speak("Generating database, this might take a while.",True)
|
||||||
|
shelf=shelve.open(paths.config_path(shelfname),'c')
|
||||||
|
for key,value in self.db.items():
|
||||||
|
if type(key) != str and type(key) != unicode:
|
||||||
|
output.speak("Uh oh, while shelving the database, a key of type " + str(type(key)) + " has been found. It will be converted to type str, but this will cause all sorts of problems on deshelve. Please bring this to the attention of the " + application.name + " developers immediately. More information about the error will be written to the error log.",True)
|
||||||
|
log.error("Uh oh, " + str(key) + " is of type " + str(type(key)) + "!")
|
||||||
|
shelf[str(key)]=value
|
||||||
|
shelf.close()
|
||||||
|
except:
|
||||||
|
output.speak("An exception occurred while shelving the " + application.name + " database. It will be deleted and rebuilt automatically. If this error persists, send the error log to the " + application.name + " developers.",True)
|
||||||
|
log.exception("Exception while shelving" + shelfname)
|
||||||
|
os.remove(shelfname)
|
||||||
|
|
||||||
|
def deshelve(self):
|
||||||
|
"Import a shelved database."
|
||||||
|
shelfname=paths.config_path(str(self.session_id)+".db")
|
||||||
|
try:
|
||||||
|
shelf=shelve.open(paths.config_path(shelfname),'c')
|
||||||
|
for key,value in shelf.items():
|
||||||
|
self.db[unicode(key)]=value
|
||||||
|
shelf.close()
|
||||||
|
except:
|
||||||
|
output.speak("An exception occurred while deshelving the " + application.name + " database. It will be deleted and rebuilt automatically. If this error persists, send the error log to the " + application.name + " developers.",True)
|
||||||
|
log.exception("Exception while deshelving" + shelfname)
|
||||||
|
os.remove(shelfname)
|
||||||
|
@ -52,17 +52,17 @@ class mainFrame(wx.Frame):
|
|||||||
self.viewLists = user.Append(wx.NewId(), _(u"&View lists"))
|
self.viewLists = user.Append(wx.NewId(), _(u"&View lists"))
|
||||||
self.viewLists.Enable(False)
|
self.viewLists.Enable(False)
|
||||||
self.details = user.Append(wx.NewId(), _(u"Show user &profile"))
|
self.details = user.Append(wx.NewId(), _(u"Show user &profile"))
|
||||||
self.timeline = user.Append(wx.NewId(), _(u"&Timeline"))
|
|
||||||
self.favs = user.Append(wx.NewId(), _(u"V&iew favourites"))
|
self.favs = user.Append(wx.NewId(), _(u"V&iew favourites"))
|
||||||
|
|
||||||
# buffer menu
|
# buffer menu
|
||||||
buffer = wx.Menu()
|
buffer = wx.Menu()
|
||||||
|
self.timeline = buffer.Append(wx.NewId(), _(u"&New buffer..."))
|
||||||
self.load_previous_items = buffer.Append(wx.NewId(), _(u"&Load previous items"))
|
self.load_previous_items = buffer.Append(wx.NewId(), _(u"&Load previous items"))
|
||||||
buffer.AppendSeparator()
|
buffer.AppendSeparator()
|
||||||
self.mute_buffer = buffer.AppendCheckItem(wx.NewId(), _(u"&Mute"))
|
self.mute_buffer = buffer.AppendCheckItem(wx.NewId(), _(u"&Mute"))
|
||||||
self.autoread = buffer.AppendCheckItem(wx.NewId(), _(u"&Autoread tweets for this buffer"))
|
self.autoread = buffer.AppendCheckItem(wx.NewId(), _(u"&Autoread"))
|
||||||
self.clear = buffer.Append(wx.NewId(), _(u"&Clear buffer"))
|
self.clear = buffer.Append(wx.NewId(), _(u"&Clear buffer"))
|
||||||
self.deleteTl = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
|
self.deleteTl = buffer.Append(wx.NewId(), _(u"&Destroy"))
|
||||||
|
|
||||||
# Help Menu
|
# Help Menu
|
||||||
help = wx.Menu()
|
help = wx.Menu()
|
||||||
|
Loading…
Reference in New Issue
Block a user