本文整理汇总了Python中pubsub.pub.subscribe函数的典型用法代码示例。如果您正苦于以下问题:Python subscribe函数的具体用法?Python subscribe怎么用?Python subscribe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subscribe函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: init
def init(serv):
serv.loadConfig(populate=False)
# Minecraft part of the Hub
wsFactory = serv.factories["WorldServerFactory"] = WorldServerFactory(serv)
# Populate configuration.
serv.populateConfig()
# Load up the database.
serv.loadDatabase()
# Start up everything.
# Until Endpoint has reconnection abilities, this is unused
#TCP4ClientEndpoint(reactor, serv.settings["world"]["main"]["hub-ip"],
# serv.settings["world"]["main"]["hub-port"]).connect(serv.factories["WorldServerFactory"]).addCallback(serv.factories["WorldServerFactory"])
def afterLoadedPreloadedWorlds():
reactor.connectTCP(wsFactory.settings["main"]["hub-ip"], wsFactory.settings["main"]["hub-port"], wsFactory)
def afterLoadedSelfID():
serv.factories["WorldServerFactory"].loadPreloadedWorlds().addCallback(noArgs(afterLoadedPreloadedWorlds))
def afterDBAPIReady():
# Get our ID
wsFactory.loadID().addCallback(noArgs(afterLoadedSelfID))
pub.subscribe(afterDBAPIReady, "cloudbox.common.service.databaseAPIReady")
reactor.run()
开发者ID:tyteen4a03,项目名称:cloudBox,代码行数:29,代码来源:run.py
示例2: __init__
def __init__(self):
"""Constructor"""
screenwidth = root.winfo_screenwidth()
screenheight = root.winfo_screenheight()
Tk.Toplevel.__init__(self)
self.overrideredirect(True)
self.geometry("{0}x{1}+0+0".format(screenwidth, screenheight))
canvasFrame = Tk.Frame(self, width = screenwidth, height = (screenheight - 100))
instructionFrame = Tk.Frame(self, width = screenwidth, height = 50)
self.canvas = Tk.Canvas(canvasFrame, width = screenwidth, height = (screenheight - 100))
# create the button
calibrateButton = Tk.Button(instructionFrame, text="Start Calibration", command=self.ovalChange)
exitButton = Tk.Button(instructionFrame, text="Quit", command=self.quitCal)
canvasFrame.grid()
instructionFrame.grid(row = 1)
self.canvas.grid()
calibrateButton.grid(column = 0)
exitButton.grid(column = 1, row = 0)
pub.subscribe(self.listener, "userFrameClosed")
开发者ID:Qwertycal,项目名称:19520-Eye-Tracker,代码行数:26,代码来源:SystemGUI.py
示例3: __init__
def __init__(self, rect):
super(TrackButtonBar, self).__init__()
self.selected_index = 0
self.tiles_to_show = 0
self.rect = rect
self.dirty = True
pub.subscribe(self.on_key_up, "input.key-up")
开发者ID:bitcraft,项目名称:Platakart,代码行数:7,代码来源:trackselect.py
示例4: __init__
def __init__(self):
self.poller = select.poll()
pub.subscribe(tracelogger, pub.ALL_TOPICS)
pub.sendMessage('lifecycle', msg='Starting up')
# Register modules
handlers.insteon.InsteonHandler(self, dev='/dev/ttyS0')
handlers.tcpsocket.TCPHandler(self, port=2062)
Arduino(self,dev='/dev/ttyACM0')
holdme = Light(self)
holdme2 = ZabbixPush(self)
testdev = X10('fishtank', 'L4', False)
#self.add_io_handler(sys.stdin.fileno(), stdinhandler)
# load configs?
# main loop
pub.sendMessage('lifecycle', msg='Starting main loop')
while (True):
try:
active=self.poller.poll()
for (fd, event) in active:
# Call the FD event handler
for i in self.FDs:
if i.fileno() == fd:
self.FDs[i](i, event)
break
except KeyboardInterrupt:
break
pub.sendMessage('lifecycle', msg='Quiting')
开发者ID:crackmonkey,项目名称:Rosie,代码行数:35,代码来源:rosie.py
示例5: __init__
def __init__(self):
pub.subscribe(self.queue_file, 'new_file')
pub.subscribe(self.stop, 'wants_to_close')
self.thread = None
self.running = False
self.queue = queue.Queue()
开发者ID:bitcraft,项目名称:tailor,代码行数:7,代码来源:hotfolder.py
示例6: test_pubsub
def test_pubsub(self):
# Subscribe so we can catch the status update as it comes out.
nodeuuid = str(uuid.uuid4())
self.configuration.set_node_uuid(nodeuuid)
job_id = str(uuid.uuid4())
pub.subscribe(self.on_job_status_update, self.configuration.get_job_status_pub_topic(job_id))
# Now send off a job update. This should exit via the pub/sub system, but be dropped
# on the incoming side.
self.configuration.send_job_status(job_id, state='TEST')
status = self.wait()
self.assertEquals(status.job_id, job_id, "Job ID was not as expected.")
self.assertEquals(status.state, 'TEST', "Job status was not as expected.")
# Now, manually send a status and force it to go via the pub/sub system and
# back out again.
job_id = str(uuid.uuid4())
pub.subscribe(self.on_job_status_update, self.configuration.get_job_status_pub_topic(job_id))
message = paasmaker.common.configuration.JobStatusMessage(job_id, 'ROUNDTRIP', 'BOGUS')
message.unittest_override = True
self.backend.send_job_status(message)
status = self.wait()
self.assertEquals(status.job_id, job_id, "Job ID was not as expected.")
self.assertEquals(status.state, 'ROUNDTRIP', "Job status was not as expected.")
self.assertEquals(status.source, 'BOGUS', 'Source was correct.')
开发者ID:kaze,项目名称:paasmaker,代码行数:28,代码来源:backendredis.py
示例7: testDeadListener
def testDeadListener():
# create a listener for listeners that have died
class DeathListener(IgnoreNotificationsMixin):
listenerStr = ''
def notifyDeadListener(self, pubListener, topicObj):
assert topicObj.getName() == 'sadTopic'
#import pdb; pdb.set_trace()
#print 'hi again'
DeathListener.listenerStr = pubListener.name()
dl = DeathListener()
pub.addNotificationHandler( dl )
pub.setNotificationFlags(deadListener=True)
# define a topic, subscribe to it, and kill its listener:
class TempListener:
def __call__(self, **kwargs):
pass
def __del__(self):
# print 'being deleted'
pass
#def tempListener(): pass
tempListener = TempListener()
expectLisrStr, _ = getListenerID(tempListener)
pub.subscribe(tempListener, 'sadTopic')
del tempListener
# verify:
gc.collect() # for pypy: the gc doesn't work the same as cpython's
assert DeathListener.listenerStr.startswith(expectLisrStr), \
'"%s" !~ "%s"' % (DeathListener.listenerStr, expectLisrStr)
pub.addNotificationHandler(None)
pub.clearNotificationHandlers()
开发者ID:schollii,项目名称:pypubsub,代码行数:33,代码来源:test3c_pubsub3.py
示例8: __init__
def __init__(self, parent, global_store, vsrc_name, *args, **kwargs):
# If the device doesn't exist, give up.
try:
vsrc = global_store.devices[vsrc_name].device
except (KeyError, AttributeError):
self.Destroy()
return
Dialog.__init__(self, parent, title='Voltage source settings', *args, **kwargs)
self.vsrc_name = vsrc_name
# Dialog.
dialog_box = wx.BoxSizer(wx.VERTICAL)
## Settings panel.
self.panel = VoltageSourceSettingsPanel(self, global_store, vsrc)
dialog_box.Add(self.panel)
self.SetSizerAndFit(dialog_box)
# Subscriptions.
pub.subscribe(self.msg_device, 'device.added')
pub.subscribe(self.msg_device, 'device.removed')
开发者ID:mainCSG,项目名称:SpanishAcquisitionIQC,代码行数:25,代码来源:voltage_source.py
示例9: test_track_event_seveal_subscriptions
def test_track_event_seveal_subscriptions(self):
c = peachbox.scheduler.ConditionalEvent('c5')
e1 = peachbox.scheduler.Event('finished')
status = e1.status()
status['payload'] = {'latest_kafka_offset':123}
e2 = peachbox.scheduler.Event('timer')
status2 = e2.status()
status2['payload'] = {'timestamp':123456}
c.subscribe(e1)
c.subscribe(e2)
def receiver(param):
self.assertEqual(123, param['payload']['latest_kafka_offset'])
self.assertEqual(123456, param['payload']['timestamp'])
pub.subscribe(receiver, c.name())
def publish_in_process(event):
self.s.publish(event)
p1 = multiprocessing.Process(target=self.s.publish, args=(e1,))
p2 = multiprocessing.Process(target=self.s.publish, args=(e2,))
p1.start()
p2.start()
p1.join()
p2.join()
# Check if the counters are reset
subscriptions = c.get_subscriptions()
self.assertEqual({'finished':1, 'timer':1}, subscriptions)
开发者ID:Fabma,项目名称:peachbox,代码行数:32,代码来源:test_event.py
示例10: __init__
def __init__(self, parent):
super(OverviewWidget, self).__init__(parent)
self.label = QtGui.QLabel("Asymmetry")
self.parent = parent
self.active = False
self.left_front = OverviewView(self, "Left Front", 0)
self.left_hind = OverviewView(self, "Left Hind", 1)
self.right_front = OverviewView(self, "Right Front", 2)
self.right_hind = OverviewView(self, "Right Hind", 3)
self.overview_list = [self.left_front,
self.left_hind,
self.right_front,
self.right_hind]
self.asymmetry_layout = QtGui.QGridLayout()
self.asymmetry_layout.addWidget(self.left_front, 1, 0)
self.asymmetry_layout.addWidget(self.left_hind, 2, 0)
self.asymmetry_layout.addWidget(self.right_front, 1, 1)
self.asymmetry_layout.addWidget(self.right_hind, 2, 1)
self.main_layout = QtGui.QVBoxLayout()
self.main_layout.addLayout(self.asymmetry_layout)
self.main_layout.addStretch(1)
self.setLayout(self.main_layout)
pub.subscribe(self.active_widget, "active_widget")
开发者ID:ivoflipse,项目名称:Pawlabeling,代码行数:30,代码来源:overviewwidget.py
示例11: testNotifyByPrint
def testNotifyByPrint():
capture = captureStdout()
def listener1(arg1):
pass
pub.subscribe(listener1, 'baz')
pub.sendMessage('baz', arg1=123)
pub.unsubscribe(listener1, 'baz')
def doa():
def listener2():
pass
pub.subscribe(listener2, 'bar')
doa() # listener2 should be gc'd
gc.collect() # for pypy: the gc doesn't work the same as cpython's
topicMgr.delTopic('baz')
expect = """\
PUBSUB: New topic "baz" created
PUBSUB: Subscribed listener "listener1" to topic "baz"
PUBSUB: Start sending message of topic "baz"
PUBSUB: Sending message of topic "baz" to listener listener1
PUBSUB: Done sending message of topic "baz"
PUBSUB: Unsubscribed listener "listener1" from topic "baz"
PUBSUB: New topic "bar" created
PUBSUB: Subscribed listener "listener2" to topic "bar"
PUBSUB: Listener "listener2" of Topic "bar" has died
PUBSUB: Topic "baz" destroyed
"""
captured = capture.getvalue()
#print captured
#print repr(expect)
assert captured == expect, \
'\n'.join( unified_diff(expect.splitlines(), captured.splitlines(), n=0) )
开发者ID:schollii,项目名称:pypubsub,代码行数:35,代码来源:test2c_notify.py
示例12: __init__
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1)
self.CreateStatusBar(1)
pub.subscribe(self.change_statusbar, "change.statusbar")
tempheading = ((" ",10), (" ",15), (" ",10))
self.panel_login = panel_login(self, -1)
self.panes = {}
self.panes['base'] = self.panel_base = panel_base(self, -1) # top horizontal ctrls
self.panes['rereg_list'] = self.panel_rereg_list = panel_rereg_list(self, -1)
self.panes['edit_booking'] = self.edit_booking = edit_booking(self, -1)
self.panes['edit_courses'] = self.panel_courses = panel_courses_picker(self, -1)
self.panes['student_details'] = self.panel_student_details = cSiswaDetails(self, -1)
self.panes['add_edit_course'] = self.panel_add_edit_course = panel_add_edit_course(self, -1)
self.panes['course_bookings'] = self.panel_course_bookings = panel_course_bookings(self,-1)
self.panes['edit_rereg_status'] = self.panel_edit_rereg_status = panel_edit_rereg_status(self, -1)
self.panes['edit_booking_status'] = self.panel_edit_booking_status = panel_edit_booking_status(self, -1)
self.panes['edit_guardian_data'] = self.PanelGuardianData = panel_edit_guardian(self, 1)
self.panes['edit_booking_student_details'] = self.edit_booking_student_details = edit_booking_student_details(self, -1)
self.panes['course_fees'] = self.panel_course_fees = course_fees(self, -1)
self.panes['edit_schools'] = self.edit_school = edit_school(self, -1)
self.panes['edit_address'] = self.panel_edit_address = panel_edit_address(self, -1)
self.Bind(wx.EVT_CLOSE, self.OnClose, self)
self.__set_properties()
self.__do_layout()
self.__do_main()
开发者ID:ckSchool,项目名称:bucky,代码行数:29,代码来源:CKDB+MSDB+only.py
示例13: __init__
def __init__(self):
self.config = config.read('config.json')
if not 'twitch_id' in self.config:
raise config.ConfigurationError(
'Setting twitch_id incorrectly configured in config.json')
self.wx = wx.App()
self.plugins = plugins.PluginManager()
self.plugins.load('plugins/')
twitch_id = self.config['twitch_id']
login = self.config['services']['chat']['login']
bot_id = login['id']
bot_oauth = login['oauth']
chat.connect(bot_id, bot_oauth, twitch_id)
reactor.interleave(wx.CallAfter)
pub.subscribe(self.quit, 'command.quit')
self.icon = gui.Icon(self.plugins.plugins())
self.menu = gui.Menu(self.plugins.plugins())
self.wx.MainLoop()
开发者ID:ronald-d-rogers,项目名称:twitchy,代码行数:28,代码来源:twitchy.py
示例14: job_subscribe
def job_subscribe(self, job_id):
"""
This event handler subscribes to the supplied job, and also
the matching job tree. Future updates to this job and any jobs
in the tree are automatically sent along to the client.
The client is sent two messages: job.subscribed, with the entire
job tree in flat format, and job.tree, which is the entire job
tree in pretty format.
"""
if not self.configuration.is_pacemaker():
# We don't relay job information if we're not a pacemaker.
self.emit('error', 'This node is not a pacemaker.')
return
# Start listening to job status's after the first subscribe request.
if not self.job_listening:
pub.subscribe(self.on_job_status, 'job.status')
self.job_listening = True
def got_pretty_tree(tree):
# Send back the pretty tree to the client.
self.emit('job.tree', job_id, tree)
def got_flat_tree_subscribe(job_ids):
for job_id in job_ids:
self.job_subscribed[job_id] = True
self.emit('job.subscribed', list(job_ids))
# Subscribe to everything in the tree.
self.configuration.job_manager.get_pretty_tree(job_id, got_pretty_tree)
self.configuration.job_manager.get_flat_tree(job_id, got_flat_tree_subscribe)
开发者ID:kaze,项目名称:paasmaker,代码行数:32,代码来源:stream.py
示例15: __init__
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()
开发者ID:codeofdusk,项目名称:ProjectMagenta,代码行数:31,代码来源:audioUploader.py
示例16: __init__
def __init__(self,parent,model,tkmaster,**kwargs):
Tk.Frame.__init__(self,parent,**kwargs)
self.parent = parent
self.model = model
self.log_vars = list()
self.plotmode = 'scalar'
self.index=0
self.tkmaster = tkmaster
self.plotted_varid = None
self.selected_varid = None
self.selected_varname = ""
self.s_value = 0.0
pub.subscribe(self.listener_new_value_received,'var_value_update')
pub.subscribe(self.listener_var_selected,'new_var_selected')
# Widgets
self.liste = Tk.Listbox(self,height=1)
self.liste.grid(column=1,row=1,sticky='EW',pady=3,padx=3,rowspan=2)
self.scrollbar_liste = Tk.Scrollbar(self.liste)
self.scrollbar_liste.config(command = self.liste.yview)
self.liste.config(yscrollcommand = self.scrollbar_liste.set)
self.scrollbar_liste.pack(side=Tk.RIGHT)
#
self.bouton_add_var = Tk.Button(self, text="PLOT SELECTION", command = self.add_var_to_plot)
self.bouton_add_var.grid(column=0,row=1,rowspan=2,pady=3,padx=3,sticky='NSEW')
#
self.bouton_switch_mode = Tk.Button(self, text="REMOVE VAR", command = self.remove_var_from_plot)
self.bouton_switch_mode.grid(column=2,row=2,pady=3,padx=3)
#
self.f = Figure(figsize=(5,4), dpi=100)
self.a = self.f.add_subplot(111)
self.a.set_xlim([0, 127])
self.a.set_ylim([-255, 255])
self.line1, = self.a.plot([],[])
self.x = deque(maxlen=128)
self.y = deque(maxlen=128)
self.ymin = 0
self.ymax = 1
self.first = False
#
self.dataPlot = FigureCanvasTkAgg(self.f, master=self)
self.dataPlot.show()
self.dataPlot.get_tk_widget().grid(column=0,row=0,sticky='EW',pady=3,padx=3,columnspan=5)
#
self.selected_var_name = Tk.StringVar()
self.selected_var_name.set("No variable")
self.selected_var = Tk.Label(self,textvariable=self.selected_var_name,bd=2,relief=Tk.GROOVE)
self.selected_var.grid(column=2,row=1,sticky='EW',pady=3,padx=3)
#
self.selected_value = Tk.DoubleVar()
self.selected_value.set(0.0)
self.selected_var_val = Tk.Label(self,textvariable=self.selected_value,bd=2,relief=Tk.GROOVE)
self.selected_var_val.grid(column=3,row=1,sticky='EW',pady=3,padx=3)
开发者ID:DanFaudemer,项目名称:TFC,代码行数:60,代码来源:Plot2D_Frame.py
示例17: setUp
def setUp(self):
super(PeriodicManagerTest, self).setUp()
self.configuration = paasmaker.common.configuration.ConfigurationStub(0, ['pacemaker'], io_loop=self.io_loop)
self.configuration.set_node_uuid('test')
# Fire up the job manager.
self.configuration.startup_job_manager(self.stop)
self.wait()
# Inject test periodic manager plugins.
self.configuration.plugins.register(
'paasmaker.periodic.test',
'paasmaker.common.helper.periodicmanager.PeriodicTestPlugin',
{},
'Test Periodic plugin'
)
self.configuration.plugins.register(
'paasmaker.periodic.testfail',
'paasmaker.common.helper.periodicmanager.PeriodicTestFailPlugin',
{},
'Test Fail Periodic plugin'
)
# Set up to catch job statuses.
pub.subscribe(self.on_job_catchall, 'job.status')
self.job_statuses = {}
开发者ID:kaze,项目名称:paasmaker,代码行数:25,代码来源:periodicmanager.py
示例18: play
def play (self):
if ItemCard.play (self):
pub.subscribe (self.on_end_turn, str(self.game_state.gameid1)+'.end_turn_event')
self.counter = 3
self.owner.opponent.silencers += [self]
return True
return False
开发者ID:arthur-hav,项目名称:TCG,代码行数:7,代码来源:gameshared.py
示例19: setup
def setup(self, options=None):
logger.debug("Setting up track scene")
self.space = pymunk.Space()
self.space.gravity = (0.0, -900.0)
if options:
track_name = options.get("trackname")
if track_name:
tmx_data = self.resources.tilemaps[track_name]
self.tmx_data = tmx_data
load_shapes(tmx_data, space=self.space)
self.map_data = pyscroll.TiledMapData(tmx_data)
self.map_layer = pyscroll.BufferedRenderer(self.map_data, (640, 480))
self.karts = list()
perf = KartPerf(100, 8, 15)
green_kart = Kart(
"green-kart",
self.space,
(200, 630),
self.resources.images["green-kart"],
self.resources.images["wheel"],
perf)
green_kart.init_physics()
self.karts.append(green_kart)
pub.subscribe(self.on_key_up, "input.key-up")
开发者ID:bitcraft,项目名称:Platakart,代码行数:26,代码来源:track.py
示例20: init_ui
def init_ui(self):
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.race_choice = wx.Choice(self,
choices=[_i for _i in char_races.RACES],
# style=wx.CB_READONLY,
)
self.race_choice.SetSelection(0)
self.race_choice.Bind(wx.EVT_CHOICE, self.send_update)
# self.combo_box.Bind(wx.EVT_COMBOBOX, self.send_update)
self.text = wx.StaticText(self,
wx.ID_ANY,
pos=(50, 50),
label="Hello",
)
# register listener
pub.subscribe(self.update_text, 'updating text')
self.vbox.Add(self.race_choice)
self.vbox.Add(Abilities(self))
self.vbox.Add(wx.StaticText(self, label="Press CTRL-ALT-I to start inspector"))
self.vbox.Add(self.text)
self.SetSizer(self.vbox)
开发者ID:dougthor42,项目名称:DnD,代码行数:29,代码来源:dnd_wx.py
注:本文中的pubsub.pub.subscribe函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论