本文整理汇总了Python中utils.thread_utils.call_threaded函数的典型用法代码示例。如果您正苦于以下问题:Python call_threaded函数的具体用法?Python call_threaded怎么用?Python call_threaded使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call_threaded函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:craigbrett17,项目名称:TheQube,代码行数:25,代码来源:interface.py
示例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)
开发者ID:Piciok,项目名称:TheQube,代码行数:34,代码来源:interface.py
示例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'])
开发者ID:Piciok,项目名称:TheQube,代码行数:7,代码来源:updating.py
示例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)
开发者ID:craigbrett17,项目名称:TheQube,代码行数:31,代码来源:interface.py
示例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)
开发者ID:Piciok,项目名称:TheQube,代码行数:25,代码来源:interface.py
示例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)
开发者ID:FBSLikan,项目名称:TheQube,代码行数:9,代码来源:twitter.py
示例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)
开发者ID:Piciok,项目名称:TheQube,代码行数:11,代码来源:interface.py
示例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)
开发者ID:Piciok,项目名称:TheQube,代码行数:11,代码来源:interface.py
示例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))
开发者ID:Piciok,项目名称:TheQube,代码行数:12,代码来源:interface.py
示例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)
开发者ID:Piciok,项目名称:TheQube,代码行数:14,代码来源:interface.py
示例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)
开发者ID:Piciok,项目名称:TheQube,代码行数:14,代码来源:interface.py
示例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)
开发者ID:Piciok,项目名称:TheQube,代码行数:16,代码来源:interface.py
示例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)
开发者ID:RN3ARA,项目名称:TheQube,代码行数:17,代码来源:sessions.py
示例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()
开发者ID:RN3ARA,项目名称:TheQube,代码行数:20,代码来源:sessions.py
示例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()
开发者ID:Oire,项目名称:TheQube,代码行数:21,代码来源:search.py
示例16: setup_stream
def setup_stream(self):
twitterDataOrig = str(self.config['oauth']['twitterData'])
trans = maketrans("-_~", "+/=")
twitterDataTrans = twitterDataOrig.translate(trans)
twitterData = b64decode(twitterDataTrans)
twitterData = literal_eval(twitterData)
userDataOrig = str(self.config['oauth']['userData'])
userDataTrans = userDataOrig.translate(trans)
userData = b64decode(userDataTrans)
userData = literal_eval(userData)
consumer = oauth2.Token(key=twitterData[0], secret=twitterData[1])
token = oauth2.Token(key=userData[0], secret=userData[1])
self.streamer = stream.UserStreamer(consumer=consumer, token=token, callback=self.stream_callback, reconnected_callback=self.update_all_buffers())
logging.debug("Twitter user stream created.")
self.daemon_stream = call_threaded(self.streamer.stream)
logging.debug("Twitter user Stream connected.")
开发者ID:FBSLikan,项目名称:TheQube,代码行数:16,代码来源:twitter.py
示例17: SetNewConfigValues
def SetNewConfigValues (self):
logging.debug("Saving default buffer configuration from dialog.")
self.session.config['updates']['checkInterval'] = int(self.panels[0].checkInterval.GetValue()) * 60
logging.info("Check interval set to: %s" % self.session.config['updates']['checkInterval'])
self.session.config['counts']['retrieveCount'] = int(self.panels[0].retrieveCount.GetValue()) or 100
logging.info("Retrieve count set to: %s" % self.session.config['counts']['retrieveCount'])
self.session.config['updates']['maxAPIPerUpdate'] = int(self.panels[0].maxAPIPerUpdate.GetValue()) or 1
logging.info("Max API calls per update set to: %s" % self.session.config['updates']['maxAPIPerUpdate'])
self.session.config['sounds']['defaultBufferMute'] = self.panels[0].mute.GetValue()
logging.info("Mute set to: %s" % self.session.config['sounds']['mute'])
if self.panels[0].applyToAll.GetValue():
apply = call_threaded(self.ApplyDefaultBufferSettingsToAll)
else:
logging.debug("Saving buffer configuration from dialog.")
for panel in self.panels[1:]:
if panel.buffer.buffer_metadata.has_key('interval') and panel.buffer.buffer_metadata['interval'] != panel.checkInterval.GetValue() * 60:
panel.buffer.set_new_interval(panel.checkInterval.GetValue() * 60)
logging.info("Update interval for buffer %s set to: %s" % (panel.buffer.name, panel.buffer.buffer_metadata['interval'] / 60))
if panel.buffer.buffer_metadata.has_key('retrieveCount') and panel.buffer.buffer_metadata['retrieveCount'] != panel.retrieveCount.GetValue():
panel.buffer.count = panel.buffer.buffer_metadata['retrieveCount'] = panel.retrieveCount.GetValue()
logging.info("Retrieve count for buffer %s set to: %s" % (panel.buffer.name, panel.buffer.buffer_metadata['retrieveCount']))
if panel.buffer.buffer_metadata.has_key('maxAPIPerUpdate') and panel.buffer.buffer_metadata['maxAPIPerUpdate'] != panel.maxAPIPerUpdate.GetValue():
panel.buffer.maxAPIPerUpdate = panel.buffer.buffer_metadata['maxAPIPerUpdate'] = panel.maxAPIPerUpdate.GetValue()
logging.info("Retrieve count for buffer %s set to: %s" % (panel.buffer.name, panel.buffer.buffer_metadata['maxAPIPerUpdate']))
if panel.buffer.buffer_metadata.has_key('sounds') and panel.buffer.buffer_metadata['sounds'].has_key('mute') and panel.buffer.buffer_metadata['sounds']['mute'] != panel.mute.GetValue():
panel.buffer.buffer_metadata['sounds']['mute'] = panel.mute.GetValue()
logging.info("Mute for buffer %s set to: %s" % (panel.buffer.name, panel.buffer.buffer_metadata['sounds']['mute']))
if not panel.buffer.get_flag('fixed_template'):
if panel.useDefaultClipboard.GetValue():
if 'clipboard' in panel.buffer.buffer_metadata:
del panel.buffer.buffer_metadata['clipboard']
logging.info("Clipboard template for {0} was reset to default.".format(panel.buffer.name))
else:
panel.buffer.buffer_metadata['clipboard'] = panel.clipboard.GetValue()
logging.info("Clipboard template for buffer %s set to: %s." % (panel.buffer.name, panel.buffer.buffer_metadata['clipboard']))
if panel.useDefaultSpoken.GetValue():
if 'spoken' in panel.buffer.buffer_metadata:
del panel.buffer.buffer_metadata['spoken']
logging.info("Spoken template for {0} was reset to default.".format(panel.buffer.name))
else:
panel.buffer.buffer_metadata['spoken'] = panel.spoken.GetValue()
logging.info("Spoken template for buffer %s set to: %s." % (panel.buffer.name, panel.buffer.buffer_metadata['spoken']))
开发者ID:FBSLikan,项目名称:TheQube,代码行数:42,代码来源:main.py
示例18: unlisten
def unlisten (self):
call_threaded(self._unlisten)
开发者ID:FBSLikan,项目名称:TheQube,代码行数:2,代码来源:http_server.py
示例19: process_command
def process_command (self, command, kws={}):
#Given a command and keywords from the handler, actually calls the appropriate command from the interface.
basepath, func = command
if basepath in self.urlmap:
logging.debug("%s: Base path %s found in URL map." % (self.name, basepath))
call_threaded(self._exec_command, basepath, func, kws)
开发者ID:FBSLikan,项目名称:TheQube,代码行数:6,代码来源:http_server.py
示例20: SetNewConfigValues
def SetNewConfigValues(self):
logging.debug("Saving default buffer configuration from dialog.")
self.session.config["updates"]["checkInterval"] = int(self.panels[0].checkInterval.GetValue()) * 60
logging.info("Check interval set to: %s" % self.session.config["updates"]["checkInterval"])
self.session.config["counts"]["retrieveCount"] = int(self.panels[0].retrieveCount.GetValue()) or 100
logging.info("Retrieve count set to: %s" % self.session.config["counts"]["retrieveCount"])
self.session.config["updates"]["maxAPIPerUpdate"] = int(self.panels[0].maxAPIPerUpdate.GetValue()) or 1
logging.info("Max API calls per update set to: %s" % self.session.config["updates"]["maxAPIPerUpdate"])
self.session.config["sounds"]["defaultBufferMute"] = self.panels[0].mute.GetValue()
logging.info("Mute set to: %s" % self.session.config["sounds"]["mute"])
if self.panels[0].applyToAll.GetValue():
apply = call_threaded(self.ApplyDefaultBufferSettingsToAll)
else:
logging.debug("Saving buffer configuration from dialog.")
for panel in self.panels[1:]:
if (
panel.buffer.buffer_metadata.has_key("interval")
and panel.buffer.buffer_metadata["interval"] != panel.checkInterval.GetValue() * 60
):
panel.buffer.set_new_interval(panel.checkInterval.GetValue() * 60)
logging.info(
"Update interval for buffer %s set to: %s"
% (panel.buffer.name, panel.buffer.buffer_metadata["interval"] / 60)
)
if (
panel.buffer.buffer_metadata.has_key("retrieveCount")
and panel.buffer.buffer_metadata["retrieveCount"] != panel.retrieveCount.GetValue()
):
panel.buffer.count = panel.buffer.buffer_metadata["retrieveCount"] = panel.retrieveCount.GetValue()
logging.info(
"Retrieve count for buffer %s set to: %s"
% (panel.buffer.name, panel.buffer.buffer_metadata["retrieveCount"])
)
if (
panel.buffer.buffer_metadata.has_key("maxAPIPerUpdate")
and panel.buffer.buffer_metadata["maxAPIPerUpdate"] != panel.maxAPIPerUpdate.GetValue()
):
panel.buffer.maxAPIPerUpdate = panel.buffer.buffer_metadata[
"maxAPIPerUpdate"
] = panel.maxAPIPerUpdate.GetValue()
logging.info(
"Retrieve count for buffer %s set to: %s"
% (panel.buffer.name, panel.buffer.buffer_metadata["maxAPIPerUpdate"])
)
if (
panel.buffer.buffer_metadata.has_key("sounds")
and panel.buffer.buffer_metadata["sounds"].has_key("mute")
and panel.buffer.buffer_metadata["sounds"]["mute"] != panel.mute.GetValue()
):
panel.buffer.buffer_metadata["sounds"]["mute"] = panel.mute.GetValue()
logging.info(
"Mute for buffer %s set to: %s"
% (panel.buffer.name, panel.buffer.buffer_metadata["sounds"]["mute"])
)
if not panel.buffer.get_flag("fixed_template"):
if panel.useDefaultClipboard.GetValue():
if "clipboard" in panel.buffer.buffer_metadata:
del panel.buffer.buffer_metadata["clipboard"]
logging.info("Clipboard template for {0} was reset to default.".format(panel.buffer.name))
else:
panel.buffer.buffer_metadata["clipboard"] = panel.clipboard.GetValue()
logging.info(
"Clipboard template for buffer %s set to: %s."
% (panel.buffer.name, panel.buffer.buffer_metadata["clipboard"])
)
if panel.useDefaultSpoken.GetValue():
if "spoken" in panel.buffer.buffer_metadata:
del panel.buffer.buffer_metadata["spoken"]
logging.info("Spoken template for {0} was reset to default.".format(panel.buffer.name))
else:
panel.buffer.buffer_metadata["spoken"] = panel.spoken.GetValue()
logging.info(
"Spoken template for buffer %s set to: %s."
% (panel.buffer.name, panel.buffer.buffer_metadata["spoken"])
)
开发者ID:Piciok,项目名称:TheQube,代码行数:75,代码来源:main.py
注:本文中的utils.thread_utils.call_threaded函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论