def install_requirements(self, requirement_files): if requirement_files: utils.vagrant_pip_clear() old_packages = utils.vagrant_pip_freeze() for requirement_file in requirement_files: out = utils.vagrant_pip_install(requirement_file, True) new_packages = utils.vagrant_pip_freeze() diff_packages = list(set(new_packages) - set(old_packages)) return diff_packages else: return []
def deployRepoAttempt(self, attempt, deployPath): utils.vagrant_pip_clear() setup_files = utils.search_file(deployPath, 'setup.py') LOG.info('setup.py: ' + str(setup_files)) if len(setup_files): return ATTEMPT_STATUS_NOT_AN_APPLICATION setting_files = utils.search_file(deployPath, 'settings.py') LOG.info('settings.py: ' + str(setting_files)) if not len(setting_files): return ATTEMPT_STATUS_MISSING_REQUIRED_FILES manage_files = utils.search_file(deployPath, 'manage.py') LOG.info('manage.py: ' + str(manage_files)) if not len(manage_files): return ATTEMPT_STATUS_MISSING_REQUIRED_FILES self.requirement_files = utils.search_file(deployPath, 'requirements.txt') LOG.info('REQUIREMENTS: ' + str(self.requirement_files)) manage_paths = [os.path.dirname(manage_file) for manage_file in manage_files] LOG.info("MANAGE_PATHS: " + str(manage_paths)) setting_paths = [os.path.dirname(os.path.dirname(setting_file)) for setting_file in setting_files] LOG.info("setting_paths: " + str(setting_paths)) base_dirs = set.intersection(set(manage_paths), set(setting_paths)) if not base_dirs: LOG.error('can not find base directory') return ATTEMPT_STATUS_MISSING_REQUIRED_FILES base_dir = next(iter(base_dirs)) LOG.info('BASE_DIR: ' + base_dir) manage_file = next(name for name in manage_files if name.startswith(base_dir)) setting_file = next(name for name in setting_files if name.startswith(base_dir)) # Database attempt.database = self.getDatabase(setting_file) LOG.info('DATABASE: ' + attempt.database.name) # Base Dir attempt.base_dir = base_dir.split('/', 1)[1] LOG.info('BASE_DIR: ' + attempt.base_dir) # Settings Dir attempt.setting_dir = os.path.basename(os.path.dirname(setting_file)) LOG.info('SETTING_DIR: ' + attempt.setting_dir) # Try to deploy! return self.tryDeploy(attempt, manage_file, setting_file)