diff --git a/src/accessible_output2/outputs/speechDispatcher.py b/src/accessible_output2/outputs/speechDispatcher.py index 33c558c9..1509ecd5 100644 --- a/src/accessible_output2/outputs/speechDispatcher.py +++ b/src/accessible_output2/outputs/speechDispatcher.py @@ -1,9 +1,9 @@ from base import Output, OutputError import atexit - +import application class SpeechDispatcher(Output): """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' @@ -11,7 +11,7 @@ class SpeechDispatcher(Output): super(SpeechDispatcher, self).__init__(*args, **kwargs) try: import speechd - self.spd = speechd.SSIPClient("TWBlue") + self.spd = speechd.SSIPClient(application.name) except ImportError: raise OutputError atexit.register(self.on_exit_event) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index f5a6564c..0e9e22e8 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -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], "timelinesStream"): session_.sessions[item].timelinesStream.disconnect() session_.sessions[item].sound.cleaner.cancel() + log.debug("Shelving database for " + session_.sessions[item].session_id) + session_.sessions[item].shelve() + if system == "Windows": self.systrayIcon.RemoveIcon() widgetUtils.exit_application() @@ -853,7 +856,7 @@ class Controller(object): def up(self, *args, **kwargs): page = self.get_current_buffer() 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 position = page.buffer.list.get_selected() index = position-1 @@ -871,7 +874,7 @@ class Controller(object): def down(self, *args, **kwargs): page = self.get_current_buffer() 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 position = page.buffer.list.get_selected() index = position+1 @@ -890,7 +893,7 @@ class Controller(object): buff = self.view.get_current_buffer_pos() buffer = self.get_current_buffer() 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 if buff == self.get_first_buffer(buffer.account) or buff == 0: self.view.change_buffer(self.get_last_buffer(buffer.account)) @@ -908,7 +911,7 @@ class Controller(object): buff = self.view.get_current_buffer_pos() buffer = self.get_current_buffer() 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 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)) @@ -932,7 +935,7 @@ class Controller(object): self.current_account = account buff = self.view.search("home_timeline", account) 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 self.view.change_buffer(buff) buffer = self.get_current_buffer() @@ -952,7 +955,7 @@ class Controller(object): self.current_account = account buff = self.view.search("home_timeline", account) 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 self.view.change_buffer(buff) buffer = self.get_current_buffer() diff --git a/src/gtkUI/view.py b/src/gtkUI/view.py index 4e53bc2a..054c43a3 100644 --- a/src/gtkUI/view.py +++ b/src/gtkUI/view.py @@ -73,21 +73,21 @@ class mainFrame(Gtk.Window): self.removeFromList = Gtk.MenuItem(label="Remove from list") self.viewLists = Gtk.MenuItem(label="View lists") self.details = Gtk.MenuItem(label="Show user profile") - self.timeline = Gtk.MenuItem(label="Timeline") 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.set_submenu(user) menuBar.append(user_menu) # buffer menu buffer = Gtk.Menu() + self.timeline = Gtk.MenuItem(label="New buffer...") self.load_previous_items = Gtk.MenuItem(label="Load previous items") 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.deleteTl = Gtk.MenuItem(label="Remove buffer") - self.append_to_menu(buffer, self.load_previous_items, self.mute_buffer, self.autoread, self.clear, self.deleteTl) + self.deleteTl = Gtk.MenuItem(label="Destroy") + 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.set_submenu(buffer) menuBar.append(buffer_menu) diff --git a/src/keystrokeEditor/constants.py b/src/keystrokeEditor/constants.py index c8e0bf04..627c4f49 100644 --- a/src/keystrokeEditor/constants.py +++ b/src/keystrokeEditor/constants.py @@ -4,8 +4,8 @@ actions = { "down": _(u"Go down in the current buffer"), "left": _(u"Go to the previous buffer"), "right": _(u"Go to the next buffer"), -"next_account": _(u"Change to the next account"), -"previous_account": _(u"Change to the previous account"), +"next_account": _(u"Focus the next session"), +"previous_account": _(u"Focus the previous session"), "show_hide": _(u"Show or hide the GUI"), "post_tweet": _(u"New tweet"), "post_reply": _(u"Reply"), @@ -18,29 +18,29 @@ actions = { "view_item": _(u"Show tweet"), "exit": _(u"Quit"), "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"), "audio": _(u"Attempt to play audio"), "volume_up": _(u"Increase volume by 5%"), "volume_down": _(u"Decrease volume by 5%"), -"go_home": _(u"Go to the first element on the list"), -"go_end": _(u"Go to the last element on the list"), -"go_page_up": _(u"Move 20 elements up on the current list"), -"go_page_down": _(u"Move 20 elements down on the current list"), +"go_home": _(u"Jump to the first element of a buffer"), +"go_end": _(u"Jump to the last element of the current buffer"), +"go_page_up": _(u"Jump 20 elements up in the current buffer"), +"go_page_down": _(u"Jump 20 elements down in the current buffer"), "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"), "repeat_item": _(u"Repeat last item"), "copy_to_clipboard": _(u"Copy to clipboard"), "add_to_list": _(u"Add to list"), "remove_from_list": _(u"Remove from list"), "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"), "search": _(u"Search on twitter"), "edit_keystrokes": _(u"Show the keystroke editor"), "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"), "view_reverse_geocode": _(u"Display the tweet's geolocation in a dialog"), "get_trending_topics": _(u"Create a trending topics buffer"), diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index dbff4433..88199364 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -12,6 +12,9 @@ import logging from twitter import utils from twython import TwythonError, TwythonRateLimitError, TwythonAuthError import config_utils +import shelve +import application +import os from mysc.thread_utils import stream_threaded from pubsub import pub log = logging.getLogger("sessionmanager.session") @@ -91,7 +94,8 @@ class Session(object): self.logged = False self.settings = None self.twitter = twitter.twitter.twitter() - self.db = {} + self.db={} + self.deshelve() self.reconnection_function_active = False self.counter = 0 self.lists = [] @@ -361,4 +365,35 @@ class Session(object): del self.timelinesStream else: self.main_stream.disconnect() - del self.main_stream \ No newline at end of file + 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) diff --git a/src/wxUI/view.py b/src/wxUI/view.py index b4d0f4dc..c7bcb621 100644 --- a/src/wxUI/view.py +++ b/src/wxUI/view.py @@ -52,17 +52,17 @@ class mainFrame(wx.Frame): self.viewLists = user.Append(wx.NewId(), _(u"&View lists")) self.viewLists.Enable(False) 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")) # buffer 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")) buffer.AppendSeparator() 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.deleteTl = buffer.Append(wx.NewId(), _(u"&Remove buffer")) + self.deleteTl = buffer.Append(wx.NewId(), _(u"&Destroy")) # Help Menu help = wx.Menu()