本文整理汇总了Python中CTCore.add_object方法的典型用法代码示例。如果您正苦于以下问题:Python CTCore.add_object方法的具体用法?Python CTCore.add_object怎么用?Python CTCore.add_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTCore
的用法示例。
在下文中一共展示了CTCore.add_object方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_jsbeautify
# 需要导入模块: import CTCore [as 别名]
# 或者: from CTCore import add_object [as 别名]
def do_jsbeautify(self,line):
try:
import jsbeautifier
l = line.split(" ")
if len(l) < 2:
self.help_jsbeautify()
else:
OPTIONS = ['slice','obj']
option = l[0]
if option not in OPTIONS:
print "Invalid option"
return False
id = l[1]
response, size = CTCore.get_response_and_size(id, "all")
name = CTCore.get_name(id)
if option == "slice":
offset = int(l[2])
length = l[3]
bytes, length = get_bytes(response,offset,length)
js_bytes = bytes
res = jsbeautifier.beautify(js_bytes)
print res
if option == "obj":
res = jsbeautifier.beautify(response)
obj_num = CTCore.add_object("jsbeautify",res,id=id)
print " JavaScript Beautify of object {} ({}) successful!".format(str(id), name)
print " New object created: {}".format(obj_num) + newLine
except Exception,e:
print str(e)
示例2: do_ungzip
# 需要导入模块: import CTCore [as 别名]
# 或者: from CTCore import add_object [as 别名]
def do_ungzip(self,line):
try:
l = line.split(" ")
if (l[0] == ""):
self.help_ungzip()
else:
id = l[0]
body, sz = get_response_size(id, "all")
name = CTCore.get_name(id)
import gzip
decomp = gzip.GzipFile('', 'rb', 9, StringIO.StringIO(body))
page = decomp.read()
obj_num = CTCore.add_object("ungzip",page,id=id)
print " GZIP Decompression of object {} ({}) successful!".format(str(id), name)
print " New object created: {}".format(obj_num) + newLine
except Exception,e:
print str(e)