本文整理汇总了Python中lib.cuckoo.common.constants.CUCKOO_VERSION.endswith方法的典型用法代码示例。如果您正苦于以下问题:Python CUCKOO_VERSION.endswith方法的具体用法?Python CUCKOO_VERSION.endswith怎么用?Python CUCKOO_VERSION.endswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.cuckoo.common.constants.CUCKOO_VERSION
的用法示例。
在下文中一共展示了CUCKOO_VERSION.endswith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_version
# 需要导入模块: from lib.cuckoo.common.constants import CUCKOO_VERSION [as 别名]
# 或者: from lib.cuckoo.common.constants.CUCKOO_VERSION import endswith [as 别名]
def check_version():
"""Checks version of Cuckoo."""
cfg = Config()
if not cfg.cuckoo.version_check:
return
print(" Checking for updates...")
url = "http://api.cuckoosandbox.org/checkversion.php"
data = urllib.urlencode({"version": CUCKOO_VERSION})
try:
request = urllib2.Request(url, data)
response = urllib2.urlopen(request)
except (urllib2.URLError, urllib2.HTTPError):
print(red(" Failed! ") + "Unable to establish connection.\n")
return
try:
response_data = json.loads(response.read())
except ValueError:
print(red(" Failed! ") + "Invalid response.\n")
return
stable_version = response_data["current"]
if CUCKOO_VERSION.endswith("-dev"):
print(yellow(" You are running a development version! Current stable is {}.".format(
stable_version)))
else:
if LooseVersion(CUCKOO_VERSION) < LooseVersion(stable_version):
msg = "Cuckoo Sandbox version {} is available now.".format(
stable_version)
print(red(" Outdated! ") + msg)
else:
print(green(" Good! ") + "You have the latest version "
"available.\n")