当前位置: 首页>>代码示例>>Python>>正文


Python channel.Channel类代码示例

本文整理汇总了Python中channel.Channel的典型用法代码示例。如果您正苦于以下问题:Python Channel类的具体用法?Python Channel怎么用?Python Channel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Channel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createProto

 def createProto(self, name, proto):
     scroll = QtGui.QScrollArea()
     scroll.setWidgetResizable(True)
     scroll.setFrameStyle(QtGui.QFrame.NoFrame)
     scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
     layout = QtGui.QVBoxLayout()
     widget = QtGui.QWidget()
     sock = socket.socket()
     try:
         sock.connect((self.host, self.port + proto["id"]))
     except:
         print ("Failed to connect on %s %d" % (self.host, self.port))
         sys.exit(-1)
     file = sock.makefile(mode="rw")
     chan = Channel(file.buffer, print_packet, proto = name,
             transmitter = self.transmitter,
             symmetrical = self.symmetrical)
     chan._file_ = file # archi moche
     for packet in proto['packets']:
         if proto['packets'][packet]['transmitter'] == self.transmitter \
                 or proto['packets'][packet]['transmitter'] == 'both' \
                 or self.transmitter == 'both':
             layout.addWidget(self.createPacket(packet,
                 proto['packets'][packet], chan), 0)
     widget.setLayout(layout)
     scroll.setWidget(widget)
     return scroll
开发者ID:7Robot-Soft,项目名称:atp,代码行数:27,代码来源:gui.py

示例2: on_channel_state

  def on_channel_state(self, msg):
    if msg.channel_id not in self.channels_by_id:
      chan = Channel(self.bot, msg.channel_id)
      self.channels_by_id[msg.channel_id] = chan
    else:
      chan = self.channels_by_id[msg.channel_id]
    chan.update(msg)

    if msg.parent == msg.channel_id:
      if not msg.channel_id == 0:
        LOGGER.warning('Root channel not ID 0.')
      if self.root and self.root != chan:
        LOGGER.error('Received 2 different roots...?')
        raise Exception('Two roots.')
      self.root = chan
    elif chan.parent:
      if chan.parent.id != msg.parent:
        chan.parent.remove_child(chan)
        self.channels_by_id[msg.parent].add_child(chan)
    else:
      if not msg.parent in self.channels_by_id:
        LOGGER.error('Parent ID passed by server is not in the channel list.')
        raise Exception('Invalid Parent.')
      self.channels_by_id[msg.parent].add_child(chan)
    print msg
开发者ID:bbrouse,项目名称:mumble-bots,代码行数:25,代码来源:bot.py

示例3: __init__

    def __init__(self, id, ordering):
        super(Process, self).__init__() # call __init__ from multiprocessing.Process
        self.id = id

        # Read config from file
        self.process_info, self.addr_dict = configreader.get_processes_info()
        address = self.process_info[id]
        ip, port = address[0], address[1]
        print(ip, port)

        # Init a socket
        self.socket = socket.socket(
            socket.AF_INET, socket.SOCK_DGRAM)
        self.socket.bind(address)

        # Init channel

        # Causal Order Channel
        if ordering == 'causal':
            print 'causal ordering'
            self.channel = CausalOrderChannel(self, self.id, self.socket, self.process_info, self.addr_dict)
        elif ordering == 'total':
            print 'total ordering'
            # Total Order Channel
            if id == 1:
                # Select process 1 to be the sequencer
                self.channel = TotalOrderChannel(self, self.id, self.socket, self.process_info, self.addr_dict, True)
            else:
                self.channel = TotalOrderChannel(self, self.id, self.socket, self.process_info, self.addr_dict)
        else:
            # Regular channel
            print 'no ordering'
            self.channel = Channel(self, self.id, self.socket, self.process_info, self.addr_dict)
开发者ID:weiyangedward,项目名称:cs425_MP,代码行数:33,代码来源:process.py

示例4: createChannel

 def createChannel(self,channelName):
     """Factory function for Channel Objects. Registers the channel.
     Returns: new Channel Object"""
     
     channel = Channel()
     channel.name = channelName
     self.addChannel(channel)
     return channel
开发者ID:emmasteimann,项目名称:knive,代码行数:8,代码来源:knive.py

示例5: markStream

  def markStream(self, chId, status):
    ch = Channel()
    ch.findOne(chId)
    ch.setStatus(status)
    xbmc.executebuiltin("Container.Refresh")


    
开发者ID:moromete,项目名称:plugin.video.streams,代码行数:5,代码来源:channels.py

示例6: __init__

 def __init__(self, channels = 512):
     self.channels = [None] * channels
     for i in range(0, channels):
         channel = Channel()
         channel.index = i
         channel.addListener(self)
         self.channels[i] = channel;
     self.output = Output()
     self.filters = []
开发者ID:jketterl,项目名称:pilight,代码行数:9,代码来源:universe.py

示例7: convert

    def convert(self):
        """
        Convert the channel to the expected sample width and frame rate.
        
        """
        newchannel = Channel()
        newchannel.set_frames( self.__convert_frames( self.channel.frames ) )
        newchannel.sampwidth = self.sampwidth
        newchannel.framerate = self.framerate

        self.channel = newchannel
开发者ID:drammock,项目名称:sppas,代码行数:11,代码来源:channelformatter.py

示例8: run

def run():
    page_id = random_page_id()
    page_channel = Channel('http://readline.io', page_id)
    print("Access your application by going to http://{}/{}".format(server_name, page_id))
    while True:
        message = page_channel.dequeue()
        if message:
            print("Message received: len={}".format(len(json.dumps(message))))
            handle_message(message)
        else:
            print("No message received, continuing long poll.")
开发者ID:readlineio,项目名称:readlineio,代码行数:11,代码来源:readlineio.py

示例9: joined_channel

    def joined_channel(self, channel, who):

        # We just joined the channel
        if who == self._nick:
            c = Channel()
            c.users.append(who)
            c.channel = channel
            self._joined_channels.append(c)
        
        for i in self._joined_channels:
            if i.channel == channel:
                i.users.append(who)
开发者ID:typoon,项目名称:boteco,代码行数:12,代码来源:botstate.py

示例10: append_frames

 def append_frames(self, frames):
     """
     Convert the channel by appending frames.
     
     @param frames (string) the frames to append
     
     """
     newchannel = Channel()
     newchannel.set_frames( self.channel.frames + frames )
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     self.channel = newchannel
开发者ID:drammock,项目名称:sppas,代码行数:12,代码来源:channelformatter.py

示例11: remove_offset

 def remove_offset(self):
     """
     Remove the offset in the channel
     
     """
     newchannel = Channel()
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     avg = audioutils.avg(self.channel.frames, self.sampwidth)
     newchannel.set_frames(audioutils.bias(self.channel.frames, self.sampwidth, - avg))
     
     self.channel = newchannel
开发者ID:drammock,项目名称:sppas,代码行数:12,代码来源:channelformatter.py

示例12: add_frames

 def add_frames(self, frames, position):
     """
     Convert the channel by adding frames.
     
     @param position (int) the position where the frames will be inserted
     
     """
     newchannel = Channel()
     newchannel.set_frames( self.channel.frames[:position*self.sampwidth] + frames + self.channel.frames[position*self.sampwidth:] )
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     self.channel = newchannel
开发者ID:drammock,项目名称:sppas,代码行数:12,代码来源:channelformatter.py

示例13: List

class List(object):

    def __init__(self, name, id=None):
        self.id = id if id else str(uuid4())
        self.channel = Channel(self.id)
        self.channel.onMessage = self.onMessage
        self.channel.onJoin = self.onJoin
        self.name = name
        self.items = []
        self.dirty = False

    def entitle(self, user):
        self.channel.entitle(user)

    def entitled(self, user):
        return user in self.channel.entitled

    def onJoin(self, socket):
        for i, item in enumerate(self.items):
            self.channel.sendTo(socket,
                {"type": "insert",
                 "index": i,
                 "attrs": item})

    def onMessage(self, socket, msg):
        require(msg, "index")

        if msg.type == "insert":
            require(msg, "attrs")
            self.items.insert(msg.index, msg.attrs)
            self.channel.broadcast(
                {"type": "insert",
                 "index": msg.index,
                 "attrs": msg.attrs})
            self.dirty = True

        elif msg.type == "delete":
            del self.items[msg.index]
            self.channel.broadcast(
                {"type": "delete",
                 "index": msg.index})
            self.dirty = True

        elif msg.type == "update":
            require(msg, "attrs")
            item = self.items[msg.index]
            item.update(msg.attrs)
            self.channel.broadcast(
                {"type": "update",
                 "index": msg.index,
                 "attrs": msg.attrs})
            self.dirty = True
开发者ID:emdash,项目名称:todoserver,代码行数:52,代码来源:server.py

示例14: remove_frames

 def remove_frames(self, begin, end):
     """
     Convert the channel by removing frames.
     
     @param begin (int) the position of the beggining of the frames to remove
     @param end (int) the position of the end of the frames to remove
     
     """
     newchannel = Channel()
     newchannel.set_frames( self.channel.frames[:begin*self.sampwidth] + self.channel.frames[end*self.sampwidth:] )
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     self.channel = newchannel
开发者ID:drammock,项目名称:sppas,代码行数:13,代码来源:channelformatter.py

示例15: bias

 def bias(self, bias):
     """
     Apply a bias on the frames
     
     @param bias (int) the value to bias the frames
     
     """
     newchannel = Channel()
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     newchannel.set_frames(audioutils.bias(self.channel.frames, self.sampwidth, bias))
     
     self.channel = newchannel
开发者ID:drammock,项目名称:sppas,代码行数:13,代码来源:channelformatter.py


注:本文中的channel.Channel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。