From 137d2b0fd4b50f3e206b0bc46b6ffe11c112dcc1 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 11 Apr 2014 20:37:06 -0700 Subject: [PATCH] Fixed #419 to not redo node/mongo downloads when rerunning the script. --- scripts/devSetup/factories.py | 8 +++++--- scripts/devSetup/mongo.py | 12 ++++++++---- scripts/devSetup/node.py | 11 ++++++++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/devSetup/factories.py b/scripts/devSetup/factories.py index f14f922ec..fa82e1abe 100644 --- a/scripts/devSetup/factories.py +++ b/scripts/devSetup/factories.py @@ -37,10 +37,12 @@ class SetupFactory(object): try: mongo_version_string = subprocess.check_output("mongod --version",shell=True) mongo_version_string = mongo_version_string.decode(encoding='UTF-8') - except: - print("Mongod not found.") + except Exception, e: + print("Mongod not found: %s"%e) if "v2.6." not in mongo_version_string: - print("MongoDB not found, so installing...") + if mongo_version_string: + print("Had MongoDB version: %s"%mongo_version_string) + print("MongoDB not found, so installing a local copy...") self.mongo.download_dependencies() self.mongo.install_dependencies() self.node.download_dependencies() diff --git a/scripts/devSetup/mongo.py b/scripts/devSetup/mongo.py index e653219e1..eb57ea452 100644 --- a/scripts/devSetup/mongo.py +++ b/scripts/devSetup/mongo.py @@ -8,7 +8,7 @@ import os from configuration import Configuration from dependency import Dependency import sys - +import shutil class MongoDB(Dependency): def __init__(self,configuration): @@ -32,12 +32,16 @@ class MongoDB(Dependency): def bashrc_string(self): return "COCO_MONGOD_PATH=" + self.config.directory.bin_directory + os.sep + u"mongo" + os.sep +"bin" + os.sep + "mongod" + def download_dependencies(self): - self.downloader.download() - self.downloader.decompress() + install_directory = self.config.directory.bin_directory + os.sep + u"mongo" + if os.path.exists(install_directory): + print(u"Skipping MongoDB download because " + install_directory + " exists.") + else: + self.downloader.download() + self.downloader.decompress() def install_dependencies(self): install_directory = self.config.directory.bin_directory + os.sep + u"mongo" - import shutil if os.path.exists(install_directory): print(u"Skipping creation of " + install_directory + " because it exists.") else: diff --git a/scripts/devSetup/node.py b/scripts/devSetup/node.py index 35d1daf30..8fb1265d8 100644 --- a/scripts/devSetup/node.py +++ b/scripts/devSetup/node.py @@ -37,21 +37,26 @@ class Node(Dependency): return self.config.directory.bin_directory def download_dependencies(self): - self.downloader.download() - self.downloader.decompress() + install_directory = self.config.directory.bin_directory + os.sep + u"node" + if os.path.exists(install_directory): + print(u"Skipping Node download because " + install_directory + " exists.") + else: + self.downloader.download() + self.downloader.decompress() def bashrc_string(self): return "COCO_NODE_PATH=" + self.config.directory.bin_directory + os.sep + u"node" + os.sep + "bin" + os.sep +"node" def install_dependencies(self): install_directory = self.config.directory.bin_directory + os.sep + u"node" #check for node here - unzipped_node_path = self.findUnzippedNodePath() if self.config.system.operating_system in ["mac","linux"] and not which("node"): + unzipped_node_path = self.findUnzippedNodePath() print("Copying node into /usr/local/bin/...") shutil.copy(unzipped_node_path + os.sep + "bin" + os.sep + "node","/usr/local/bin/") os.chmod("/usr/local/bin/node",S_IRWXG|S_IRWXO|S_IRWXU) if os.path.exists(install_directory): print(u"Skipping creation of " + install_directory + " because it exists.") else: + unzipped_node_path = self.findUnzippedNodePath() shutil.copytree(self.findUnzippedNodePath(),install_directory) wants_to_upgrade = True if self.check_if_executable_installed(u"npm"):