Skip to content

Commit

Permalink
Added version check
Browse files Browse the repository at this point in the history
  • Loading branch information
Nex committed Oct 3, 2012
1 parent efede2b commit 95215ad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions cuckoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def main():
check_configs()
create_structure()
init_logging()
check_version()

parser = argparse.ArgumentParser()
parser.add_argument("-q", "--quiet", help="Display only error messages", action="store_true", required=False)
Expand Down
25 changes: 24 additions & 1 deletion lib/cuckoo/core/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

import os
import sys
import json
import urllib
import urllib2
import logging

from lib.cuckoo.common.constants import CUCKOO_ROOT
from lib.cuckoo.common.constants import CUCKOO_ROOT, CUCKOO_VERSION
from lib.cuckoo.common.exceptions import CuckooStartupError, CuckooOperationalError
from lib.cuckoo.common.utils import create_folders
from lib.cuckoo.common.config import Config
from lib.cuckoo.common.colors import *

log = logging.getLogger()

Expand Down Expand Up @@ -83,3 +88,21 @@ def init_logging():
fh.setFormatter(formatter)
log.addHandler(fh)
log.setLevel(logging.INFO)

def check_version():
"""Check version of Cuckoo."""
cfg = Config()
url = "http://api.cuckoosandbox.org/checkversion.php"

data = urllib.urlencode({"version" : CUCKOO_VERSION})

try:
request = urllib2.Request(url, data)
response = urllib2.urlopen(request)
except (URLError, HTTPError):
return

response_data = json.loads(response.read())
if not response_data["error"]:
if response_data["response"] == "NEW_VERSION":
print(" You have an outdated Cuckoo, version %s is available now\n" % green(response_data["current"]))

0 comments on commit 95215ad

Please sign in to comment.