mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 19:06:59 -05:00
Fixed #419 to not redo node/mongo downloads when rerunning the script.
This commit is contained in:
parent
8ea2a80088
commit
137d2b0fd4
3 changed files with 21 additions and 10 deletions
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
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:
|
||||
|
|
|
@ -37,6 +37,10 @@ class Node(Dependency):
|
|||
return self.config.directory.bin_directory
|
||||
|
||||
def download_dependencies(self):
|
||||
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):
|
||||
|
@ -44,14 +48,15 @@ class Node(Dependency):
|
|||
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"):
|
||||
|
|
Loading…
Reference in a new issue