RX and TX bytes for each of the network devices
178005
def netdevs():
    '''  '''

    with open('/proc/net/dev') as f:
        net_dump = f.readlines()
    
    device_data={}
    data = namedtuple('data',['rx','tx'])
    for line in net_dump[2:]:
        line = line.split(':')
        if line[0].strip() != 'lo':
            device_data[line[0].strip()] = data(float(line[1].split()[0])/(1024.0*1024.0), 
                                                float(line[1].split()[8])/(1024.0*1024.0))
    
    return device_data
776393
def read_pdu
      loop do
        header = @io.read(7)
        if header
          trn = header[0,2].unpack('n')[0]
          len = header[4,2].unpack('n')[0]
          msg = @io.read(len-1)

          log "Rx (#{(header + msg).size} bytes): " + logging_bytes(header + msg)

          if trn == @transaction
            return msg
          else
            log "Transaction number mismatch. A packet is ignored."
          end
        end
      end
    end
486527
public byte[] toByteArray()
	{
		final byte[] buf = super.toByteArray();
		int i = 2;
		buf[i++] = (byte) knxmedium;
		buf[i++] = (byte) devicestatus;
		final byte[] addr = address.toByteArray();
		buf[i++] = addr[0];
		buf[i++] = addr[1];
		buf[i++] = (byte) (projectInstallID >> 8);
		buf[i++] = (byte) projectInstallID;
		for (int k = 0; k < 6; ++k)
			buf[i++] = serial[k];
		for (int k = 0; k < 4; ++k)
			buf[i++] = mcaddress[k];
		for (int k = 0; k < 6; ++k)
			buf[i++] = mac[k];
		for (int k = 0; k < name.length(); ++k)
			buf[i++] = (byte) name.charAt(k);
		return buf;
	}
910981
def find_parent_outputs(provider: Provider, utxo: TxIn) -> TxOut:
    ''''''

    network_params = net_query(provider.network)
    index = utxo.txout  # utxo index
    return TxOut.from_json(provider.getrawtransaction(utxo.txid,
                           1)['vout'][index],
                           network=network_params)
17557
def to_networkx(self):
        
        return nx_util.to_networkx(self.session.get(self.__url).json())
795783
def to_bytes(self):
        '''
        
        '''
        # Verify that the properties make sense
        self.sanitize()

        # Write the source and destination ports
        bitstream = BitStream('uint:16=%d, '
                              'uint:16=%d' % (self.source_port,
                                              self.destination_port))

        # Write the length
        payload_bytes = bytes(self.payload)
        length = len(payload_bytes) + 8
        bitstream += BitStream('uint:16=%d' % length)

        # Write the checksum
        bitstream += BitStream('uint:16=%d' % self.checksum)

        return bitstream.bytes + payload_bytes
164925
def read_tx_witnesses(ptr, tx, num_witnesses):
    
    witnesses = []
    for i in xrange(0, num_witnesses):

        witness_stack_len = read_var_int(ptr, tx)
        witness_stack = []

        for j in xrange(0, witness_stack_len):

            stack_item = read_var_string(ptr, tx)
            witness_stack.append(stack_item)
             
        witness_script = btc_witness_script_serialize(witness_stack).decode('hex')
        witnesses.append(witness_script)

    return witnesses
1033951
def serialize(self):
        

        self.data = bytearray()
        r = self.protocols[::-1]
        for i, p in enumerate(r):
            if isinstance(p, packet_base.PacketBase):
                if i == len(r) - 1:
                    prev = None
                else:
                    prev = r[i + 1]
                data = p.serialize(self.data, prev)
            else:
                data = six.binary_type(p)
            self.data = bytearray(data + self.data)
28600
def send_and_receive_raw(self, target, lun, netfn, raw_bytes):
        
        return self._send_and_receive(target=target,
                                      lun=lun,
                                      netfn=netfn,
                                      cmdid=array('B', raw_bytes)[0],
                                      payload=raw_bytes[1:])
713771
def bytes()
			return [
				(@addr >> 56 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 48 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 40 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 32 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 24 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 16 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 8 & 0xff).to_s(16).rjust(2, "0"),
				(@addr & 0xff).to_s(16).rjust(2, "0"),
				]
		end
473520
def broadcast_tx(cls, tx_hex):  # pragma: no cover
        
        success = None

        for api_call in cls.BROADCAST_TX_MAIN:
            try:
                success = api_call(tx_hex)
                if not success:
                    continue
                return
            except cls.IGNORED_ERRORS:
                pass

        if success is False:
            raise ConnectionError('Transaction broadcast failed, or '
                                  'Unspents were already used.')

        raise ConnectionError('All APIs are unreachable.')
1308480
def _send_and_receive(self, target, lun, netfn, cmdid, payload):
        
        self._inc_sequence_number()

        # assemble IPMB header
        header = IpmbHeaderReq()
        header.netfn = netfn
        header.rs_lun = lun
        header.rs_sa = target.ipmb_address
        header.rq_seq = self.next_sequence_number
        header.rq_lun = 0
        header.rq_sa = self.slave_address
        header.cmd_id = cmdid

        retries = 0
        while retries < self.max_retries:
            try:
                self._send_raw(header, payload)
                rx_data = self._receive_raw(header)
                break
            except IpmiTimeoutError:
                log().warning('I2C transaction timed out'),

            retries += 1

        else:
            raise IpmiTimeoutError()

        return rx_data.tostring()[5:-1]
1347280
def broadcast_transaction(hex_tx, blockchain_client):
    
    if isinstance(blockchain_client, BitcoindClient):
        bitcoind = blockchain_client.bitcoind
    elif isinstance(blockchain_client, AuthServiceProxy):
        bitcoind = blockchain_client
    else:
        raise Exception('A BitcoindClient object is required')

    try:
        resp = bitcoind.sendrawtransaction(hex_tx)
    except httplib.BadStatusLine:
        raise Exception('Invalid HTTP status code from bitcoind.')

    if len(resp) > 0:
        return {'tx_hash': resp, 'success': True}
    else:
        raise Exception('Invalid response from bitcoind.')
639616
def broadcast_transaction(self, hex_tx):
        

        resp = self.obj.sendrawtransaction(hex_tx)
        if len(resp) > 0:
            return {'transaction_hash': resp, 'success': True}
        else:
            return error_reply('Invalid response from bitcoind.')
623016
def init_group_read(self, dst_addr=1):
        """"""
        self.init_group(dst_addr)
        self.tpci_apci = 0x00  # unnumbered data packet, group read
        self.data = [0]
507519
def _get_net_io_counters(self):
        
        counters = psutil.net_io_counters(pernic=self.pernic)

        res = {}
        for name, io in counters.iteritems():
            res[name] = io._asdict()
            res[name].update({'tx_per_sec': 0, 'rx_per_sec': 0})

        return res
361361
def broadcast_tx(self, tx):
        
        return BitcoinServiceProviderConnector.broadcast_tx_with_chain(tx, self.bitcoin_chain, self.bitcoind)