def run_install_command(graphical, cmd, args, as_root=True):
    if isinstance(args, basestring):
        cmd += ' %s' % shell_escape(args)
    elif isinstance(args, list):
        for package in args:
            if not isinstance(package, basestring):
                raise TypeError("Expected string or list of strings")
            cmd += ' %s' % shell_escape(package)
    else:
        raise TypeError("Expected string or list of strings")

    debug.warning("VisTrails wants to install package(s) %r" %
                  args)

    if as_root and systemType != 'Windows':
        if graphical:
            sucmd, escape = guess_graphical_sudo()
        else:
            if get_executable_path('sudo'):
                sucmd, escape = "sudo %s", False
            elif systemType != 'Darwin':
                sucmd, escape = "su -c %s", True
            else:
                sucmd, escape = '%s', False

        if escape:
            cmd = sucmd % shell_escape(cmd)
        else:
            cmd = sucmd % cmd

    print "about to run: %s" % cmd
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                              stderr=subprocess.STDOUT,
                              shell=True)
    lines = []
    try:
        for line in iter(p.stdout.readline, ''):
            print line,
            lines.append(line)
    except IOError, e:
        print "Ignoring IOError: %s" % e
    result = p.wait()

    if result != 0:
        debug.critical("Error running: %s" % cmd, ''.join(lines))

    return result == 0 # 0 indicates success
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/gui/bundles/installbundle.py/run_install_command/original