subprocess.

Here are the examples of the python api subprocess. taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

Example 1

Project: ansible-websphere Source File: wsadmin.py
Function: main
def main():

    # Read arguments
    module = AnsibleModule(
        argument_spec = dict(
            params = dict(required=True),
            host = dict(default='localhost', required=False),
            port = dict(default='8879', required=False),
            username = dict(required=False),
            password = dict(required=False),
            script = dict(required=True)
        )
    )

    params = module.params['params']
    host = module.params['host']
    port = module.params['port']
    username = module.params['username']
    password = module.params['password']
    script = module.params['script']

    # Run wsadmin command server
    if state == 'stopped':
        child = subprocess.Popen([wasdir+"/bin/wsadmin.sh -lang jython -conntype SOAP -host "+host+" -port "+port+" -username " + username + " -password " + password " -f "+script+" "+params], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout_value, stderr_value = child.communicate()
        if child.returncode != 0:
            module.fail_json(msg="Failed executing wsadmin script: " + ¨script, stdout=stdout_value, stderr=stderr_value)

        module.exit_json(changed=True, msg="Script executed successfully: " + scrpit, stdout=stdout_value)