From c366945d894b22646985b2c21e3c56df598b10d4 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Sat, 4 Jan 2014 17:14:18 -0500 Subject: [PATCH 1/2] Improved behavior when tmp directory exists --- scripts/devSetup/directoryController.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/scripts/devSetup/directoryController.py b/scripts/devSetup/directoryController.py index b6cd7fd8d..68b82a5fc 100644 --- a/scripts/devSetup/directoryController.py +++ b/scripts/devSetup/directoryController.py @@ -31,18 +31,12 @@ class DirectoryController(object): os.mkdir(full_path) def create_base_directories(self): - #first create the directory for the development environment to be installed in try: - #os.mkdir(self.root_install_directory) - #then the tmp directory for file downloads and the like - os.mkdir(self.tmp_directory) - #then the bin directory for binaries(also includes binaries for dependencies? - #os.mkdir(self.bin_directory) + if os.path.exists(self.tmp_directory): + shutil.rmtree(self.tmp_directory) + os.mkdir(self.tmp_directory) except: - #cleanup whatever we created - #self.remove_directories() - raise errors.CoCoError(u"There was an error creating the directory structure, do you have correct permissions? Please remove all and start over.") - + raise errors.CoCoError(u"There was an error creating the directory structure, do you have correct permissions? Please remove all and start over.") def remove_directories(self): print u"Removed directories created!" From 5687fae1cc6b9b04c061fb0a0007bb427e8006f1 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Sat, 4 Jan 2014 17:53:41 -0500 Subject: [PATCH 2/2] More intermittent improvements and cleanup --- scripts/devSetup/directoryController.py | 9 +++++---- scripts/devSetup/factories.py | 14 ++++++-------- scripts/devSetup/mongo.py | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/devSetup/directoryController.py b/scripts/devSetup/directoryController.py index 68b82a5fc..03bec6705 100644 --- a/scripts/devSetup/directoryController.py +++ b/scripts/devSetup/directoryController.py @@ -12,7 +12,6 @@ class DirectoryController(object): @property def root_install_directory(self): - #return self.root_dir + os.sep + u"codecombat" return self.root_dir + os.sep + "coco" + os.sep + "bin" @property def tmp_directory(self): @@ -31,14 +30,16 @@ class DirectoryController(object): os.mkdir(full_path) def create_base_directories(self): + shutil.rmtree(self.root_dir + os.sep + "coco" + os.sep + "node_modules",ignore_errors=True) #just in case try: if os.path.exists(self.tmp_directory): - shutil.rmtree(self.tmp_directory) + self.remove_directories() os.mkdir(self.tmp_directory) except: raise errors.CoCoError(u"There was an error creating the directory structure, do you have correct permissions? Please remove all and start over.") def remove_directories(self): - print u"Removed directories created!" shutil.rmtree(self.tmp_directory) - #shutil.rmtree(self.root_install_directory) + shutil.rmtree(self.bin_directory + os.sep + "node",ignore_errors=True) + shutil.rmtree(self.bin_directory + os.sep + "mongo",ignore_errors=True) + diff --git a/scripts/devSetup/factories.py b/scripts/devSetup/factories.py index 2d71f2860..1edbec108 100644 --- a/scripts/devSetup/factories.py +++ b/scripts/devSetup/factories.py @@ -10,17 +10,19 @@ import shutil import os import glob import subprocess +def print_computer_information(os_name,address_width): + print(os_name + " detected, architecture: " + str(address_width) + " bit") def constructSetup(): config = configuration.Configuration() + address_width = config.system.get_virtual_memory_address_width() if config.system.operating_system == u"mac": - print("Mac detected, architecture: " + str(config.system.get_virtual_memory_address_width()) + " bit") + print_computer_information("Mac",address_width) return MacSetup(config) elif config.system.operating_system == u"win": - print("Windows detected, architecture: " + str(config.system.get_virtual_memory_address_width())+ " bit") + print_computer_information("Windows",address_width) raise NotImplementedError("Windows is not supported at this time.") - #return WinSetup(config) elif config.system.operating_system == u"linux": - print("Linux detected, architecture: " + str(config.system.get_virtual_memory_address_width())+ " bit") + print_computer_information("Linux",address_width) return LinuxSetup(config) class SetupFactory(object): @@ -60,13 +62,9 @@ class SetupFactory(object): print("2. ./coco-brunch") print("3. ./coco-dev-server") print("Once brunch is done, visit http://localhost:3000!") - #print self.mongo.bashrc_string() - #print self.node.bashrc_string() - #print "COCO_DIR="+ self.config.directory.root_dir + os.sep + "coco" def cleanup(self): self.config.directory.remove_directories() - class MacSetup(SetupFactory): def setup(self): super(self.__class__, self).setup() diff --git a/scripts/devSetup/mongo.py b/scripts/devSetup/mongo.py index b6917967f..b706c2ae8 100644 --- a/scripts/devSetup/mongo.py +++ b/scripts/devSetup/mongo.py @@ -12,7 +12,7 @@ class MongoDB(Dependency): super(self.__class__, self).__init__(configuration) operating_system = configuration.system.operating_system self.config.directory.create_directory_in_tmp(u"mongo") - #self.config.directory.create_directory_in_bin("mongo") + if operating_system == u"mac": self.downloader = MacMongoDBDownloader(self) elif operating_system == u"win":