def __off(service): if __isOn(service): with hide('everything'): execute('chkconfig %s off' % service) done("echo 'turn off : %s'" % service) else: already("echo 'already off : %s'" % service)
def __stop(service): if __isRunning(service): with hide('everything'): execute('service %s stop' % service) done("echo 'stopped : %s'" % service) else: already("echo 'already stopped : %s'" % service)
def __addRepository(name, url): package = __repository(name) if __doesNotHasRepository(package): with hide('everything'): execute('rpm -iv %s' % url) done("echo 'install complete : %s'" % __repository(name)) else: already("echo 'already installed : %s'" % package)
def __addRepository(name, url): package = __repository(name) if __doesNotHasRepository(package): with hide('everything'): execute('rpm -iv %s' % url) done("echo 'install complete : %s'" % __repository(name)) else: already("echo 'already installed : %s'" % package)
def __on(service): if __isOn(service): already("echo 'already on : %s'" % service) else: with hide('everything'): stdout = execute('chkconfig %s on; true' % service) if 'No such file or directory' in stdout: error("echo 'turn on error : %s is unrecognized'" % service) else: done("echo 'turn on : %s'" % service)
def __start(service): if __isRunning(service): already("echo 'already started : %s'" % service) else: with hide('everything'): stdout = execute('service %s start; true' % service) if 'unrecognized' in stdout: error("echo 'start error : %s is unrecognized'" % service) else: done("echo 'started : %s'" % service)
def __install(package, repositories): if __isNotInstalled(package): with hide('stdout'): stdout = execute('yum install -y %s%s; true' % (__enablerepos(repositories), package)) if 'Error: Nothing to do' in stdout: error("echo 'install error : No package %s available.'" % package) else: done("echo 'install complete : %s'" % __version(package)) else: already("echo 'already installed : %s'" % __version(package))
def generate(): from result import done, already dst = '%s/my_configure.py' % os.getcwd() src = os.path.join(os.path.dirname(__file__), 'default_configure.py') if os.path.exists(dst): already('echo already exists : %s' % dst) else: with hide('everything'): local('cp %s %s' % (src, dst)) done('echo cteate complete : %s' % dst)
def generate(): from result import done, already dst = '%s/my_configure.py' % os.getcwd() src = os.path.join(os.path.dirname(__file__), 'default_configure.py') if os.path.exists(dst): already('echo already exists : %s' % dst) else: with hide('everything'): local('cp %s %s' % (src, dst)) done('echo cteate complete : %s' % dst)
def __install(package, repositories): if __isNotInstalled(package): with hide('stdout'): stdout = execute('yum install -y %s%s; true' % (__enablerepos(repositories), package)) if 'Error: Nothing to do' in stdout: error("echo 'install error : No package %s available.'" % package) else: done("echo 'install complete : %s'" % __version(package)) else: already("echo 'already installed : %s'" % __version(package))
def __backup(path): if __hasNoBackup(path): if not isExists(path): error('echo not exists : %s' % path) return False else: with hide('everything'): execute('cp -p %s %s.origin' % (path, path)) done('echo create backup : %s.origin' % path) return True else: already('echo already exists : %s' % path) return True
def __backup(path): if __hasNoBackup(path): if not isExists(path): error('echo not exists : %s' % path) return False else: with hide('everything'): execute('cp -p %s %s.origin' % (path, path)) done('echo create backup : %s.origin' % path) return True else: already('echo already exists : %s' % path) return True