本文整理匯總了Python中Type.typestr方法的典型用法代碼示例。如果您正苦於以下問題:Python Type.typestr方法的具體用法?Python Type.typestr怎麽用?Python Type.typestr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Type
的用法示例。
在下文中一共展示了Type.typestr方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: storeRR
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def storeRR(self, u):
r = {}
r['name'], r['type'], r['class'], r[
'ttl'], r['rdlength'] = u.getRRheader()
r['typename'] = Type.typestr(r['type'])
r['classstr'] = Class.classstr(r['class'])
# print 'name=%s, type=%d(%s), class=%d(%s), ttl=%d' \
# % (name,
# type, typename,
# klass, Class.classstr(class),
# ttl)
mname = 'get%sdata' % r['typename']
if hasattr(u, mname):
r['data'] = getattr(u, mname)()
else:
r['data'] = u.getbytes(r['rdlength'])
return r
示例2: storeRR
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def storeRR(self,u):
r={}
r['name'],r['type'],r['class'],r['ttl'],r['rdlength'] = u.getRRheader()
r['typename'] = Type.typestr(r['type'])
r['classstr'] = Class.classstr(r['class'])
#print 'name=%s, type=%d(%s), class=%d(%s), ttl=%d' \
# % (name,
# type, typename,
# klass, Class.classstr(class),
# ttl)
mname = 'get%sdata' % r['typename']
if hasattr(u, mname):
r['data']=getattr(u, mname)()
else:
r['data']=u.getbytes(r['rdlength'])
return r
示例3: storeQ
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def storeQ(self, u):
q = {}
q['qname'], q['qtype'], q['qclass'] = u.getQuestion()
q['qtypestr'] = Type.typestr(q['qtype'])
q['qclassstr'] = Class.classstr(q['qclass'])
return q
示例4: dumpQ
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def dumpQ(u):
qname, qtype, qclass = u.getQuestion()
print 'qname=%s, qtype=%d(%s), qclass=%d(%s)' \
% (qname,
qtype, Type.typestr(qtype),
qclass, Class.classstr(qclass))
示例5: dumpRR
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def dumpRR(u):
name, type, klass, ttl, rdlength = u.getRRheader()
typename = Type.typestr(type)
print 'name=%s, type=%d(%s), class=%d(%s), ttl=%d' \
% (name,
type, typename,
klass, Class.classstr(klass),
ttl)
mname = 'get%sdata' % typename
if hasattr(u, mname):
print ' formatted rdata:', getattr(u, mname)()
else:
print ' binary rdata:', u.getbytes(rdlength)
示例6: req
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def req(self,*name,**args):
" needs a refactoring "
self.argparse(name,args)
#if not self.args:
# raise ArgumentError, 'reinitialize request before reuse'
protocol = self.args['protocol']
self.port = self.args['port']
self.tid = random.randint(0,65535)
self.timeout = self.args['timeout'];
opcode = self.args['opcode']
rd = self.args['rd']
server=self.args['server']
if type(self.args['qtype']) == types.StringType:
try:
qtype = getattr(Type, string.upper(self.args['qtype']))
except AttributeError:
raise ArgumentError, 'unknown query type'
else:
qtype=self.args['qtype']
if not self.args.has_key('name'):
print self.args
raise ArgumentError, 'nothing to lookup'
qname = self.args['name']
if qtype == Type.AXFR and protocol != 'tcp':
print 'Query type AXFR, protocol forced to TCP'
protocol = 'tcp'
#print 'QTYPE %d(%s)' % (qtype, Type.typestr(qtype))
m = Lib.Mpacker()
# jesus. keywords and default args would be good. TODO.
m.addHeader(self.tid,
0, opcode, 0, 0, rd, 0, 0, 0,
1, 0, 0, 0)
m.addQuestion(qname, qtype, Class.IN)
self.request = m.getbuf()
try:
if protocol == 'udp':
self.sendUDPRequest(server)
else:
self.sendTCPRequest(server)
except socket.error, reason:
raise SocketError, reason
示例7: storeQ
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def storeQ(self,u):
q={}
q['qname'], q['qtype'], q['qclass'] = u.getQuestion()
q['qtypestr']=Type.typestr(q['qtype'])
q['qclassstr']=Class.classstr(q['qclass'])
return q
示例8: dumpQ
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def dumpQ(u):
qname, qtype, qclass = u.getQuestion()
print 'qname=%s, qtype=%d(%s), qclass=%d(%s)' \
% (qname,
qtype, Type.typestr(qtype),
qclass, Class.classstr(qclass))
示例9: dumpRR
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def dumpRR(u):
name, type, klass, ttl, rdlength = u.getRRheader()
typename = Type.typestr(type)
print 'name=%s, type=%d(%s), class=%d(%s), ttl=%d' \
% (name,
type, typename,
klass, Class.classstr(klass),
ttl)
mname = 'get%sdata' % typename
if hasattr(u, mname):
print ' formatted rdata:', getattr(u, mname)()
else:
print ' binary rdata:', u.getbytes(rdlength)
示例10: req
# 需要導入模塊: import Type [as 別名]
# 或者: from Type import typestr [as 別名]
def req(self, *name, **args):
" needs a refactoring "
import time, Lib
self.argparse(name, args)
#if not self.args:
# raise DNSError,'reinitialize request before reuse'
protocol = self.args['protocol']
self.port = self.args['port']
opcode = self.args['opcode']
rd = self.args['rd']
server = self.args['server']
if type(self.args['qtype']) == types.StringType:
try:
qtype = getattr(Type, string.upper(self.args['qtype']))
except AttributeError:
raise DNSError, 'unknown query type'
else:
qtype = self.args['qtype']
if not self.args.has_key('name'):
print self.args
raise DNSError, 'nothing to lookup'
qname = self.args['name']
if qtype == Type.AXFR:
print 'Query type AXFR, protocol forced to TCP'
protocol = 'tcp'
#print 'QTYPE %d(%s)' % (qtype, Type.typestr(qtype))
m = Lib.Mpacker()
# jesus. keywords and default args would be good. TODO.
m.addHeader(0,
0, opcode, 0, 0, rd, 0, 0, 0,
1, 0, 0, 0)
m.addQuestion(qname, qtype, Class.IN)
self.request = m.getbuf()
try:
if protocol == 'udp':
self.sendUDPRequest(server)
else:
self.sendTCPRequest(server)
except socket.error, reason:
raise DNSError, reason