<s> """<STR_LIT>""" <EOL> import logging <EOL> from fabric . context_managers import settings , hide , shell_env <EOL> from fabric . decorators import task , runs_once <EOL> from fabric . operations import sudo , put , os , local <EOL> from fabric . state import env <EOL> from fabric . tasks import execute <EOL> from fabric . utils import abort <EOL> from prestoadmin . util import constants <EOL> from prestoadmin . standalone . config import StandaloneConfig <EOL> from prestoadmin . util . base_config import requires_config <EOL> from prestoadmin . util . fabricapi import get_host_list <EOL> _LOGGER = logging . getLogger ( __name__ ) <EOL> __all__ = [ '<STR_LIT>' ] <EOL> @ task <EOL> @ runs_once <EOL> @ requires_config ( StandaloneConfig ) <EOL> def install ( local_path ) : <EOL> """<STR_LIT>""" <EOL> check_if_valid_rpm ( local_path ) <EOL> return execute ( deploy_install , local_path , hosts = get_host_list ( ) ) <EOL> def check_if_valid_rpm ( local_path ) : <EOL> _LOGGER . info ( "<STR_LIT>" ) <EOL> with settings ( hide ( '<STR_LIT>' , '<STR_LIT>' ) , warn_only = True ) : <EOL> result = local ( '<STR_LIT>' + local_path , capture = True ) <EOL> if '<STR_LIT>' in result . stdout : <EOL> abort ( "<STR_LIT>" ) <EOL> elif result . stderr : <EOL> abort ( result . stderr ) <EOL> def deploy_install ( local_path ) : <EOL> deploy_action ( local_path , rpm_install ) <EOL> def deploy_upgrade ( local_path ) : <EOL> deploy_action ( local_path , rpm_upgrade ) <EOL> def deploy_action ( local_path , rpm_action ) : <EOL> deploy ( local_path ) <EOL> rpm_action ( os . path . basename ( local_path ) ) <EOL> def deploy ( local_path = None ) : <EOL> _LOGGER . info ( "<STR_LIT>" % env . host ) <EOL> print ( "<STR_LIT>" % env . host ) <EOL> sudo ( '<STR_LIT>' + constants . REMOTE_PACKAGES_PATH ) <EOL> ret_list = put ( local_path , constants . REMOTE_PACKAGES_PATH , use_sudo = True ) <EOL> if not ret_list . succeeded : <EOL> _LOGGER . warn ( "<STR_LIT>" ) <EOL> ret_list = put ( local_path , constants . REMOTE_PACKAGES_PATH , <EOL> use_sudo = True , temp_dir = '<STR_LIT>' ) <EOL> if ret_list . succeeded : <EOL> print ( "<STR_LIT>" + env . host ) <EOL> def rpm_install ( rpm_name ) : <EOL> _LOGGER . info ( "<STR_LIT>" ) <EOL> nodeps = '<STR_LIT>' <EOL> if env . nodeps : <EOL> nodeps = '<STR_LIT>' <EOL> if '<STR_LIT>' not in env or env . java8_home is None : <EOL> ret = sudo ( '<STR_LIT>' % <EOL> ( nodeps , os . path . join ( constants . REMOTE_PACKAGES_PATH , <EOL> rpm_name ) ) ) <EOL> else : <EOL> with shell_env ( JAVA8_HOME = '<STR_LIT:%s>' % env . java8_home ) : <EOL> ret = sudo ( '<STR_LIT>' % <EOL> ( nodeps , os . path . join ( constants . REMOTE_PACKAGES_PATH , <EOL> rpm_name ) ) ) <EOL> if ret . succeeded : <EOL> print ( "<STR_LIT>" + env . host ) <EOL> def rpm_upgrade ( rpm_name ) : <EOL> _LOGGER . info ( "<STR_LIT>" ) <EOL> nodeps = '<STR_LIT>' <EOL> if env . nodeps : <EOL> nodeps = '<STR_LIT>' <EOL> package_path = os . path . join ( constants . REMOTE_PACKAGES_PATH , rpm_name ) <EOL> package_name = sudo ( '<STR_LIT>' <EOL> % package_path , quiet = True ) <EOL> ret_uninstall = sudo ( '<STR_LIT>' % ( nodeps , package_name ) ) <EOL> ret_install = sudo ( '<STR_LIT>' % ( nodeps , package_path ) ) <EOL> if ret_uninstall . succeeded and ret_install . succeeded : <EOL> print ( "<STR_LIT>" + env . host ) </s>
