本文整理汇总了Python中pyamf.remoting.decode函数的典型用法代码示例。如果您正苦于以下问题:Python decode函数的具体用法?Python decode怎么用?Python decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_header_data_length
def test_invalid_header_data_length(self):
remoting.decode('\x00\x00\x00\x01\x00\x04name\x00\x00\x00\x00\x06\x0a'
'\x00\x00\x00\x00\x00\x00')
self.failUnlessRaises(pyamf.DecodeError, remoting.decode,
'\x00\x00\x00\x01\x00\x04name\x00\x00\x00\x00\x06\x0a\x00\x00\x00'
'\x00\x00\x00', strict=True)
示例2: test_amf_version
def test_amf_version(self):
for x in ("\x00", "\x03"):
try:
remoting.decode(x)
except EOFError:
pass
self.failUnlessRaises(pyamf.DecodeError, remoting.decode, "\x10")
示例3: test_amf_version
def test_amf_version(self):
for x in ('\x00', '\x03'):
try:
remoting.decode(x)
except IOError:
pass
self.failUnlessRaises(pyamf.DecodeError, remoting.decode, '\x10')
示例4: test_invalid_body_data_length
def test_invalid_body_data_length(self):
remoting.decode('\x00\x00\x00\x00\x00\x01\x00\x09test.test\x00\x02/1'
'\x00\x00\x00\x13\x0a\x00\x00\x00\x01\x08\x00\x00\x00\x00\x00\x01'
'\x61\x02\x00\x01\x61\x00\x00\x09')
self.failUnlessRaises(pyamf.DecodeError, remoting.decode,
'\x00\x00\x00\x00\x00\x01\x00\x09test.test\x00\x02/1\x00\x00\x00'
'\x13\x0a\x00\x00\x00\x01\x08\x00\x00\x00\x00\x00\x01\x61\x02\x00'
'\x01\x61\x00\x00\x09', strict=True)
示例5: test_client_version
def test_client_version(self):
"""
Tests the AMF client version.
"""
for x in ('\x00', '\x01', '\x03'):
try:
remoting.decode('\x00' + x)
except IOError:
pass
示例6: test_invalid_header_data_length
def test_invalid_header_data_length(self):
remoting.decode("\x00\x00\x00\x01\x00\x04name\x00\x00\x00\x00\x06\x0a" "\x00\x00\x00\x00\x00\x00")
self.failUnlessRaises(
pyamf.DecodeError,
remoting.decode,
"\x00\x00\x00\x01\x00\x04name\x00\x00\x00\x00\x06\x0a\x00\x00\x00" "\x00\x00\x00",
strict=True,
)
示例7: test_client_version
def test_client_version(self):
"""
Tests the AMF client version.
"""
for x in ("\x00", "\x01", "\x03"):
try:
remoting.decode("\x00" + x)
except EOFError:
pass
示例8: test_invalid_body_data_length
def test_invalid_body_data_length(self):
remoting.decode(
"\x00\x00\x00\x00\x00\x01\x00\x09test.test\x00\x02/1"
"\x00\x00\x00\x13\x0a\x00\x00\x00\x01\x08\x00\x00\x00\x00\x00\x01"
"\x61\x02\x00\x01\x61\x00\x00\x09"
)
self.failUnlessRaises(
pyamf.DecodeError,
remoting.decode,
"\x00\x00\x00\x00\x00\x01\x00\x09test.test\x00\x02/1\x00\x00\x00"
"\x13\x0a\x00\x00\x00\x01\x08\x00\x00\x00\x00\x00\x01\x61\x02\x00"
"\x01\x61\x00\x00\x09",
strict=True,
)
示例9: main
def main():
"""
Run AMF decoder on input file.
"""
(options, args) = parse_options()
print 'Using pyamf from: %s' % (pyamf,)
print 'Strict = ' + str(options.strict)
for arg in args:
for fname in glob.glob(arg):
if fnmatch(fname, '*.amf*'):
body = read_file(fname)
try:
print "\nDecoding file:", fname
request = remoting.decode(body, None, options.strict)
if options.debug:
for name, message in request:
print " %s: %s" % (name, message)
except pyamf.UnknownClassAlias, c:
if options.debug:
print '\n Warning: %s' % c
except pyamf.DecodeError, c:
if options.debug:
print '\n Warning: %s' % c
except:
示例10: get_clip_info
def get_clip_info(const, playerID, videoPlayer, publisherID):
conn = httplib.HTTPConnection("c.brightcove.com")
envelope = build_amf_request(const, playerID, videoPlayer, publisherID)
conn.request("POST", "/services/messagebroker/amf?playerKey=AQ~~,AAAAC_GBGZE~,q40QbnxHunHkwKuAvWxESNjERBgcAQY8", str(remoting.encode(envelope).read()), {'content-type': 'application/x-amf'})
response = conn.getresponse().read()
response = remoting.decode(response).bodies[0][1].body
return response
示例11: __GetBrightCoveData
def __GetBrightCoveData(self):
""" Retrieves the Url's from a brightcove stream
Arguments:
playerKey : string - Key identifying the current request
contentId : int - ID of the content to retrieve
url : string - Url of the page that calls the video SWF
seed : string - Constant which depends on the website
Keyword Arguments:
experienceId : id - <unknown parameter>
Returns a dictionary with the data
"""
# Seed = 61773bc7479ab4e69a5214f17fd4afd21fe1987a
envelope = self.__BuildBrightCoveAmfRequest(
self.playerKey, self.contentId, self.url, self.experienceId, self.seed
)
connection = httplib.HTTPConnection("c.brightcove.com")
connection.request(
"POST",
"/services/messagebroker/amf?playerKey=" + self.playerKey,
str(remoting.encode(envelope).read()),
{"content-type": "application/x-amf"},
)
response = connection.getresponse().read()
response = remoting.decode(response).bodies[0][1].body
# self.logger.debug(response)
return response["programmedContent"]["videoPlayer"]["mediaDTO"]
示例12: test_timezone
def test_timezone(self):
import datetime
http_request = http.HttpRequest()
self.executed = False
td = datetime.timedelta(hours=-5)
now = datetime.datetime.utcnow()
def echo(d):
self.assertEqual(d, now + td)
self.executed = True
return d
gw = django.DjangoGateway({'test.test': echo}, timezone_offset=-18000,
expose_request=False)
msg = remoting.Envelope(amfVersion=pyamf.AMF0)
msg['/1'] = remoting.Request(target='test.test', body=[now])
http_request.method = 'POST'
http_request.raw_post_data = remoting.encode(msg).getvalue()
res = remoting.decode(gw(http_request).content)
self.assertTrue(self.executed)
self.assertEqual(res['/1'].body, now)
示例13: get_clip_info
def get_clip_info(const, playerID, videoPlayer, publisherID):
conn = httplib.HTTPConnection("c.brightcove.com")
envelope = build_amf_request(const, playerID, videoPlayer, publisherID)
conn.request("POST", "/services/messagebroker/amf?playerKey=AQ~~,AAAAFR9Ptpk~,qrsh31CHJoFjltWH9CfvxE3UxqGVBf9B", str(remoting.encode(envelope).read()), {'content-type': 'application/x-amf'})
response = conn.getresponse().read()
response = remoting.decode(response).bodies[0][1].body
return response
示例14: get
def get(self, url):
try:
from pyamf import remoting
except ImportError:
log.error("You need to install pyamf to download content from kanal5 and kanal9")
log.error("In debian the package is called python-pyamf")
sys.exit(2)
player_id = 811317479001
publisher_id = 22710239001
const = "9f79dd85c3703b8674de883265d8c9e606360c2e"
env = remoting.Envelope(amfVersion=3)
env.bodies.append(("/1", remoting.Request(target="com.brightcove.player.runtime.PlayerMediaFacade.findMediaById", body=[const, player_id, self.other, publisher_id], envelope=env)))
env = str(remoting.encode(env).read())
url = "http://" + url + "/services/messagebroker/amf?playerKey=AQ~~,AAAABUmivxk~,SnCsFJuhbr0vfwrPJJSL03znlhz-e9bk"
header = "application/x-amf"
data = get_http_data(url, "POST", header, env)
streams = {}
for i in remoting.decode(data).bodies[0][1].body['renditions']:
stream = {}
stream["uri"] = i["defaultURL"]
streams[i["encodingRate"]] = stream
test = select_quality(self.options, streams)
filename = test["uri"]
match = re.search("(rtmp[e]{0,1}://.*)\&(.*)$", filename)
other = "-W %s -y %s " % ("http://admin.brightcove.com/viewer/us1.25.04.01.2011-05-24182704/connection/ExternalConnection_2.swf", match.group(2))
download_rtmp(self.options, match.group(1), self.output, self.live, other, self.resume)
示例15: amf_parse
def amf_parse(string, environ):
try:
from pyamf import remoting
res = remoting.decode(BytesIO(string))
#print(res)
body = res.bodies[0][1].body[0]
values = {}
if hasattr(body, 'body'):
values['body'] = body.body
if hasattr(body, 'source'):
values['source'] = body.source
if hasattr(body, 'operation'):
values['op'] = body.operation
if environ is not None:
environ['pywb.inputdata'] = res
query = urlencode(values)
#print(query)
return query
except Exception as e:
import traceback
traceback.print_exc()
print(e)
return None