本文整理匯總了Python中xdrlib.Packer.pack_array方法的典型用法代碼示例。如果您正苦於以下問題:Python Packer.pack_array方法的具體用法?Python Packer.pack_array怎麽用?Python Packer.pack_array使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xdrlib.Packer
的用法示例。
在下文中一共展示了Packer.pack_array方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from xdrlib import Packer [as 別名]
# 或者: from xdrlib.Packer import pack_array [as 別名]
def __init__(self, stamp, machinename, uid, gid, gids):
if len(machinename) > 255:
raise SecError("machinename %s is too long" % machinename)
if len(gids) > 16:
raise SecError("gid array too long: %s" % str(gids))
try:
p = Packer()
p.pack_int(stamp)
p.pack_string(machinename)
p.pack_uint(uid)
p.pack_uint(gid)
p.pack_array(gids, p.pack_uint)
self.cred = p.get_buffer()
except Error, e:
raise SecError("Packing error: %s", str(e))
示例2: __init__
# 需要導入模塊: from xdrlib import Packer [as 別名]
# 或者: from xdrlib.Packer import pack_array [as 別名]
def __init__(self, stamp=0, machinename='', uid=0, gid=0, gids=[]):
if len(machinename) > 255:
raise SecError("machinename %s is too long" % machinename)
if len(gids) > 16:
raise SecError("gid array too long: %s" % str(gids))
try:
p = Packer()
p.pack_int(stamp)
try: # for python2
p.pack_string(machinename)
except: # for python3
p.pack_string(bytes(machinename, 'utf-8'))
p.pack_uint(uid)
p.pack_uint(gid)
p.pack_array(gids, p.pack_uint)
self.cred = p.get_buffer()
except Error as e:
raise SecError("Packing error: %s", str(e))
self.uid = uid
self.gid = gid