本文整理汇总了Python中utils.thread_utils.call_threaded函数的典型用法代码示例。如果您正苦于以下问题:Python call_threaded函数的具体用法?Python call_threaded怎么用?Python call_threaded使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call_threaded函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NewTweet
def NewTweet(self, buffer=None, index=None, text=u"", title=None, retweet=False, quote=False):
"""Allows you to post a new tweet.
"""
new = gui.NewTweetDialog(parent=self.session.frame, text=text, title=title)
new.retweet.Show(retweet)
new.quote.Show(quote)
new.message.SetInsertionPoint(0)
val=new.ShowModal()
if val==wx.ID_OK:
if new.retweet.GetValue():
return self.Retweet(buffer, index)
elif new.quote.GetValue():
return self.Quote(buffer, index)
else:
text = new.message.GetValue()
else:
logging.debug("User canceled post.")
return output.speak(_("Canceled."), True)
if len(text) > self.session.config['lengths']['tweetLength']:
logging.info("Tweet too long. Forcing edit.")
return self.NewTweet(buffer, index, text)
if new.delay:
delay_action(new.delay, self.session.post_update, text=text, action=_("tweet"))
else:
call_threaded(self.session.post_update, text=text)
示例2: Retweet
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)
示例3: setup_timer
def setup_timer (self, run_immediately=True):
if self.buffer_metadata['interval']:
self.timer = RepeatingTimer(self.buffer_metadata['interval'], self.update)
self.timer.start()
if run_immediately:
logging.info("%s: performing immediate update in buffer %s" % (self.session, self))
call_threaded(self.update, update_type=self._update_types['initial'])
示例4: Quote
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)
示例5: NewReply
def NewReply(self, buffer=None, index=None, text="", user=None):
"""Allows you to post a reply to a tweet."""
default = user
users = buffer.get_all_screen_names(index)
if 'source' not in buffer[index] and 'text' in buffer[index] and self.session.config['UI']['DMSafeMode']:
return self.NewDm(buffer, index, text)
if not self.session.config['UI']['replyToSelf']:
for n, u in enumerate(users):
if self.session.is_current_user(u):
users.remove(users[n])
if default:
users.insert(0, default)
if not users:
return output.speak(_("Unable to detect a user to reply to."), True)
new = modal_dialog(gui.NewReplyDialog, parent=self.session.frame, default=users[0], selection=users, title=_("Reply"), text=text)
user = new.selection.GetValue()
fulltext = templates.replyTemplate(user, new.message.GetValue())
if len(fulltext) > self.session.config['lengths']['tweetLength']:
i = fulltext.index(" ") + 1
return self.NewReply(buffer, index, fulltext[i:])
if new.delay:
delay_action(new.delay, self.session.post_reply, buffer=buffer, index=index, text=fulltext, action=_("reply"))
else:
call_threaded(self.session.post_reply, buffer=buffer, index=index, text=fulltext)
示例6: login_succeeded
def login_succeeded (self):
self.save_config()
output.speak(_("Logged into Twitter as %s") % self.username)
self.API_initialized()
self.setup_stream()
if self.config['UI']['autoLoadSearches']:
call_threaded(self.load_saved_searches)
if self.config['UI']['autoLoadLists']:
call_threaded(self.load_lists)
示例7: Unfollow
def Unfollow(self, buffer=None, index=None):
"""Allows you to unfollow, block, or report the specified user as a spammer."""
who = buffer.get_all_screen_names(index)
if not who:
output.speak(_("No users to unfollow detected in current post."), True)
return logging.debug("No users to unfollow detected in current post.")
new = modal_dialog(gui.UnfollowDialog, parent=self.session.frame, users=who)
who = new.users.GetValue()
action = new.action.GetSelection()
call_threaded(self.session.do_unfollow, who, action)
示例8: Follow
def Follow(self, buffer=None, index=None):
"""Allows you to follow the specified user."""
who = buffer.get_all_screen_names(index)
if not who:
output.speak(_("No users to follow detected in current post."), True)
return logging.debug("No users to follow detected in current post.")
new = modal_dialog(gui.FollowDialog, parent=self.session.frame, users=who)
who = new.users.GetValue()
updates = new.updates.GetValue()
call_threaded(self.session.follow, who, updates)
示例9: ViewUserLists
def ViewUserLists(self, buffer = None, index = None):
"""View the public lists a user has created."""
who = buffer.get_all_screen_names(index)
dlg = gui.UserListDialog(parent = self.session.frame, title = _("Select user"), users = who)
dlg.setup_users()
dlg.finish_setup()
if dlg.ShowModal() != wx.ID_OK:
return output.speak(_("Canceled."), True)
user = dlg.users.GetValue()
dlg.Destroy()
call_threaded(self.session.list_manager(screen_name = user))
示例10: NewDm
def NewDm(self, buffer=None, index=None, user="", text=""):
"""Allows you to send a new direct message to a user."""
who = buffer.get_all_screen_names(index)
new = modal_dialog(gui.NewDirectDialog, parent=self.session.frame, default=who[0], selection=who, title=_("Direct message"), text=text)
user = new.selection.GetValue()
text = new.message.GetValue()
if len(text) > self.session.config['lengths']['tweetLength']:
logging.info("Direct message too long. Forcing edit.")
return self.NewDm (buffer, index, user, text)
if new.delay:
delay_action(new.delay, self.session.post_dm, text=text, buffer=buffer, index=index, user=user, action=_("dm"))
else:
call_threaded(self.session.post_dm, buffer=buffer, index=index, user=user, text=text)
示例11: RelationshipStatus
def RelationshipStatus(self, buffer=None, index=None):
"""Retrieve and speak the current relationship between yourself and the user associated with the focused item"""
try:
name = buffer.get_screen_name(index)
except:
output.speak(_("No user detected in current item."), 1)
return
try:
name = buffer.get_name(index)
except:
pass
output.speak(_("Retrieving relationship status for %s") % name, True)
call_threaded(self.session.relationship_status, buffer=buffer, index=index)
示例12: RelationshipStatusBetween
def RelationshipStatusBetween(self, buffer=None, index=None):
"""Determine the relationship status between any two users"""
username = self.session.username
who = buffer.get_all_screen_names(index)
if len(who) > 1 or who[0] != "":
try:
who.remove(username)
except:
pass
who.append(username)
new = modal_dialog(gui.RelationshipStatusDialog, parent=self.session.frame, users=who)
user1 = new.users.GetValue()
user2 = new.users2.GetValue()
output.speak(_("Retrieving relationship status between %s and %s") % (user1, user2), True)
call_threaded(self.session.relationship_status_between, user1, user2)
示例13: RegisterSession
def RegisterSession (name, type, *args, **kwargs):
"""Registers session in sessions list."""
global current_session
global sessions
logging.debug("Sessions: Registering new %s session named %s. Args: %s kwargs: %s" % (type, name, args, kwargs))
try:
new = getattr (session, type) (name=name, type=type, *args, **kwargs)
except:
return logging.exception("Unable to initialize an instance of session.%s " % type)
if SessionExists(new):
return logging.warning("Suppressed duplicate registration of session %s" % name)
AddSession (new)
try:
call_threaded(dispatcher.send, sender=new, signal=signals.session_created)
except:
logging.exception("sessions.RegisterSession: Something errored when the NewSession signal was sent.")
return sessions.index(new)
示例14: RemoveSession
def RemoveSession(session, end=False, delete = False):
"""Remove session from global sessions list. Accepts a session object."""
global sessions
logging.info("Removing session %s from global list." % session.name)
index = GetSessionIndex(session)
index = index - 1
if not end:
SetSession(index)
try:
sessions.remove(session)
config.main['sessions']['sessions'].remove(session_descriptor(session))
config.main.write()
except:
pass
try:
call_threaded(session.shutdown, end=end, delete=delete)
except:
logging.exception("Error deactivating session...")
dispatcher.send(sender=session, signal=signals.session_destroyed)
output.AnnounceSession()
示例15: __init__
def __init__(self, store=False, term="", saved=False, saved_id=0, *args, **kwargs):
self.init_done_event = threading.Event()
super(Search, self).__init__(*args, **kwargs)
self.initial_update = True
self.term = unicode(term)
self.saved = saved or bool(saved_id)
self.saved_id = saved_id
if saved:
call_threaded(self.create_saved_search)
self.item_name = _("result for %s") % self.term
self.item_name_plural = _("results for %s") % self.term
self.item_sound = self.session.config['sounds']['resultReceived']
self.default_template = 'search'
self.store_args({'store':store, 'term':term, 'saved':saved})
self.set_flag('temp', not store)
if 'name' in self.item_fields:
del self.item_fields['name']
if 'geo' in self.item_fields:
del self.item_fields['geo']
#self.set_field('screen_name', _("Screen Name"), 'from_user')
self.init_done_event.set()