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


Python xdrlib.Unpacker方法代码示例

本文整理汇总了Python中xdrlib.Unpacker方法的典型用法代码示例。如果您正苦于以下问题:Python xdrlib.Unpacker方法的具体用法?Python xdrlib.Unpacker怎么用?Python xdrlib.Unpacker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xdrlib的用法示例。


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

示例1: _unpack_info

# 需要导入模块: import xdrlib [as 别名]
# 或者: from xdrlib import Unpacker [as 别名]
def _unpack_info(self, info):
        self.target_info = {}
        info = xdrlib.Unpacker(info)
        self.target_info["Target_Type"] = info.unpack_string()  # 'VxWorks\x00'
        self.target_info["Vx_Version"] = info.unpack_string()  # '6.6\x00'
        self.target_info["Unknow1"] = info.unpack_uint()  # 80
        self.target_info["Unknow2"] = info.unpack_uint()  # 86
        self.target_info["CPU_Type"] = info.unpack_string()  # '86\x00'
        self.target_info["compiler"] = info.unpack_string()  # '86\x00'
        self.target_info["Unknow3"] = info.unpack_uint()  # 86
        self.target_info["Unknow4"] = info.unpack_uint()  # 86
        self.target_info["Unknow5"] = info.unpack_uint()  # 86
        self.target_info["Unknow6"] = info.unpack_uint()  # 86
        self.target_info["Unknow7"] = info.unpack_uint()  # 86
        self.target_info["CPU_Model"] = info.unpack_string()  # '86\x00'
        self.target_info["Unknow8"] = info.unpack_string()  # '86\x00'
        self.target_info["Unknow9"] = info.unpack_uint()  # 86
        self.target_info["Memory_Size"] = info.unpack_uint()  # 86
        self.target_info["Unknow10"] = info.unpack_uint()
        self.target_info["Unknow11"] = info.unpack_uint()
        self.target_info["Unknow12"] = info.unpack_uint()
        self.target_info["Unknow13"] = info.unpack_uint()
        self.target_info["Unknow14"] = info.unpack_uint()
        self.target_info["Unknow15"] = info.unpack_uint()
        return self.target_info 
开发者ID:d0ubl3g,项目名称:Industrial-Security-Auditing-Framework,代码行数:27,代码来源:Wdb2Client.py

示例2: __init__

# 需要导入模块: import xdrlib [as 别名]
# 或者: from xdrlib import Unpacker [as 别名]
def __init__(self, u):
        self.size = u.unpack_uint()

        self.sequence = u.unpack_uint()
        self.source_id = u.unpack_uint()
        self.sample_rate = u.unpack_uint()
        self.sample_pool = u.unpack_uint()
        self.dropped_packets = u.unpack_uint()

        self.if_inIndex = u.unpack_uint()
        self.if_outIndex = u.unpack_uint()

        self.record_count = u.unpack_uint()
        
        self.flows = {}

        for i in range(self.record_count):
            flow_format = u.unpack_uint()
            flow_head = u.unpack_opaque()
            flow_u = xdrlib.Unpacker(flow_head)

            d = flows.getDecoder(flow_format)
            if d:
                self.flows[flow_format] = d(flow_u) 
开发者ID:calston,项目名称:tensor,代码行数:26,代码来源:protocol.py

示例3: read_header

# 需要导入模块: import xdrlib [as 别名]
# 或者: from xdrlib import Unpacker [as 别名]
def read_header(self):
    self.u = xdrlib.Unpacker(self.file.read(200))
    self.magic = self.u.unpack_int()
    self.version = self.u.unpack_string()
    self.size_ir = self.u.unpack_int()
    self.size_e = self.u.unpack_int()
    self.size_box = self.u.unpack_int()
    self.size_vir = self.u.unpack_int()
    self.size_pres = self.u.unpack_int()
    self.size_top = self.u.unpack_int()
    self.size_sym = self.u.unpack_int()
    self.size_x = self.u.unpack_int()
    self.size_v = self.u.unpack_int()
    self.size_f = self.u.unpack_int()
    self.n_atom = self.u.unpack_int()
    self.step = self.u.unpack_int()
    self.nre = self.u.unpack_int()
    self.t = self.u.unpack_float()
    self.lamb = self.u.unpack_float()
    self.pos_after_header = self.u.get_position() 
开发者ID:boscoh,项目名称:pdbremix,代码行数:22,代码来源:gromacs.py

示例4: load_frame

# 需要导入模块: import xdrlib [as 别名]
# 或者: from xdrlib import Unpacker [as 别名]
def load_frame(self, i_frame):
    if i_frame < - 1*self.n_frame or i_frame >= self.n_frame:
      raise IndexError
    if i_frame < 0:
      i_frame = self.n_frame + i_frame
    if i_frame == self.i_frame:
      return
    self.file.seek(self.pos_after_header + i_frame*self.size_frame)
    self.u = xdrlib.Unpacker(self.file.read(self.size_frame))
    box, positions, velocities, forces = None, None, None, None
    if self.size_box:
      box = [self.next_3_reals() for i in range(n_dim)]
    if self.size_vir:
      dummy = [self.next_3_reals() for i in range(n_dim)]
    if self.size_pres:
      dummy = [self.next_3_reals() for i in range(n_dim)]
    if self.size_x:
      positions = [self.next_3_reals() for i in range(self.n_atom)]
    if self.size_v:
      velocities = [self.next_3_reals() for i in range(self.n_atom)]
    if self.size_f:
      forces = [self.next_3_reals() for i in range(self.n_atom)]
    self.frame = box, positions, velocities, forces
    self.i_frame = i_frame 
开发者ID:boscoh,项目名称:pdbremix,代码行数:26,代码来源:gromacs.py

示例5: addpackers

# 需要导入模块: import xdrlib [as 别名]
# 或者: from xdrlib import Unpacker [as 别名]
def addpackers(self):
        # Override this to use derived classes from Packer/Unpacker
        self.packer = Packer()
        self.unpacker = Unpacker("") 
开发者ID:pyvisa,项目名称:pyvisa-py,代码行数:6,代码来源:rpc.py

示例6: test_xdr

# 需要导入模块: import xdrlib [as 别名]
# 或者: from xdrlib import Unpacker [as 别名]
def test_xdr(self):
        p = xdrlib.Packer()

        s = 'hello world'
        a = ['what', 'is', 'hapnin', 'doctor']

        p.pack_int(42)
        p.pack_int(-17)
        p.pack_uint(9)
        p.pack_bool(True)
        p.pack_bool(False)
        p.pack_uhyper(45L)
        p.pack_float(1.9)
        p.pack_double(1.9)
        p.pack_string(s)
        p.pack_list(range(5), p.pack_uint)
        p.pack_array(a, p.pack_string)

        # now verify
        data = p.get_buffer()
        up = xdrlib.Unpacker(data)

        self.assertEqual(up.get_position(), 0)

        self.assertEqual(up.unpack_int(), 42)
        self.assertEqual(up.unpack_int(), -17)
        self.assertEqual(up.unpack_uint(), 9)
        self.assertTrue(up.unpack_bool() is True)

        # remember position
        pos = up.get_position()
        self.assertTrue(up.unpack_bool() is False)

        # rewind and unpack again
        up.set_position(pos)
        self.assertTrue(up.unpack_bool() is False)

        self.assertEqual(up.unpack_uhyper(), 45L)
        self.assertAlmostEqual(up.unpack_float(), 1.9)
        self.assertAlmostEqual(up.unpack_double(), 1.9)
        self.assertEqual(up.unpack_string(), s)
        self.assertEqual(up.unpack_list(up.unpack_uint), range(5))
        self.assertEqual(up.unpack_array(up.unpack_string), a)
        up.done()
        self.assertRaises(EOFError, up.unpack_uint) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:47,代码来源:test_xdrlib.py

示例7: test_xdr

# 需要导入模块: import xdrlib [as 别名]
# 或者: from xdrlib import Unpacker [as 别名]
def test_xdr(self):
        p = xdrlib.Packer()

        s = b'hello world'
        a = [b'what', b'is', b'hapnin', b'doctor']

        p.pack_int(42)
        p.pack_int(-17)
        p.pack_uint(9)
        p.pack_bool(True)
        p.pack_bool(False)
        p.pack_uhyper(45)
        p.pack_float(1.9)
        p.pack_double(1.9)
        p.pack_string(s)
        p.pack_list(range(5), p.pack_uint)
        p.pack_array(a, p.pack_string)

        # now verify
        data = p.get_buffer()
        up = xdrlib.Unpacker(data)

        self.assertEqual(up.get_position(), 0)

        self.assertEqual(up.unpack_int(), 42)
        self.assertEqual(up.unpack_int(), -17)
        self.assertEqual(up.unpack_uint(), 9)
        self.assertTrue(up.unpack_bool() is True)

        # remember position
        pos = up.get_position()
        self.assertTrue(up.unpack_bool() is False)

        # rewind and unpack again
        up.set_position(pos)
        self.assertTrue(up.unpack_bool() is False)

        self.assertEqual(up.unpack_uhyper(), 45)
        self.assertAlmostEqual(up.unpack_float(), 1.9)
        self.assertAlmostEqual(up.unpack_double(), 1.9)
        self.assertEqual(up.unpack_string(), s)
        self.assertEqual(up.unpack_list(up.unpack_uint), list(range(5)))
        self.assertEqual(up.unpack_array(up.unpack_string), a)
        up.done()
        self.assertRaises(EOFError, up.unpack_uint) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:47,代码来源:test_xdrlib.py


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