Exemplo n.º 1
0
void ProcessManagerX11::_open(const FB::BrowserHostPtr& host, const std::string &path)
{
	char *env;
	std::string launcher;
	const char *x11Path = path.c_str();
	pid_t pid = fork();

	env = getenv("SHOTGUN_PLUGIN_LAUNCHER");
	launcher = (env == NULL) ? "xdg-open" : std::string(env);

	switch(pid) {
		case 0: // child
			execlp(launcher.c_str(), launcher.c_str(), x11Path, NULL);
			// should never return from execlp
			exit(1);
		default: {
			// parent
			host->htmlLog(
				"[ShotgunIntegration] Launched \"" +
				launcher + "\" \"" +
				path +
				"\" (pid " +
				boost::lexical_cast<std::string>(pid) + ")"
			);
		}
	}
}
Exemplo n.º 2
0
/*
 * Execute the toolkit command asynchronously
 */
void ProcessManager::ExecuteToolkitCommandAsync(
        const FB::BrowserHostPtr& host,
        const std::string &pipelineConfigPath,
        const std::string &command,
        const std::vector<std::string> &args,
        const ExecuteToolkitCallback &cb)
{
    host->htmlLog("[ShotgunIntegration] ExecuteToolkitCommandAsync");
    VerifyArguments(pipelineConfigPath, command);
    boost::thread cmdThread(&ProcessManager::_ExecuteToolkitCommandAsync, this, pipelineConfigPath, command, args, cb);
}
Exemplo n.º 3
0
FB::VariantMap ProcessManager::ExecuteTankCommand(
    const FB::BrowserHostPtr& host,
    const std::string &pipelineConfigPath,
    const std::string &command,
    const std::vector<std::string> &args)
{
    host->htmlLog("[ShotgunIntegration] ExecuteTankCommand");
    
    try {
        VerifyArguments(pipelineConfigPath, command);
    
        fs::path exec = pipelineConfigPath;
        exec /= TANK_SCRIPT_NAME;

        std::vector<std::string> arguments = boost::assign::list_of(exec.string())(command);
        arguments.insert(arguments.end(), args.begin(), args.end());

        bp::child child = Launch(exec.string(), arguments);
        bp::status status = child.wait();

        int retcode;
        if (status.exited())
            retcode = status.exit_status();
        else
            retcode = -1;

        std::string line;
        std::ostringstream ossStdout;
        bp::pistream &isStdout = child.get_stdout();
        while (std::getline(isStdout, line)) {
            ossStdout << line << std::endl;
        }
        
        std::ostringstream ossStderr;
        bp::pistream &isStderr = child.get_stderr();
        while (std::getline(isStderr, line)) {
            ossStderr << line << std::endl;
        }
        
        return FB::variant_map_of<std::string>
            ("retcode", retcode)
            ("out", ossStdout.str())
            ("err", ossStderr.str());
    } catch (std::exception &e) {
        // May be running in a non-main thread.  Avoid propagating exception
        return FB::variant_map_of<std::string>
            ("retcode", -1)
            ("out", std::string(""))
            ("err", std::string(e.what()));
    }
}