當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。