本文整理汇总了Python中request.Request.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Request.__init__方法的具体用法?Python Request.__init__怎么用?Python Request.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request.Request
的用法示例。
在下文中一共展示了Request.__init__方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
def __init__(self, attackCard, context):
""" Initialize the Request with the attack """
self.attackCard = attackCard
self.context = context
self.defenseFilters = [ComparisonFilter(zoneType, FixedCriteria("defendFrom", zoneType, "==")) for zoneType in self.ZONES]
self.cardsForZone = {}
Request.__init__(self, [context.player])
示例2: __init__
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
def __init__(self, url, password, proxy=None):
Request.__init__(self, url, proxy)
self.password = password
self.extractor = re.compile("<%s>(.*)</%s>" % (self.password[2:], self.password[2:]), re.DOTALL)
# self.extractor_debug = re.compile( "<%sDEBUG>(.*)</%sDEBUG>" % ( self.password[2:], self.password[2:] ), re.DOTALL )
self.parsed = urlparse.urlparse(self.url)
self.data = None
if not self.parsed.path:
self.query = self.parsed.netloc.replace("/", " ")
else:
self.query = "".join(self.parsed.path.split(".")[:-1]).replace("/", " ")
示例3: __init__
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
def __init__(self, cards, player, cost, toDescription):
""" Initialize the Request with the potential options """
self.cards = cards
self.cost = cost
self.toDescription = toDescription
Request.__init__(self, [player])
示例4: str
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
'''Helpful print statements'''
print 'Beginning torrent for ' + name
print 'Average piece length: ' + str(piece_length)
if debug:
print 'The last piece will be of size: ' + str(last_piece_length)
print 'Total length: ' + str(total_length)
print 'Number of pieces to receive: ' + str(num_pieces) + '\n'
'''////////////////////////'''
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = socket.gethostname() # Get local machine name
'''host = 'bl_tardis' 'kate-english' - HE'''
port = 42044 # 25159 - HE
s.connect((host, port)) #connect to <host> at <port>
Request.__init__(s, num_pieces, piece_length, last_piece_length, debug, pieces, name)
# Handshake
peer_id = ""
while len(peer_id) != 12:
peer_id = peer_id + choice("1234567890")
peer_id = '-' + 'PY' + '0001' + '-' + peer_id
protocol_id = 'BitTorrent protocol'
# len_id = str(len(protocol_id))
reserved = '\x00'*7 + '\x01'
handshake = '\x13' + protocol_id + reserved + info_hash + peer_id
s.send(handshake)
data = s.recv(len(handshake))
示例5: __init__
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
def __init__(self, sender):
Request.__init__(self)
self.response = '{} pong! Hehe that was fun!'.format(sender)
示例6: __init__
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
def __init__(self, id, message):
Request.__init__(self, 'POST', 'http://www.reddit.com/api/comment', api_type='json',
text=message, thing_id=id)
示例7: __init__
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
def __init__(self, username, password):
Request.__init__(self, 'POST', 'http://www.reddit.com/api/login', api_type='json', user=username, passwd=password)
示例8: __init__
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
def __init__(self, post_url, limit=25):
Request.__init__(self, 'GET', '{0}.json'.format(post_url), limit=limit)
self.json = None
self.comments = []