def unrar(rarfile, dest, excludes=None, template=None): ''' Uses the unrar command to unpack rar files Uses rar for Linux from http://www.rarlab.com/ CLI Example: .. code-block:: bash salt '*' archive.unrar /tmp/rarfile.rar /home/strongbad/ excludes=file_1,file_2 The template arg can be set to 'jinja' or another supported template engine to render the command arguments before execution. For example: .. code-block:: bash salt '*' archive.unrar template=jinja /tmp/rarfile.rar /tmp/{{grains.id}}/ excludes=file_1,file_2 ''' if isinstance(excludes, salt._compat.string_types): excludes = [entry.strip() for entry in excludes.split(',')] cmd = [_which_bin(('unrar', 'rar')), 'x', '-idp', rarfile] if excludes is not None: for exclude in excludes: cmd.extend(['-x', exclude]) cmd.append(dest) return __salt__['cmd.run'](' '.join(cmd), template=template).splitlines()
def unrar(rarfile, dest, excludes=None, template=None, runas=None): ''' Uses the unrar command to unpack rar files Uses rar for Linux from http://www.rarlab.com/ CLI Example: .. code-block:: bash salt '*' archive.unrar /tmp/rarfile.rar /home/strongbad/ excludes=file_1,file_2 The template arg can be set to 'jinja' or another supported template engine to render the command arguments before execution. For example: .. code-block:: bash salt '*' archive.unrar template=jinja /tmp/rarfile.rar /tmp/{{grains.id}}/ excludes=file_1,file_2 ''' if isinstance(excludes, string_types): excludes = [entry.strip() for entry in excludes.split(',')] cmd = [_which_bin(('unrar', 'rar')), 'x', '-idp', rarfile] if excludes is not None: for exclude in excludes: cmd.extend(['-x', exclude]) cmd.append(dest) return __salt__['cmd.run'](' '.join(cmd), template=template, runas=runas).splitlines()
def unrar(rarfile, dest, excludes=None, template=None, runas=None): ''' Uses `rar for Linux`_ to unpack rar files .. _`rar for Linux`: http://www.rarlab.com/ rarfile Name of rar file to be unpacked dest The destination directory into which to **unpack** the rar file template : None Can be set to 'jinja' or another supported template engine to render the command arguments before execution: .. code-block:: bash salt '*' archive.unrar template=jinja /tmp/rarfile.rar /tmp/{{grains.id}}/ excludes=file_1,file_2 CLI Example: .. code-block:: bash salt '*' archive.unrar /tmp/rarfile.rar /home/strongbad/ excludes=file_1,file_2 ''' if isinstance(excludes, string_types): excludes = [entry.strip() for entry in excludes.split(',')] cmd = [_which_bin(('unrar', 'rar')), 'x', '-idp', '{0}'.format(rarfile)] if excludes is not None: for exclude in excludes: cmd.extend(['-x', '{0}'.format(exclude)]) cmd.append('{0}'.format(dest)) return __salt__['cmd.run'](cmd, template=template, runas=runas, python_shell=False).splitlines()
def unrar(rarfile, dest, excludes=None, template=None): ''' Uses `rar for Linux`_ to unpack rar files .. _`rar for Linux`: http://www.rarlab.com/ rarfile Name of rar file to be unpacked dest The destination directory into which to **unpack** the rar file template : None Can be set to 'jinja' or another supported template engine to render the command arguments before execution: .. code-block:: bash salt '*' archive.unrar template=jinja /tmp/rarfile.rar /tmp/{{grains.id}}/ excludes=file_1,file_2 CLI Example: .. code-block:: bash salt '*' archive.unrar /tmp/rarfile.rar /home/strongbad/ excludes=file_1,file_2 ''' if isinstance(excludes, string_types): excludes = [entry.strip() for entry in excludes.split(',')] cmd = [_which_bin(('unrar', 'rar')), 'x', '-idp', '{0}'.format(rarfile)] if excludes is not None: for exclude in excludes: cmd.extend(['-x', '{0}'.format(exclude)]) cmd.append('{0}'.format(dest)) return __salt__['cmd.run'](cmd, template=template, python_shell=False).splitlines()