def _rbenv_exec(command, args='', env=None, runas=None, ret=None): if not is_installed(runas): return False binary = _rbenv_bin(runas) path = _rbenv_path(runas) environ = {} for token in _cmd_split(env): try: var, val = token.split('=') environ[var] = val except Exception: pass # if token != var=val, it's not a proper env anyway environ['RBENV_ROOT'] = path args = ' '.join([_cmd_quote(arg) for arg in _cmd_split(args)]) result = __salt__['cmd.run_all']('{0} {1} {2}'.format( binary, _cmd_quote(command), args), runas=runas, env=environ) if isinstance(ret, dict): ret.update(result) return ret if result['retcode'] == 0: return result['stdout'] else: return False
def _rbenv_exec(command, args='', env=None, runas=None, ret=None): if not is_installed(runas): return False binary = _rbenv_bin(runas) path = _rbenv_path(runas) environ = {} for token in _cmd_split(env): try: var, val = token.split('=') environ[var] = val except Exception: pass # if token != var=val, it's not a proper env anyway environ['RBENV_ROOT'] = path args = ' '.join([_cmd_quote(arg) for arg in _cmd_split(args)]) result = __salt__['cmd.run_all']( '{0} {1} {2}'.format(binary, _cmd_quote(command), args), runas=runas, env=environ ) if isinstance(ret, dict): ret.update(result) return ret if result['retcode'] == 0: return result['stdout'] else: return False
def do(cmdline=None, runas=None): ''' Execute a ruby command with rbenv's shims from the user or the system. CLI Example: .. code-block:: bash salt '*' rbenv.do 'gem list bundler' salt '*' rbenv.do 'gem list bundler' deploy ''' path = _rbenv_path(runas) environ = {'PATH': '{0}/shims:{1}'.format(path, os.environ['PATH'])} cmdline = ' '.join([_cmd_quote(cmd) for cmd in _cmd_split(cmdline)]) result = __salt__['cmd.run_all']( cmdline, runas=runas, env=environ ) if result['retcode'] == 0: rehash(runas=runas) return result['stdout'] else: return False
def do(cmdline=None, runas=None): ''' Execute a ruby command with rbenv's shims from the user or the system. CLI Example: .. code-block:: bash salt '*' rbenv.do 'gem list bundler' salt '*' rbenv.do 'gem list bundler' deploy ''' path = _rbenv_path(runas) environ = {'PATH': '{0}/shims:{1}'.format(path, os.environ['PATH'])} cmdline = ' '.join([_cmd_quote(cmd) for cmd in _cmd_split(cmdline)]) result = __salt__['cmd.run_all'](cmdline, runas=runas, env=environ) if result['retcode'] == 0: rehash(runas=runas) return result['stdout'] else: return False
def cmd_split(s): return _cmd_split(s.decode('utf-8'))
# limitations under the License. from __future__ import print_function import datetime import errno import os import re import subprocess import sys import trollius as asyncio from shlex import split as _cmd_split try: _cmd_split(u'\u00E9') def cmd_split(s): return _cmd_split(s.decode('utf-8')) except UnicodeEncodeError: cmd_split = _cmd_split try: from shlex import quote as cmd_quote except ImportError: from pipes import quote as cmd_quote from catkin_pkg.packages import find_packages from .terminal_color import ColorMapper
def cmd_split(s): if sys.version_info.major == 3: return _cmd_split(str(s, 'utf-8')) else: return _cmd_split(s.decode('utf-8'))