Beispiel #1
0
 def start_recording(self):
  self.attach_exists.Disable()
  self.file = tempfile.mktemp(suffix='.wav')
  self.recording = sound.recording(self.file)
  self.recording.play()
  self.record.SetLabel(_(u"Stop recording"))
  output.speak(_(u"Recording"))
Beispiel #2
0
 def retrieve_update(self, *args, **kwargs):
  timeline = self.timeline_update('get_user_timeline', since_id=self.get_max_twitter_id(), screen_name=self.username, include_rts=True, include_entities=True, tweet_mode='extended')
  if self.initial_update:
   self.initial_update = False
   if not len(self) and not timeline:
    output.speak(_("%s has no tweets.") % self.name)
  return timeline
Beispiel #3
0
 def LocalTrends(self):
  """Creates a buffer containing the trends for the specified location."""

  output.speak(_("Retrieving locations."), True)
  try:
   locations = self.session.TwitterApi.get_available_trends()
   logging.debug("Raw locations: %s" % str(locations))
  except:
   logging.debug("Unable to obtain local trend locations.")
   return output.speak(_("Unable to retrieve local trend locations; please try again later."), True)
  locations.sort(key=lambda location: location['name'])
  locations_by_name = {}
  locations_tree = {}
  for location in locations:
   type = location['placeType']['name']
   place = location['name']
   if place == "Worldwide":
    continue
   locations_by_name[place] = location
   if type not in locations_tree.keys():
    locations_tree[type] = []
   locations_tree[type].append(place)
  dlg = modal_dialog(gui.LocalTrendsDialog, parent=self.session.frame, id=wx.ID_ANY, locations_tree=locations_tree)
  if dlg.locations_list.GetSelection() == wx.NOT_FOUND:
   choice = dlg.locations_list.GetItems()[0]
  else:
   choice = dlg.locations_list.GetStringSelection()
  location = locations_by_name[choice]
  self.session.register_buffer(_("Trending: %s" % location['name']), buffers.LocalTrends, woeid=location['woeid'])
 def stop_recording(self):
  self.recording.stop()
  self.recording.free()
  output.speak(_(u"Stopped"))
  self.recorded = True
  self.dialog.set("record", _(u"&Record"))
  self.file_attached()
Beispiel #5
0
 def retrieve_access_token(self):
     output.speak(
         _("Please wait while an access token is retrieved from Twitter."),
         True)
     self.check_twitter_connection()
     auth_props = self.auth_handler.get_authentication_tokens()
     oauth_token = auth_props['oauth_token']
     oauth_token_secret = auth_props['oauth_token_secret']
     url = auth_props['auth_url']
     misc.open_url_in_browser(url)
     dlg = wx.TextEntryDialog(
         caption=_("Twitter Login"),
         message=
         _("Please enter the verification code from Twitter for session %s")
         % self.name,
         parent=self.frame)
     dlg.Raise()
     if dlg.ShowModal() != wx.ID_OK:
         raise ValueError("User canceled login")
     verification = dlg.GetValue().strip()
     self.auth_handler = Twython(str(self.config['oauth']['twitterKey']),
                                 str(self.config['oauth']['twitterSecret']),
                                 oauth_token, oauth_token_secret)
     token = self.auth_handler.get_authorized_tokens(verification)
     output.speak(_("Retrieved access token from Twitter."), True)
     self.config['oauth']['userKey'] = token['oauth_token']
     self.config['oauth']['userSecret'] = token['oauth_token_secret']
     logging.debug("Successfully retrieved an oAuth access token for user.")
     self.login()
Beispiel #6
0
 def start_recording(self):
  self.attach_existing.Disable()
  self.file = tempfile.mktemp(suffix='.wav')
  self.recording = sessions.current_session.record_sound(self.file)
  self.recording.play()
  self.record.SetLabel(_("&Stop"))
  output.speak(_("Recording."), True)
Beispiel #7
0
 def upload_completed(self):
  url = self.uploader.get_url()
  self.uploaderDialog.Destroy()
  if url != 0:
   self.text.SetValue(self.text.GetValue()+url+" #audio")
  else:
   output.speak(_(u"Unable to upload the audio"))
Beispiel #8
0
    def TwitterSearch(self, text=None):
        """Allows you to search twitter for the specified term."""

        if not text:
            text = self.buffer().get_hash_tags(self.buffer().index)
        text.extend(self.buffer().get_mentions(self.buffer().index))
        new = modal_dialog(gui.TwitterSearchDialog,
                           parent=self.session.frame,
                           title=_("Twitter search"),
                           text=text)
        term = unicode(new.term.GetValue())
        save = new.save.GetValue()
        store = new.store.GetValue()
        count = new.retrieveCount.GetValue()
        maxAPIPerUpdate = new.maxAPIPerUpdate.GetValue()
        if count == 100 and maxAPIPerUpdate > 1:
            count = 200
        if not term:
            output.speak(_("Please enter a term to search for."), True)
            return self.TwitterSearch()
        title = _("Search for %s") % term
        search = self.session.register_buffer(title,
                                              buffers.Search,
                                              store=store,
                                              term=term,
                                              saved=save,
                                              count=count,
                                              maxAPIPerUpdate=maxAPIPerUpdate)
Beispiel #9
0
def smsSend(*args, **kwargs):
    dlg = wx.TextEntryDialog(
        globalVars.Frame,
        _("Enter Phone Number or numbers separated by semicolons:"),
        versionInfo.name + " - " + _("New SMS Wizard"))
    dlg.FindWindowById(3000).Bind(wx.EVT_KEY_DOWN, OnKeyDown)
    globalVars.Frame.DisplayDialog(dlg)
    s = dlg.ShowModal()
    while True and s != wx.ID_CANCEL:
        targets = [
            "+" + x.strip().replace("+", "") for x in dlg.GetValue().split(";")
        ]
        try:
            globalVars.currentSms = globalVars.Skype.CreateSms(
                Skype4Py.smsMessageTypeOutgoing, *targets)
            smsDialog.smsDialog(
                parent=globalVars.Frame,
                title=versionInfo.name + " - " +
                _("New SMS Wizard: from %s to %s") %
                (globalVars.currentSms.ReplyToNumber, "; ".join(
                    [x for x in globalVars.currentSms.TargetNumbers])))
            break
        except:
            output.speak(
                _("Invalid number. Please check your input and try again."))
            s = dlg.ShowModal()
            dlg.FindWindowById(3000).SetFocus()
    globalVars.Frame.CloseDialog(dlg)
Beispiel #10
0
 def interact_with_audio(self, index=None):
     url = self.find_audio_handler(index)
     if self._url_matches_playing_item(
             url) and self.session.currently_playing.is_playing:
         return self._stop()
     output.speak(_("playing audio."), True)
     self.session.user_playback(url, stream=True)
Beispiel #11
0
 def ToggleModifierLock(self):
  if self.session.modifiers_locked:
   self.session.unlock_modifiers()
   output.speak(_("Modifiers unlocked."), True)
  else:
   self.session.lock_modifiers()
   output.speak(_("Modifiers locked."), True)
Beispiel #12
0
 def replace_keymap(new):
  self.session.unregister_hotkeys()
  self.session.keymap.clear()
  self.session.keymap.update(new)
  self.session.set_active_keymap(self.session.keymap)
  self.session.save_config()
  output.speak(_("Keymap saved."), True)
Beispiel #13
0
 def add_users_to_database(self):
     self.config["mysc"][
         "save_friends_in_autocompletion_db"] = self.dialog.get(
             "friends_buffer")
     self.config["mysc"][
         "save_followers_in_autocompletion_db"] = self.dialog.get(
             "followers_buffer")
     output.speak(
         _(u"Updating database... You can close this window now. A message will tell you when the process finishes."
           ))
     database = storage.storage(self.buffer.session.session_id)
     if self.dialog.get("followers_buffer") == True:
         buffer = self.window.search_buffer(
             "followers", self.config["twitter"]["user_name"])
         for i in buffer.session.db[buffer.name]["items"]:
             database.set_user(i["screen_name"], i["name"], 1)
     else:
         database.remove_by_buffer(1)
     if self.dialog.get("friends_buffer") == True:
         buffer = self.window.search_buffer(
             "friends", self.config["twitter"]["user_name"])
         for i in buffer.session.db[buffer.name]["items"]:
             database.set_user(i["screen_name"], i["name"], 2)
     else:
         database.remove_by_buffer(2)
     wx_settings.show_success_dialog()
     self.dialog.destroy()
Beispiel #14
0
 def onView(self, ev):
     ev.Skip()
     if self.lista.get_count() == 0:
         return
     list_id = self.db.settings["lists"][self.lista.get_selected()]["id"]
     list_updated = self.twitter.twitter.get_specific_list(list_id=list_id)
     self.db.settings["lists"][self.lista.get_selected()] = list_updated
     if list_updated["slug"] not in config.main["other_buffers"]["lists"]:
         config.main["other_buffers"]["lists"].append(list_updated["slug"])
         output.speak(_(u"List opened"))
     else:
         output.speak(_(u"This list is arready opened."))
         return
     listUI = gui.buffers.lists.listPanel(
         self.nb,
         self.parent,
         list_updated["slug"] + "-list",
         argumento=utils.find_list(list_updated["slug"], self.db.settings["lists"]),
     )
     self.nb.InsertSubPage(
         self.db.settings["buffers"].index("lists"), listUI, _(u"List for %s") % (list_updated["slug"],)
     )
     self.db.settings["buffers"].append(list_updated["slug"] + "-list")
     num = listUI.start_streams()
     listUI.put_items(num)
     listUI.sound = "tweet_timeline.wav"
     self.parent.stream2.disconnect()
     del self.parent.stream2
     self.parent.get_tls()
Beispiel #15
0
 def do_import(self):
  output.speak("Initiating import...")
  for k in self.root:
   if type(self.root[k]) == list: #An old buffer that deserves buffership!
    self.import_buffer(k)
  self.file.close()
  del(self.connection)
Beispiel #16
0
 def start_recording(self):
  self.attach_existing.Disable()
  self.file = tempfile.mktemp(suffix='.wav')
  self.recording = sessions.current_session.record_sound(self.file)
  self.recording.play()
  self.record.SetLabel(_("&Stop"))
  output.speak(_("Recording."), True)
Beispiel #17
0
 def announce_session_mute (self, first=False):
  if not self.config['sounds']['mute'] and not first:
   output.speak(_("Session mute off"), True)
  elif self.config['sounds']['mute']:
   output.speak(_("Session mute on"), not first)
  if first:
   self.announce_global_mute(first=first)
Beispiel #18
0
def modal_dialog(dialog, *args, **kwargs):
 dlg = dialog(*args, **kwargs)
 if dlg.ShowModal() != wx.ID_OK:
  output.speak(_("Canceled."), True)
  canceled = True
  raise WXDialogCanceled()
 return dlg
Beispiel #19
0
 def ForceSyncToDisk(self):
     """Saves the current session's database to disk."""
     #FIXME Should be moved to storage session
     output.speak(
         _("Syncing storage to disk for %s session." %
           sessions.current_session.name), True)
     call_threaded(sessions.current_session.sync, forced=True, speak=True)
Beispiel #20
0
 def interact(self, ev):
  try:
   tweet = self.get_tweet()
   urls = twitter.utils.find_urls_in_text(tweet["text"])
  except:
   urls = []
  if type(ev) is str: event = ev
  else:
   if ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown(): event = "audio"
   elif ev.GetKeyCode() == wx.WXK_RETURN: event = "url"
   elif ev.GetKeyCode() == wx.WXK_F5: event = "volume_down"
   elif ev.GetKeyCode() == wx.WXK_F6: event = "volume_up"
   elif ev.GetKeyCode() == wx.WXK_DELETE and ev.ShiftDown(): event = "clear_list"
   elif ev.GetKeyCode() == wx.WXK_DELETE: event = "delete_item"
   else:
    ev.Skip()
    return
  if event == "audio"  and len(urls) > 0:
   if len(urls) == 1:
    self.streamer(urls[0])
   elif len(urls) > 1:
    urlList = gui.dialogs.urlList.urlList(urls)
    if urlList.ShowModal() == wx.ID_OK:
     self.streamer(urls[urlList.lista.GetSelection()])
  elif event == "url":
   if len(urls) == 0: return
   elif len(urls) == 1:
    output.speak(_(u"Opening URL..."), True)
    webbrowser.open(urls[0])
   elif len(urls) > 1:
    urlList = gui.dialogs.urlList.urlList(urls)
    if urlList.ShowModal() == wx.ID_OK:
     webbrowser.open_new_tab(urls[urlList.lista.GetSelection()])
  elif event == "volume_down":
   if config.main["sound"]["volume"] > 0.05:
    config.main["sound"]["volume"] = config.main["sound"]["volume"]-0.05
    sound.player.play("volume_changed.ogg", False)
    if hasattr(self.parent, "audioStream"):
     self.parent.audioStream.stream.volume = config.main["sound"]["volume"]
  elif event == "volume_up":
   if config.main["sound"]["volume"] < 0.95:
    config.main["sound"]["volume"] = config.main["sound"]["volume"]+0.05
    sound.player.play("volume_changed.ogg", False)
    if hasattr(self.parent, "audioStream"):
     self.parent.audioStream.stream.volume = config.main["sound"]["volume"]
  elif event == "clear_list" and self.list.get_count() > 0:
   dlg = wx.MessageDialog(self, _(u"Do you really want to empty this buffer? It's tweets will be removed from the list but not from Twitter"), _(u"Empty buffer"), wx.ICON_QUESTION|wx.YES_NO)
   if dlg.ShowModal() == wx.ID_YES:
    self.db.settings[self.name_buffer] = []
    self.list.clear()
  elif event == "delete_item":
   dlg = wx.MessageDialog(self, _(u"Do you really want to delete this message?"), _(u"Delete"), wx.ICON_QUESTION|wx.YES_NO)
   if dlg.ShowModal() == wx.ID_YES:
    self.destroy_status(wx.EVT_MENU)
   else:
    return
  try:
   ev.Skip()
  except:
   pass
Beispiel #21
0
 def replace_keymap(new):
     self.session.unregister_hotkeys()
     self.session.keymap.clear()
     self.session.keymap.update(new)
     self.session.set_active_keymap(self.session.keymap)
     self.session.save_config()
     output.speak(_("Keymap saved."), True)
Beispiel #22
0
 def Quote (self, buffer=None, index=None):
  """Allows you to quote the current tweet."""

  try:
   user = buffer.get_screen_name(index)
   if 'quoted_status' not in buffer[index]:
    id = buffer[index]['id']
   else:
    id = buffer[index]['quoted_status']['id']
   tweet_link = u"https://twitter.com/%s/statuses/%s" % (user, str(id))
  except:
   logging.debug("Quoter: Unable to retrieve post to reply to.")
   return output.speak(_("Item is not a post."), True)
  if self.session.config['UI']['DMSafeMode'] and 'source' not in buffer[index]:
   logging.debug("Quoter: Preventing quote of direct message in DM safe mode...")
   return output.speak(_("Cannot quote a direct message while DM safe mode is enabled."), True)
  title="Quote"
  choice = 0
  if self.session.config['UI']['RTStyle'] == 0 and 'source' in buffer[index]:
   choice = question_dialog(caption=_("Quote"), message=_("Would you like to add a comment?"))
   if choice == wx.ID_CANCEL:
    return output.speak(_("Canceled."), True)
   elif choice == wx.ID_NO:
    return call_threaded(self.session.post_update, text=tweet_link)
   else:
    return   self.NewTweet(buffer, index, tweet_link, title)
  elif self.session.config['UI']['RTStyle'] == 1:
   logging.debug("Retweeter: Automatically retweeting...")
   call_threaded(self.session.post_retweet, id)
  elif self.session.config['UI']['RTStyle'] == 2 or 'source' not in buffer[index]:
   self.NewTweet(buffer, index, tweet_link, title)
Beispiel #23
0
 def ToggleModifierLock(self):
     if self.session.modifiers_locked:
         self.session.unlock_modifiers()
         output.speak(_("Modifiers unlocked."), True)
     else:
         self.session.lock_modifiers()
         output.speak(_("Modifiers locked."), True)
 def __init__(self, configFile, completed_callback):
  self.config = configFile
  super(audioUploader, self).__init__()
  self.dialog = wx_ui.audioDialog(services=self.get_available_services())
  self.file = None
  self.recorded = False
  self.recording = None
  self.playing = None
  widgetUtils.connect_event(self.dialog.play, widgetUtils.BUTTON_PRESSED, self.on_play)
  widgetUtils.connect_event(self.dialog.pause, widgetUtils.BUTTON_PRESSED, self.on_pause)
  widgetUtils.connect_event(self.dialog.record, widgetUtils.BUTTON_PRESSED, self.on_record)
  widgetUtils.connect_event(self.dialog.attach_exists, widgetUtils.BUTTON_PRESSED, self.on_attach_exists)
  widgetUtils.connect_event(self.dialog.discard, widgetUtils.BUTTON_PRESSED, self.on_discard)
  if self.dialog.get_response() == widgetUtils.OK:
   self.postprocess()
   log.debug("Uploading file %s to %s..." % (self.file, self.dialog.get("services")))
   self.uploaderDialog = wx_transfer_dialogs.UploadDialog(self.file)
   output.speak(_(u"Attaching..."))
   if self.dialog.get("services") == "SNDUp":
    base_url = "http://sndup.net/post.php"
    if len(self.config["sound"]["sndup_api_key"]) > 0:
     url = base_url + '?apikey=' + self.config['sound']['sndup_api_key']
    else:
     url = base_url
    self.uploaderFunction = transfer.Upload(field='file', url=url, filename=self.file, completed_callback=completed_callback)
   elif self.dialog.get("services") == "TwUp":
    url = "http://api.twup.me/post.json"
    self.uploaderFunction = transfer.Upload(field='file', url=url, filename=self.file, completed_callback=completed_callback)
   pub.subscribe(self.uploaderDialog.update, "uploading")
   self.uploaderDialog.get_response()
   self.uploaderFunction.perform_threaded()
Beispiel #25
0
	def load_album(self, *args, **kwargs):
		output.speak(_(u"Loading album..."))
		self.can_get_items = True
		self.tab.load.Enable(False)
		wx.CallAfter(self.get_items)
		self.tab.play.Enable(True)
		self.tab.play_all.Enable(True)
Beispiel #26
0
 def stop_recording(self):
     self.recording.stop()
     self.recording.free()
     output.speak(_(u"Stopped"))
     self.recorded = True
     self.dialog.set("record", _(u"&Record"))
     self.file_attached()
Beispiel #27
0
	def play_audio(self, *args, **kwargs):
		selected = self.tab.list.get_selected()
		if selected == -1:
			selected = 0
		output.speak(_(u"Opening video in webbrowser..."))
		webbrowser.open_new_tab(self.session.db[self.name]["items"][selected]["player"])
		return True
Beispiel #28
0
    def ApplyFilter(self, buffer=None):
        """Display a buffer containing or excluding the items which contain the specified search criteria."""

        from core.sessions.buffers.buffers import Filtered
        if not buffer.get_flag('filterable'):
            logging.debug("Buffer %s is not filterable." % buffer.name)
            return output.speak(
                _("Buffer %s does not support filtration." %
                  buffer.display_name), True)
        new = modal_dialog(gui.FilterDialog,
                           parent=self.session.frame,
                           buffer=buffer)
        output.speak(_("Processing.  Please wait."))
        filter_specs = new.get_filter_specs()
        for filter_spec in filter_specs:
            buftitle = Filtered.generate_filter_name(buffer, filter_spec)
            if filter_spec['replace']:
                replaces = buffer
            else:
                replaces = None
            filtered = self.session.register_buffer(buftitle,
                                                    Filtered,
                                                    replaces=replaces,
                                                    source_name=buffer.name,
                                                    **filter_spec)
Beispiel #29
0
 def update(self, update_type=None, *args, **kwargs):
     """The Update method.  Called to check for new  information and consolidate it into this buffer."""
     if hasattr(self, 'init_done_event'):
         self.init_done_event.wait()
     if not self.get_flag(
             'updatable') and update_type == self._update_types['forced']:
         raise UpdateError("Buffer %r is not updatable." % self)
     if not self.update_lock.acquire(False):
         if update_type == self._update_types['forced']:
             output.speak(_("Update already in progress; please wait."),
                          True)
         return
     try:
         if update_type == self._update_types['forced']:
             output.speak(self.update_message, True)
         logging.debug("Synchronizer: Updating buffer %s." % self)
         try:
             new = self.retrieve_update(update_type=update_type)
         except:
             return logging.exception(
                 "%s: Error during update process in buffer %s" %
                 (self.session, self))
         self.handle_update(new, update_type=update_type, *args, **kwargs)
     finally:
         self.update_lock.release()
Beispiel #30
0
 def get_more_items(self):
     if self.name_buffer == "followers":
         cursor = twitter.starting.followers_cursor
     elif self.name_buffer == "friends":
         cursor = twitter.starting.friends_cursor
     try:
         items = twitter.starting.get_more_items(
             self.function,
             self.twitter,
             users=True,
             name=self.name_buffer,
             count=config.main["general"]["max_tweets_per_call"],
             cursor=cursor)
     except TwythonError as e:
         output.speak(e.message)
         return
     for i in items:
         if config.main["general"]["reverse_timelines"] == False:
             self.db.settings[self.name_buffer].insert(0, i)
         else:
             self.db.settings[self.name_buffer].append(i)
     if config.main["general"]["reverse_timelines"] == False:
         for i in items:
             tweet = self.compose_function(i, self.db)
             self.list.insert_item(True, *tweet)
     else:
         for i in items:
             tweet = self.compose_function(i, self.db)
             self.list.insert_item(False, *tweet)
     output.speak(_(u"%s items retrieved") % (len(items)))
Beispiel #31
0
def checkForUpdates():
    if not automatic:
        output.speak(_("Checking for updates... Please wait..."))
    if config.conf["updates"]["downloadType"] == 1:
        compareVersions(getOnlineVersion("portable"), currentVersion)
    else:
        compareVersions(getOnlineVersion("setup"), currentVersion)
Beispiel #32
0
 def favorite_tweet(self, buffer=None, index=None):
  twitter_id = buffer[index]['id']
  post_type = buffer.get_item_type(index)
  if post_type != _("tweet"):
   return output.speak(_("You can like only a tweet."), True)
  output.speak(_("You like this tweet"), True)
  self.api_call('create_favorite', action=_("marking as favorite"), id=twitter_id)
 def get_more_items(self):
  elements = []
  if self.session.settings["general"]["reverse_timelines"] == False:
   last_id = self.session.db[self.name][0]["id"]
  else:
   last_id = self.session.db[self.name][-1]["id"]
  try:
   items = self.session.get_more_items(self.function, count=self.session.settings["general"]["max_tweets_per_call"], max_id=last_id, *self.args, **self.kwargs)
  except TwythonError as e:
   output.speak(e.message, True)
  for i in items:
   if utils.is_allowed(i, self.session.settings["twitter"]["ignored_clients"]) == True:
    elements.append(i)
    if self.session.settings["general"]["reverse_timelines"] == False:
     self.session.db[self.name].insert(0, i)
    else:
     self.session.db[self.name].append(i)
  selection = self.buffer.list.get_selected()
  if self.session.settings["general"]["reverse_timelines"] == False:
   for i in elements:
    tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
    self.buffer.list.insert_item(True, *tweet)
  else:
   for i in items:
    tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
    self.buffer.list.insert_item(False, *tweet)
#   self.buffer.list.select_item(selection+elements)
#  else:
   self.buffer.list.select_item(selection)
  output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
Beispiel #34
0
 def register_buffer (self, name, type, set_focus=True, announce=True, prelaunch_message="", postlaunch_message="", prevent_duplicates=True, *args, **kwargs):
  """Registers buffer  in session buffer list."""
  logging.debug("%s: Registering %s" % (self, name))
  if self.get_buffer_by_name(name) != None and prevent_duplicates:
   logging.debug("Buffer %s already exists." % name)
   num = self.get_buffer_index(self.get_buffer_by_name(name))
   if set_focus:
    self.set_buffer(self.get_navigation_index(buf_index=num))
   if announce:
    self.announce_buffer(interrupt=False)
   return num
  prelaunch_message and output.speak(prelaunch_message, True)
  try:
   new = type(name=name, session=self, *args, **kwargs)
  except:
   logging.exception("Unable to initialize an instance of buffer.%s " % type)
   return None
  if self.buffer_exists(new):
   logging.warning("%s: Prevented duplicate buffer registration of buffer %s." % (self.name, name))
   return None
  if new is None: #Something strange is going on.
   logging.debug("Attempted new buffer creation but got back a None object.  Aborting.")
   return None
  dispatcher.send(sender=self, signal=signals.buffer_created, buffer=new)
  num = self.add_buffer(new)
  if set_focus and num in self.nav_order:
   self.set_buffer(self.get_navigation_index(buf_index=num))
  postlaunch_message and output.speak(postlaunch_message, True)
  if announce:
   self.announce_buffer(interrupt=False)
  return num
 def get_more_items(self):
  try:
   items = self.session.get_more_items(self.function, users=True, name=self.name, count=self.session.settings["general"]["max_tweets_per_call"], cursor=self.session.db[self.name]["cursor"])
  except TwythonError as e:
   output.speak(e.message, True)
   return
  for i in items:
   if self.session.settings["general"]["reverse_timelines"] == False:
    self.session.db[self.name]["items"].insert(0, i)
   else:
    self.session.db[self.name]["items"].append(i)
  selected = self.buffer.list.get_selected()
#  self.put_items_on_list(len(items))
  if self.session.settings["general"]["reverse_timelines"] == True:
   for i in items:
    tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
    self.buffer.list.insert_item(True, *tweet)
   self.buffer.list.select_item(selected)
  else:
   for i in items:
    tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
    self.buffer.list.insert_item(True, *tweet)
#   self.buffer.list.select_item(selection)
#  else:
#   self.buffer.list.select_item(selection-elements)
  output.speak(_(u"%s items retrieved") % (len(items)), True)
Beispiel #36
0
    def RemoveFromList(self, buffer=None, index=None):
        """Remove a user from a list"""

        who = buffer.get_all_screen_names(index)
        dlg = gui.UserListDialog(parent=self.session.frame,
                                 title=_("Select user to remove"),
                                 users=who)
        dlg.setup_users()
        dlg.finish_setup()
        if dlg.ShowModal() != wx.ID_OK:
            return output.speak(_("Canceled."), True)
        user = dlg.users.GetValue()
        output.speak(_("Retrieving lists, please wait."), True)
        lists = self.session.TwitterApi.show_lists()
        if not lists:
            return output.speak(
                _("No lists defined.  Please create a list with the list manager before performing this action."
                  ), True)
        dlg = wx.SingleChoiceDialog(
            parent=self.session.frame,
            caption=_("Select list"),
            message=_("Please select a list to remove %s from?") % user,
            choices=[i['name'] for i in lists])
        if dlg.ShowModal() != wx.ID_OK:
            return output.speak(_("Canceled."), True)
        which = lists[dlg.GetSelection()]
        self.session.api_call('delete_list_member',
                              action=_("removing %s from list %s.") %
                              (user, which['name']),
                              screen_name=user,
                              list_id=which['id'])
Beispiel #37
0
 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"], 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"], 2)
     else:
         database.remove_by_buffer(2)
     wx_settings.show_success_dialog()
     self.dialog.Destroy()
Beispiel #38
0
 def _add_user_to_list(self, buffer=None, index=None):
     try:
         who = [buffer.get_screen_name(index)]
     except:
         who = [""]
     if who == [None]:
         who = [""]
     if hasattr(buffer, "get_mentions"):
         who.extend(buffer.get_mentions())
     dlg = gui.UserListDialog(parent=self.frame,
                              title=_("Select user to add"),
                              users=who)
     dlg.setup_users()
     dlg.finish_setup()
     if dlg.ShowModal() != wx.ID_OK:
         return output.speak(_("Canceled."), True)
     user = dlg.users.GetValue()
     output.speak(_("Retrieving lists, please wait."), True)
     lists = self.TwitterApi.lists()[0]['lists']
     dlg = wx.SingleChoiceDialog(
         parent=self.frame,
         caption=_("Select list"),
         message=_("Please select a list to add %s to?") % user,
         choices=[i['name'] for i in lists])
     if dlg.ShowModal() != wx.ID_OK:
         return output.speak(_("Canceled."), True)
     which = lists[dlg.GetSelection()]
     self.api_call('add_list_member',
                   _("adding user %s to list %s") % (user, which['name']),
                   id=user,
                   slug=which['slug'])
Beispiel #39
0
 def get_more_items(self):
     if config.main["general"]["reverse_timelines"] == False:
         last_id = self.db.settings[self.name_buffer][0]["id"]
     else:
         last_id = self.db.settings[self.name_buffer][-1]["id"]
     try:
         items = twitter.starting.get_more_items(
             self.function,
             self.twitter,
             count=config.main["general"]["max_tweets_per_call"],
             max_id=last_id,
             screen_name=self.argumento)
     except TwythonError as e:
         output.speak(e.message)
     for i in items:
         if twitter.utils.is_allowed(i) == True:
             if config.main["general"]["reverse_timelines"] == False:
                 self.db.settings[self.name_buffer].insert(0, i)
             else:
                 self.db.settings[self.name_buffer].append(i)
     if config.main["general"]["reverse_timelines"] == False:
         for i in items:
             if twitter.utils.is_allowed(i) == True:
                 tweet = self.compose_function(i, self.db)
                 self.list.insert_item(True, *tweet)
     else:
         for i in items:
             if twitter.utils.is_allowed(i) == True:
                 tweet = self.compose_function(i, self.db)
                 self.list.insert_item(False, *tweet)
     output.speak(_(u"%s items retrieved") % (len(items)))
Beispiel #40
0
 def get_more_items(self):
  if config.main["general"]["reverse_timelines"] == False:
   last_id = self.db.settings[self.name_buffer][0]["id"]
  else:
   last_id = self.db.settings[self.name_buffer][-1]["id"]
  try:
   items = twitter.starting.get_more_items(self.function, self.twitter, count=config.main["general"]["max_tweets_per_call"], max_id=last_id, screen_name=self.argumento)
  except TwythonError as e:
   output.speak(e.message)
  for i in items:
   if twitter.utils.is_allowed(i) == True:
    if config.main["general"]["reverse_timelines"] == False:
     self.db.settings[self.name_buffer].insert(0, i)
    else:
     self.db.settings[self.name_buffer].append(i)
  if config.main["general"]["reverse_timelines"] == False:
   for i in items:
    if twitter.utils.is_allowed(i) == True:
     tweet = self.compose_function(i, self.db)
     self.list.insert_item(True, *tweet)
  else:
   for i in items:
    if twitter.utils.is_allowed(i) == True:
     tweet = self.compose_function(i, self.db)
     self.list.insert_item(False, *tweet)
  output.speak(_(u"%s items retrieved") % (len(items)))
Beispiel #41
0
	def OnChar(self, evt):
		evt.Skip()
		if evt.GetKeyCode()==wx.WXK_F2:  
			if globalVars.currentSms.Chunks.Count: 
				output.speak(_("SMS %d, %d characters left, Current price %s.")%(globalVars.currentSms.Chunks.Count,globalVars.currentSms.Chunks[-1].CharactersLeft,globalVars.currentSms.PriceToText))
			else:
				output.speak(_("Empty"))
Beispiel #42
0
def modal_dialog(dialog, *args, **kwargs):
    dlg = dialog(*args, **kwargs)
    if dlg.ShowModal() != wx.ID_OK:
        output.speak(_("Canceled."), True)
        canceled = True
        raise WXDialogCanceled()
    return dlg
Beispiel #43
0
 def on_attach_audio(self, evt):
  evt.Skip()
  logging.debug("Attempting to attach audio file...")
  self.recording_dlg = dlg = RecordingDialog(parent=self.pane.Parent)
  if dlg.ShowModal() != wx.ID_OK:
   dlg.cleanup()
   return output.speak(_("Canceled."), True)
  try:
   dlg.postprocess()
   output.speak(_("Attaching..."), True)
   baseUrl = 'http://api.twup.me/post.json' if config.main['AudioServices']['service'] == 'twup.me' else 'http://sndup.net/post.php'
   if config.main['AudioServices']['service'] == 'sndup.net' and len(config.main['AudioServices']['sndUpAPIKey']) > 0:
    uploadUrl = baseUrl + '?apikey=' + config.main['AudioServices']['sndUpAPIKey']
   else:
    uploadUrl = baseUrl
   logging.debug("Upload url: %s" % uploadUrl)
   self.upload_dlg = UploadDialog(parent=self, title=_("Upload in progress"), field='file', url=uploadUrl, filename=dlg.file, completed_callback=self.upload_completed)
   self.upload_dlg.Show(True)
   try:
    self.upload_dlg.perform_threaded()
   except:
    logging.exception("Unable to perform upload")
  except:
   logging.exception("Unable to upload audio file to %s" % config.main['AudioServices']['service'])
   dlg.cleanup()
   return output.speak(_("There was an error attaching the file."), True)
Beispiel #44
0
 def BufferConfigDialog(self):
  """Displays a dialog in which you can set buffer speciffic properties."""

  if not hasattr(self.session, 'buffers') or len(self.session.buffers)==0:
   return output.speak(_("No buffers in this session."), 1)
  frame = self.session.frame
  #FIXME!
  try:
   if self.session.kind == "twitter":
    new = gui.configuration.twitter.BufferConfigDialog(self.session, frame, wx.ID_ANY, title=_("%s Buffer Configuration") % self.session.name)
   elif self.session.kind == "solona":
    new = core.gui.solona.buffers.BufferConfigDialog(self.session, frame, wx.ID_ANY, title=_("%s Buffer Configuration") % self.session.name)
   elif self.session.kind == "facebook":
    new = core.gui.facebook.buffers.BufferConfigDialog(self.session, frame, wx.ID_ANY, title=_("%s Buffer Configuration") % self.session.name)
   elif self.session.kind == "bing":
    new = core.gui.bing.buffers.BufferConfigDialog(self.session, frame, wx.ID_ANY, title=_("%s Buffer Configuration") % self.session.name)
   elif self.session.kind == "rss":
    new = core.gui.rss.buffers.BufferConfigDialog(self.session, frame, wx.ID_ANY, title=_("%s Buffer Configuration") % self.session.name)
   else:
    new = ThrowException
  except:
   return logging.exception("%s: Failure in buffer configuration in session" % self.session.name)
  new.SetDefaultValues()
  if new.ShowModal() == wx.ID_OK:
   new.SetNewConfigValues()
   output.speak(_("Configuration saved."), 1)
   dispatcher.send(sender=self.session, signal=signals.config_saved)
  else:
   output.speak(_("Configuration canceled."), True)
  self.session.frame.Show(False)
  new.Destroy()
Beispiel #45
0
 def favorite_tweet(self, buffer=None, index=None):
  twitter_id = buffer[index]['id']
  post_type = buffer.get_item_type(index)
  if post_type != _("tweet"):
   return output.speak(_("You can like only a tweet."), True)
  output.speak(_("You like this tweet"), True)
  self.api_call('create_favorite', action=_("Liking"), id=twitter_id)
Beispiel #46
0
 def Retweet (self, buffer=None, index=None):
  """Allows you to retweet (RT) the current tweet."""

  try:
   user = buffer.get_screen_name(index)
   text = templates.retweetTemplate(user, buffer.get_text(index))
   if 'retweeted_status' not in buffer[index]:
    id = buffer[index]['id']
   else:
    id = buffer[index]['retweeted_status']['id']
  except:
   logging.debug("Retweeter: Unable to retrieve post to reply to.")
   return output.speak(_("Item is not a post."), True)
  if self.session.config['UI']['DMSafeMode'] and 'source' not in buffer[index]:
   logging.debug("Retweeter: Preventing retweet of direct message in DM safe mode...")
   return output.speak(_("Cannot retweet a direct message while DM safe mode is enabled."), True)
  if self.session.is_current_user(user):
   logging.debug("Retweeter: Preventing retweet of user's own tweet...")
   return output.speak(_("Cannot retweet your own tweet."), True)
  title="Retweet"
  choice = 0
  if self.session.config['UI']['RTStyle'] == 0 and 'source' in buffer[index]:
   choice = question_dialog(caption=_("Retweet"), message=_("Would you like to add a comment?"))
   if choice == wx.ID_CANCEL:
    return output.speak(_("Canceled."), True)
   elif choice == wx.ID_NO:
    return call_threaded(self.session.post_retweet, id)
   else:
    return   self.NewTweet(buffer, index, text, title)
  elif self.session.config['UI']['RTStyle'] == 1:
   logging.debug("Retweeter: Automatically retweeting...")
   call_threaded(self.session.post_retweet, id)
  elif self.session.config['UI']['RTStyle'] == 2 or 'source' not in buffer[index]:
   self.NewTweet(buffer, index, text, title)
Beispiel #47
0
 def retrieve_access_token (self):
  output.speak(_("Please wait while an access token is retrieved from Twitter."), True)
  httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', 8080), Handler)
  twitterDataOrig = str(self.config['oauth']['twitterData'])
  trans = maketrans("-_~", "+/=")
  twitterDataTrans = twitterDataOrig.translate(trans)
  twitterData = b64decode(twitterDataTrans)
  twitterData = literal_eval(twitterData)
  tw = Twython(twitterData[0], twitterData[1], auth_endpoint='authorize')
  auth = tw.get_authentication_tokens("http://127.0.0.1:8080")
  webbrowser.open_new_tab(auth['auth_url'])
  global logged, verifier
  logged = False
  while logged == False:
   httpd.handle_request()
  self.auth_handler = Twython(twitterData[0], twitterData[1], auth['oauth_token'], auth['oauth_token_secret'])
  token = self.auth_handler.get_authorized_tokens(verifier)
  output.speak(_("Retrieved access token from Twitter."), True)
  httpd.server_close()
  data = [token['oauth_token'], token['oauth_token_secret']]
  eData = dumps(data)
  trans = maketrans("+/=", "-_~")
  eData = b64encode(eData)
  eData = eData.translate(trans)
  self.config['oauth']['userData'] = eData
  self.login()
  del (httpd, auth, tw, token, logged, verifier, twitterData, twitterDataOrig, data, edata, self.auth_handler)
Beispiel #48
0
 def SocialNetwork(self):
  """Creates a buffer containing your social network based on the choice selected."""

  dlg = wx.SingleChoiceDialog(None, _("Choose your social network:"), _("Social Network"), [_("Users whom I follow and who also follow me"), _("Users whom I follow but who do not follow me"), _("Users who follow me but whom I do not follow")])
  dlg.Raise()
  if dlg.ShowModal() == wx.ID_OK:
   followers = None
   friends = None
   for i in self.session.buffers:
    if hasattr(i, 'is_followers_buffer') and i.is_followers_buffer:
     followers = i
    if hasattr(i, 'is_friends_buffer') and i.is_friends_buffer:
     friends = i
    if followers and friends:
     break
   if not (followers and friends):
    return output.speak(_("Please launch both your followers and friends buffers before attempting to create a social network."), 1)
   elif not (len(followers) and len(friends)):
    return output.speak(_("Cannot create social network from an empty followers or friends buffer."), 1)
   choice = dlg.GetStringSelection()
   if choice == _("Users whom I follow and who also follow me"):
    method = 'intersection'
   elif choice == _("Users whom I follow but who do not follow me"):
    method = 'friend_but_not_follower'
   else:
    method = 'follower_but_not_friend'
   self.session.register_buffer(_("Social Network: %s") % choice, buffers.SocialNetwork, prelaunch_message=_("Creating social network, please wait..."), method=method, mute=True)
Beispiel #49
0
def shutdown(ShutdownSkype=True, silent=False, restart=False):
	exited=False
	import launcher
	if ShutdownSkype and config.conf['general']['autoStopSkype']==True:
		logging.debug("Shutting down Skype.")
		try:
			globalVars.Skype.Client.Shutdown()
		except:
			logging.exception("Error shutting down Skype client.")
	else:
		pass
	if not silent:
		output.speak(_("Goodbye!"), True)
	logging.debug("Closing all open windows.")
	try:
		for child in globalVars.Frame.GetChildren():
			wx.CallAfter(child.Destroy)
	except: logging.exception("Error, couldn't destroy open windows.")
	try: globalVars.Hotkey.unregisterHotkeys()
	except: logging.exception("Error unregistering hotkeys.")
	globalVars.Frame.Destroy()
	wx.GetApp().ExitMainLoop()
	exited=True
	if restart and exited:
		launcher.restartProcess()
 def start_recording(self):
  self.dialog.disable_control("attach_exists")
  self.file = tempfile.mktemp(suffix='.wav')
  self.recording = sound.recording(self.file)
  self.recording.play()
  self.dialog.set("record", _(u"&Stop"))
  output.speak(_(u"Recording"))
Beispiel #51
0
def shutdown(ShutdownSkype=True, silent=False, restart=False):
    exited = False
    import launcher

    if ShutdownSkype and config.conf["general"]["autoStopSkype"] == True:
        logging.debug("Shutting down Skype.")
        try:
            globalVars.Skype.Client.Shutdown()
        except:
            logging.exception("Error shutting down Skype client.")
    else:
        pass
    if not silent:
        output.speak(_("Goodbye!"), True)
    logging.debug("Closing all open windows.")
    try:
        for child in globalVars.Frame.GetChildren():
            wx.CallAfter(child.Destroy)
    except:
        logging.exception("Error, couldn't destroy open windows.")
    try:
        globalVars.Hotkey.unregisterHotkeys()
    except:
        logging.exception("Error unregistering hotkeys.")
    globalVars.Frame.Destroy()
    wx.GetApp().ExitMainLoop()
    exited = True
    if restart and exited:
        launcher.restartProcess()
Beispiel #52
0
 def start_recording(self):
     self.dialog.disable_control("attach_exists")
     self.file = tempfile.mktemp(suffix='.wav')
     self.recording = sound.recording(self.file)
     self.recording.play()
     self.dialog.set("record", _(u"&Stop"))
     output.speak(_(u"Recording"))
Beispiel #53
0
def authenticate():
    """Authenticate with facebook so you can make api calls that require auth.

    Alternatively you can just set the ACCESS_TOKEN global variable in this
    module to an access token you get from facebook.

    If you want to request certain permissions, set the AUTH_SCOPE global
    variable to the list of permissions you want.
    """
    global ACCESS_TOKEN, APP_ID, APP_SECRET, LOCAL_FILE
    needs_auth = True
    if needs_auth:
        output.speak(
            "Logging you into facebook... Plese accept any dialog from facebook"
        )
        webbrowser.open('https://www.facebook.com/dialog/oauth?' +
                        urlencode({
                            'client_id': APP_ID,
                            'redirect_uri': REDIRECT_URI,
                            'response_type': 'token',
                            'scope': ','.join(AUTH_SCOPE)
                        }))

        httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', SERVER_PORT),
                                          _RequestHandler)
        while ACCESS_TOKEN is None:
            httpd.handle_request()
    # extend short-life access token with a long life one.
    if os.path.exists(LOCAL_FILE):
        os.remove(LOCAL_FILE)
    fb = facebook.GraphAPI(ACCESS_TOKEN)
    data = fb.extend_access_token(APP_ID, APP_SECRET)
    open(LOCAL_FILE, "w").write(json.dumps(data))
Beispiel #54
0
def handleVoicemail(action, *args):
	vm=globalVars.voicemail
	if vm:
		voicemail.checkVoicemail(False, True)
	if action == 'getStatus':
		if not globalVars.voicemailEvent:
			return output.speak(_("There are no voicemails."))
		else:
			return output.speak(globalVars.voicemailEvent)
	elif action == 'open':
		if vm:
			try:
				vm.Open()
			except:
				output.speak(_("Error, cannot open that voicemail."))
		else:
			return output.speak(_("No voicemail to play."))
	elif action == 'delete':
		if vm:
			try:
				vm.Delete()
				output.speak(_("Voicemail deleted."), True)
			except:
				output.speak(_("Error, voicemail cannot be deleted."), True)
		else:
			return output.speak(_("No voicemail to delete."))
Beispiel #55
0
 def retrieve_update(self, *args, **kwargs):
  timeline = self.paged_update('get_user_timeline', since_id=self.get_max_twitter_id(), screen_name=self.username, include_rts=True, include_entities=True)
  if self.initial_update:
   self.initial_update = False
   if not len(self) and not timeline:
    output.speak("%s has no tweets." % self.name)
  return timeline
Beispiel #56
0
 def stop_recording(self):
  self.recording.stop()
  self.recording.free()
  output.speak(_(u"Stopped"))
  self.recorded = True
  self.record.SetLabel(_(u"Record"))
  self.file_attached()
Beispiel #57
0
 def onView(self, ev):
     ev.Skip()
     if self.lista.get_count() == 0: return
     list_id = self.db.settings["lists"][self.lista.get_selected()]["id"]
     list_updated = self.twitter.twitter.get_specific_list(list_id=list_id)
     self.db.settings["lists"][self.lista.get_selected()] = list_updated
     if list_updated["slug"] not in config.main["other_buffers"]["lists"]:
         config.main["other_buffers"]["lists"].append(list_updated["slug"])
         output.speak(_(u"List opened"))
     else:
         output.speak(_(u"This list is arready opened."))
         return
     listUI = gui.buffers.lists.listPanel(self.nb,
                                          self.parent,
                                          list_updated["slug"] + "-list",
                                          argumento=utils.find_list(
                                              list_updated["slug"],
                                              self.db.settings["lists"]))
     self.nb.InsertSubPage(self.db.settings["buffers"].index("lists"),
                           listUI,
                           _(u"List for %s") % (list_updated["slug"], ))
     self.db.settings["buffers"].append(list_updated["slug"] + "-list")
     num = listUI.start_streams()
     listUI.put_items(num)
     listUI.sound = "tweet_timeline.wav"
     self.parent.stream2.disconnect()
     del self.parent.stream2
     self.parent.get_tls()