def install(self, project, renderer): metadata = self.fetch_metadata(project, renderer) tar_name = '{}.{}.tar.gz'.format(self.package, self.version) tar_path = os.path.realpath( os.path.join(get_downloads_path(), tar_name)) system.make_directory(os.path.dirname(tar_path)) download_url = metadata.downloads.tarball system.download(download_url, tar_path) deps_path = project.modules_path package_name = self.get_project_name(project, renderer) system.untar_package(tar_path, deps_path, package_name)
def __init__(self, args, config): if not args.from_archive: raise RuntimeException('The --from-archive parameter is required!') if args.apply: args.write_files = True args.migrate_database = True super(MigrationTask, self).__init__(args, config) self.snapshot_root = os.path.normpath(self.config.snapshot_paths[0]) system.make_directory(self.snapshot_root) self.backups_made = [] self.snapshots_written = []
def run(self): system.make_directory(self.config.modules_path) packages = self.config.packages.packages if not packages: logger.info('Warning: No packages were found in packages.yml') return with downloads_directory(): final_deps = resolve_packages(packages, self.config) for package in final_deps: logger.info('Installing {}', package) package.install(self.config) logger.info(' Installed from {}\n', package.nice_version_name()) self.track_package_install(package_name=package.name, source_type=package.source_type(), version=package.get_version())
def downloads_directory(): global DOWNLOADS_PATH remove_downloads = False # the user might have set an environment variable. Set it to that, and do # not remove it when finished. if DOWNLOADS_PATH is None: DOWNLOADS_PATH = os.getenv('DBT_DOWNLOADS_DIR') remove_downloads = False # if we are making a per-run temp directory, remove it at the end of # successful runs if DOWNLOADS_PATH is None: DOWNLOADS_PATH = tempfile.mkdtemp(prefix='dbt-downloads-') remove_downloads = True system.make_directory(DOWNLOADS_PATH) logger.debug("Set downloads directory='{}'".format(DOWNLOADS_PATH)) yield DOWNLOADS_PATH if remove_downloads: system.rmtree(DOWNLOADS_PATH) DOWNLOADS_PATH = None
def run(self): system.make_directory(self.config.modules_path) packages = self.config.packages.packages if not packages: logger.info('Warning: No packages were found in packages.yml') return with downloads_directory(): final_deps = resolve_packages(packages, self.config) renderer = DbtProjectYamlRenderer( generate_target_context(self.config, self.config.cli_vars)) for package in final_deps: logger.info('Installing {}', package) package.install(self.config, renderer) logger.info(' Installed from {}', package.nice_version_name()) if package.get_subdirectory(): logger.info(' and subdirectory {}\n', package.get_subdirectory()) self.track_package_install(package_name=package.name, source_type=package.source_type(), version=package.get_version())
def write_parse_results(self): path = os.path.join(self.root_project.target_path, PARTIAL_PARSE_FILE_NAME) make_directory(self.root_project.target_path) with open(path, 'wb') as fp: pickle.dump(self.results, fp)
def write_manifest_for_partial_parse(self): path = os.path.join(self.root_project.target_path, PARTIAL_PARSE_FILE_NAME) make_directory(self.root_project.target_path) with open(path, 'wb') as fp: pickle.dump(self.manifest, fp)
def initialize(self): make_directory(self.config.target_path) make_directory(self.config.modules_path)