Skip to content

Instantly share code, notes, and snippets.

Created May 26, 2015 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/dbe2e91b25bbc664b3eb to your computer and use it in GitHub Desktop.
Save anonymous/dbe2e91b25bbc664b3eb to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# vim: set ft=python
"""
Run the given command via cmd.run, expect json
"""
import json
import logging
import salt.log
import salt.utils
import salt.modules.cmdmod
__virtualname__ = 'cmd_run_json'
log = logging.getLogger(__name__)
def parse(script_path_and_options):
"""Do things.
"""
script_output = __salt__['cmd.run'](script_path_and_options,
python_shell=True)
try:
return json.loads(script_output)
except ValueError:
return {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment