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