Ejemplo n.º 1
0
/* once init'ed, you might want to extractBinaries()
 * If you do, what comes after is very platform specific.
 * Once you've taken care of the platform specific details,
 * or if there are no binaries to extract, you go on
 * to doIt(), which is the important part
 */
int doIt(ARCHIVE_STATUS *status, int argc, char *argv[])
{
	int rc = 0;
	/* Load Python DLL */
	if (loadPython(status))
		return -1;

	/* Start Python. */
	if (startPython(status, argc, argv))
		return -1;

	/* Import modules from archive - bootstrap */
	if (importModules(status))
		return -1;

	/* Install zlibs  - now all hooks in place */
	if (installZlibs(status))
		return -1;

	/* Run scripts */
	rc = runScripts(status);

	VS("OK.\n");

	return rc;
}
Ejemplo n.º 2
0
Archivo: ps.c Proyecto: iceant/mks
int main(int argc, char* argv[]) { 
	if( 3 > argc ) 
    { 
        printf( "ps [suspend|resume|kill] <app_name>\n" ); 
        return 0; 

    } 
	
	char client_path[BUF_SIZE]={0};
	char hostname[BUF_SIZE]={0};
	int port=7010;
	char username[BUF_SIZE]={0};
	char password[BUF_SIZE]={0};
	read_ini(&client_path, &hostname, &port, &username, &password);
	char cmd[BUF_SIZE]={0};
	sprintf(cmd, "%s\\bin\\aa.exe connect --hostname=%s --port=%d --user=%s --password=%s", client_path, hostname, port, username, password);
	
	BOOL bRet;
	if( ! strcmpi( argv[1], "suspend" )){
		bRet = NTPauseResumeProcess(argv[2], FALSE);
		if(bRet){
			KillProcessByName("IntegrityClient.exe");
		}
		
	}else
	if( ! strcmpi( argv[1], "resume" )){
		printf("Running... \"%s\"\n", cmd);
		BOOL bRunStatus = runScripts(cmd);
		if(bRunStatus)
			bRet = NTPauseResumeProcess(argv[2], TRUE);
	}else
	if( ! strcmpi( argv[1], "kill" )){
		KillProcessByName(argv[2]);
		printf("Running... \"%s\"\n", cmd);
		bRet = runScripts(cmd);
	}
	printf("Result By Process:%d\n", bRet);

	//KillProcessByName("IntegrityClient.exe"); 
	return 0; 
}
Ejemplo n.º 3
0
/*
 * Launch an archive with the given fully-qualified path name
 * No command line, no extracting of binaries
 * Designed for embedding situations.
 */
int launchembedded(char const * archivePath, char  const * archiveName)
{
	char pathnm[_MAX_PATH];

	VS("START\n");
	strcpy(pathnm, archivePath);
	strcat(pathnm, archiveName);
	/* Set up paths */
	if (setPaths(archivePath, archiveName))
		return -1;
	VS("Got Paths\n");
	/* Open the archive */
	if (openArchive())
		return -1;
	VS("Opened Archive\n");
	/* Load Python DLL */
	if (loadPython())
		return -1;

	/* Start Python with silly command line */
	if (startPython(1, (char**)&pathnm))
		return -1;
	VS("Started Python\n");

	/* a signal to scripts */
	PyRun_SimpleString("import sys;sys.frozen='dll'\n");
	VS("set sys.frozen\n");
	/* Import modules from archive - this is to bootstrap */
	if (importModules())
		return -1;
	VS("Imported Modules\n");
	/* Install zlibs - now import hooks are in place */
	if (installZlibs())
		return -1;
	VS("Installed Zlibs\n");
	/* Run scripts */
	if (runScripts())
		return -1;
	VS("All scripts run\n");
	if (PyErr_Occurred()) {
		// PyErr_Print();
		//PyErr_Clear();
		VS("Some error occurred\n");
	}
	VS("OK.\n");

	return 0;
}
Ejemplo n.º 4
0
void KWin::Scripting::start()
{
#if 0
    // TODO make this threaded again once KConfigGroup is sufficiently thread safe, bug #305361 and friends
    // perform querying for the services in a thread
    QFutureWatcher<LoadScriptList> *watcher = new QFutureWatcher<LoadScriptList>(this);
    connect(watcher, SIGNAL(finished()), this, SLOT(slotScriptsQueried()));
    watcher->setFuture(QtConcurrent::run(this, &KWin::Scripting::queryScriptsToLoad, pluginStates, offers));
#else
    LoadScriptList scriptsToLoad = queryScriptsToLoad();
    for (LoadScriptList::const_iterator it = scriptsToLoad.constBegin();
            it != scriptsToLoad.constEnd();
            ++it) {
        if (it->first) {
            loadScript(it->second.first, it->second.second);
        } else {
            loadDeclarativeScript(it->second.first, it->second.second);
        }
    }

    runScripts();
#endif
}
    void
    onInterest(const ndn::Name& name, const ndn::Interest& interest)
    {
        ndn::Name interestName(interest.getName());

        if(DEBUG)
            std::cout << "received interest: " << interest.getName() << std::endl;

        //run scripts if requested by server
        ndn::Name cmpName(getFilter()+SCRIPT_SUFFIX);
        int num_components = cmpName.size();
        if(cmpName.isPrefixOf(interestName))
        {
            int numberOfComponents = interestName.size();
            for(int i = num_components; i < numberOfComponents; ++i)
            {
                m_scriptsList.push_front(interestName[i].toUri());
            }
            runScripts(interestName);
        }
        else
        {
            int numberOfComponents = interestName.size();
            if(!m_remoteLinks.empty())
            {
                std::cerr << "remote links list is not empty - check for a missing reports!!" << std::endl;
                m_remoteLinks.clear();
            }
            for(int i = name.size(); i < numberOfComponents; ++i)
            {
                m_remoteLinks.insert(interestName[i].toUri());
            }

            // ask for local status
            fetchFaceStatusInformation(interestName);
        }
    }
Ejemplo n.º 6
0
int launch(char const * archivePath, char  const * archiveName)
{
	PyObject *obHandle;
	int loadedNew = 0;
	char pathnm[_MAX_PATH];

    VS("START");
	strcpy(pathnm, archivePath);
	strcat(pathnm, archiveName);
    /* Set up paths */
    if (setPaths(archivePath, archiveName))
        return -1;
	VS("Got Paths");
    /* Open the archive */
    if (openArchive())
        return -1;
	VS("Opened Archive");
    /* Load Python DLL */
    if (attachPython(&loadedNew))
        return -1;

	if (loadedNew) {
		/* Start Python with silly command line */
		PyEval_InitThreads();
		if (startPython(1, (char**)&pathnm))
			return -1;
		VS("Started new Python");
		thisthread = PyThreadState_Swap(NULL);
		PyThreadState_Swap(thisthread);
	}
	else {
		VS("Attached to existing Python");

		/* start a mew interp */
		thisthread = PyThreadState_Swap(NULL);
		PyThreadState_Swap(thisthread);
		if (thisthread == NULL) {
			thisthread = Py_NewInterpreter();
			VS("created thisthread");
		}
		else
			VS("grabbed thisthread");
		PyRun_SimpleString("import sys;sys.argv=[]");
	}

	/* a signal to scripts */
	PyRun_SimpleString("import sys;sys.frozen='dll'\n");
	VS("set sys.frozen");
	/* Create a 'frozendllhandle' as a counterpart to
	   sys.dllhandle (which is the Pythonxx.dll handle)
	*/
	obHandle = Py_BuildValue("i", gInstance);
	PySys_SetObject("frozendllhandle", obHandle);
	Py_XDECREF(obHandle);
    /* Import modules from archive - this is to bootstrap */
    if (importModules())
        return -1;
	VS("Imported Modules");
    /* Install zlibs - now import hooks are in place */
    if (installZlibs())
        return -1;
	VS("Installed Zlibs");
    /* Run scripts */
    if (runScripts())
        return -1;
	VS("All scripts run");
    if (PyErr_Occurred()) {
		// PyErr_Print();
		//PyErr_Clear();
		VS("Some error occurred");
    }
	VS("PGL released");
	// Abandon our thread state.
	PyEval_ReleaseThread(thisthread);
    VS("OK.");
    return 0;
}