def clean(): """ Remove all downloaded packages """ logger.info("[Deleting] remove java libs in %s" % get_lib_path()) shutil.rmtree(get_lib_path()) index_manager.remove_all() index_manager.commit() logger.info("[Finished] all downloaded files erased")
def update(artifact_id): """ Update a snapshot artifact, check for new version """ artifact = Artifact.from_id(artifact_id) artifact = index_manager.get_artifact(artifact) if artifact is None: logger.error('[Error] Can not update %s, please install it first' % artifact) sys.exit(1) if artifact.is_snapshot(): selected_repos = artifact.repos installed_file = os.path.join(get_lib_path(), artifact.to_jip_name()) if os.path.exists(installed_file): lm = os.stat(installed_file)[stat.ST_MTIME] ## find the repository contains the new release ts = selected_repos.last_modified(artifact) if ts is not None and ts > lm : ## download new jar selected_repos.download_jar(artifact, get_lib_path()) ## try to update dependencies pomstring = selected_repos.download_pom(artifact) pom = Pom(pomstring) dependencies = pom.get_dependencies() _install(dependencies) else: logger.error('[Error] Artifact not installed: %s' % artifact) sys.exit(1) else: logger.error('[Error] Can not update non-snapshot artifact') return
def update(artifact_id): """ Update a snapshot artifact, check for new version """ artifact = Artifact.from_id(artifact_id) artifact = index_manager.get_artifact(artifact) if artifact is None: logger.error('[Error] Can not update %s, please install it first' % artifact) sys.exit(1) if artifact.is_snapshot(): selected_repos = artifact.repos installed_file = os.path.join(get_lib_path(), artifact.to_jip_name()) if os.path.exists(installed_file): lm = os.stat(installed_file)[stat.ST_MTIME] ## find the repository contains the new release ts = selected_repos.last_modified(artifact) if ts is not None and ts > lm: ## download new jar selected_repos.download_jar(artifact, get_lib_path()) ## try to update dependencies pomstring = selected_repos.download_pom(artifact) pom = Pom(pomstring) dependencies = pom.get_dependencies() _install(dependencies) else: logger.error('[Error] Artifact not installed: %s' % artifact) sys.exit(1) else: logger.error('[Error] Can not update non-snapshot artifact') return
def _install(artifacts, exclusions=[], options={}): dryrun = options.get("dry-run", False) verify = not options.get("insecure", True) _exclusions = options.get('exclude', []) copy_pom = options.get('copy-pom', False) if _exclusions: _exclusions = map(lambda x: Artifact(*(x.split(":"))), _exclusions) exclusions.extend(_exclusions) download_list = _resolve_artifacts(artifacts, exclusions, verify) if not dryrun: ## download to cache first for artifact in download_list: if artifact.repos != cache_manager.as_repos(): artifact.repos.download_jar( artifact, cache_manager.get_jar_path(artifact), verify) pool.join() for artifact in download_list: cache_manager.get_artifact_jar(artifact, get_lib_path()) if copy_pom: cache_manager.get_artifact_pom(artifact, get_lib_path()) index_manager.commit() logger.info("[Finished] dependencies resolved") else: logger.info("[Install] Artifacts to install:") for artifact in download_list: logger.info(artifact)
def _install(artifacts, exclusions=[], options={}): dryrun = options.get("dry-run", False) _exclusions = options.get('exclude', []) copy_pom = options.get('copy-pom', False) if _exclusions: _exclusions = map(lambda x: Artifact(*(x.split(":"))), _exclusions) exclusions.extend(_exclusions) download_list = _resolve_artifacts(artifacts, exclusions) if not dryrun: ## download to cache first for artifact in download_list: if artifact.repos != cache_manager.as_repos(): artifact.repos.download_jar(artifact, cache_manager.get_jar_path(artifact)) pool.join() for artifact in download_list: cache_manager.get_artifact_jar(artifact, get_lib_path()) if copy_pom: cache_manager.get_artifact_pom(artifact, get_lib_path()) index_manager.commit() logger.info("[Finished] dependencies resolved") else: logger.info("[Install] Artifacts to install:") for artifact in download_list: logger.info(artifact)
def keep_consistent(self): in_path_libs = os.listdir(get_lib_path()) remembered_libs = list(self.installed) for artifact in remembered_libs: local_name = artifact.to_jip_name() if local_name not in in_path_libs: logger.warn(('[Warning] %s is not in your path which should be installed by previous actions. ' + 'If you still need it, please reinstall it by: jip install %s') % (local_name, str(artifact))) self.remove_artifact(artifact)
def keep_consistent(self): in_path_libs = os.listdir(get_lib_path()) remembered_libs = list(self.installed) for artifact in remembered_libs: local_name = artifact.to_jip_name() if local_name not in in_path_libs: logger.warn(( '[Warning] %s is not in your path which should be installed by previous actions. ' + 'If you still need it, please reinstall it by: jip install %s' ) % (local_name, str(artifact))) self.remove_artifact(artifact)
def remove(artifact_id): """ Remove an artifact from library path """ logger.info('[Checking] %s in library index' % artifact_id) artifact = Artifact.from_id(artifact_id) artifact_path = os.path.join(get_lib_path(), artifact.to_jip_name()) if index_manager.is_installed(artifact) and os.path.exists(artifact_path): os.remove(artifact_path) index_manager.remove_artifact(artifact) index_manager.commit() logger.info('[Finished] %s removed from library path' % artifact_id) else: logger.error('[Error] %s not installed' % artifact_id) sys.exit(1)