• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PySys_SetArgv函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PySys_SetArgv函数的典型用法代码示例。如果您正苦于以下问题:C++ PySys_SetArgv函数的具体用法?C++ PySys_SetArgv怎么用?C++ PySys_SetArgv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PySys_SetArgv函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pycaml_setargs

@@ -1468,7 +1468,7 @@ value pycaml_setargs(value argv) {
 
   PySys_SetArgv(1, cargv);
 
-  CAMLreturn0; 
+  CAMLreturn(Val_unit);
 }
开发者ID:EliseuTorres,项目名称:pkgsrc,代码行数:7,代码来源:patch-pycaml_pycaml__ml.c


示例2: python_system_init

/* Initialize Python interpreter */
static void python_system_init(lua_State *L) {
    char *python_home = luaL_check_string(L, 1);
    if (!Py_IsInitialized()) {
        python_setnumber(L, PY_API_IS_EMBEDDED, 1); // If python is inside Lua
        if (PyType_Ready(&LuaObject_Type) == 0) {
            Py_INCREF(&LuaObject_Type);
        } else {
            lua_error(L, "failure initializing lua object type");
        }
        PyObject *luam, *mainm, *maind;
#if PY_MAJOR_VERSION >= 3
        wchar_t *argv[] = {L"<lua_bootstrap>", 0};
#else
        char *argv[] = {"<lua_bootstrap>", 0};
#endif
        Py_SetProgramName(argv[0]);
        Py_SetPythonHome(python_home);
        Py_InitializeEx(0);
        PySys_SetArgv(1, argv);
        /* Import 'lua' automatically. */
        luam = PyImport_ImportModule("lua_bootstrap");
        if (!luam) {
            lua_error(L, "Can't import lua_bootstrap module");
        } else {
            mainm = PyImport_AddModule("__main__");
            if (!mainm) {
                lua_error(L, "Can't get __main__ module");
            } else {
                maind = PyModule_GetDict(mainm);
                PyDict_SetItemString(maind, "lua_bootstrap", luam);
                Py_DECREF(luam);
            }
        }
    }
}
开发者ID:alexsilva,项目名称:lunatic-python,代码行数:36,代码来源:pythoninlua.c


示例3: argv_ptrs

void PySetup::set_argv(const std::vector<std::wstring>& argv)
{
	std::vector<const wchar_t*> argv_ptrs(argv.size());
	std::transform(argv.begin(), argv.end(), argv_ptrs.begin(), [](const std::wstring& s) { return s.c_str(); } );

	PySys_SetArgv(argv_ptrs.size(), const_cast<wchar_t**>(argv_ptrs.data()));
}
开发者ID:pezcode,项目名称:Pyllow,代码行数:7,代码来源:py_setup.cpp


示例4: main

int main(int argc, char **argv)
{
#if (COW_MPI)
  {
    int rank;
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    if (rank != 0) freopen("/dev/null", "w", stdout);
    printf("was compiled with MPI support\n");
  }
#endif
  Py_Initialize();
  PySys_SetArgv(argc, argv);
  Py_SetProgramName("/Users/jzrake/Work/cow/cowpy");
  init_cow();

  if (argc > 1) {
    FILE *fp = fopen(argv[1], "r");
    if (fp) {
      PyRun_SimpleFileExFlags(fp, argv[1], 1, NULL);
      fclose(fp);
    }
    else {
      printf("No such file %s\n", argv[1]);
    }
  }

  Py_Finalize();
  printf("finished...\n");
#if (COW_MPI)
  MPI_Finalize();
#endif
  return 0;
}
开发者ID:darien0,项目名称:cow,代码行数:34,代码来源:cowpy.c


示例5: rpmpythonNew

rpmpython rpmpythonNew(char ** av, uint32_t flags)
{
    static char * _av[] = { "rpmpython", NULL };
#if defined(WITH_PYTHONEMBED)
    int initialize = (!(flags & 0x80000000) || _rpmpythonI == NULL);
#endif
    rpmpython python = (flags & 0x80000000)
	? rpmpythonI() : rpmpythonGetPool(_rpmpythonPool);

if (_rpmpython_debug)
fprintf(stderr, "==> %s(%p, %d) python %p\n", __FUNCTION__, av, flags, python);

    if (av == NULL) av = _av;

#if defined(WITH_PYTHONEMBED)
    if (!Py_IsInitialized()) {
	Py_SetProgramName((char *)_av[0]);
	Py_Initialize();
    }
    if (PycStringIO == NULL)
	PycStringIO = PyCObject_Import("cStringIO", "cStringIO_CAPI");

    if (initialize) {
	int ac = argvCount((ARGV_t)av);
	(void) PySys_SetArgv(ac, (char **)av);
	(void) rpmpythonRun(python, rpmpythonInitStringIO, NULL);
    }
#endif

    return rpmpythonLink(python);
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:31,代码来源:rpmpython.c


示例6: main

int main(int argc, char *argv[]) {
  // Set the python interpreter.
  setup_python(argc, argv);

  std::string filepath(argv[0]);

  // Get the path to the helper script.
  std::string helper_path;
  size_t path_end = filepath.find_last_of('\\');
  if (path_end != std::string::npos)
    helper_path = filepath.substr(0, path_end + 1);

  helper_path += "wbadminhelper.py";

  // Configures the execution of the script to take the same
  // parameters as this helper tool.
  Py_SetProgramName(argv[0]);

  PySys_SetArgv(argc, argv);

  // Executes the helper script.
  PyObject *pFileObject = PyFile_FromString(const_cast<char *>(helper_path.c_str()), "r");

  PyRun_SimpleFileEx(PyFile_AsFile(pFileObject), "wbadminhelper.py", 1);

  finalize_python();

  return 0;
}
开发者ID:pk-codebox-evo,项目名称:mysql-workbench,代码行数:29,代码来源:admin_helper.cpp


示例7: main

int main()
{
	Py_Initialize();
	PySys_SetArgv(SIZEOF_STATIC_ARRAY(pythonArgv), pythonArgv);
	PyRun_SimpleStringFlags(pythonScript, NULL);
	Py_Finalize();
	return 0;
}
开发者ID:nixxcode,项目名称:nixxcodemisc,代码行数:8,代码来源:pyhost.c


示例8: LMF_PyInitialise

 bool LMF_PyInitialise(int argc, char* argv[]){
	bool returnb = false;
	if (LMF_PyInitialise()){
		PySys_SetArgv(argc, argv);
		returnb = true;
	}
	return returnb;
}
开发者ID:lukemonaghan,项目名称:YR01_04_OpenGLFramework,代码行数:8,代码来源:LukeMonaghanFrameworkPython.cpp


示例9: luaopen_python

LUA_API int luaopen_python(lua_State *L)
{
    int rc;

    /* Register module */
    luaL_register(L, "python", py_lib);

    /* Register python object metatable */
    luaL_newmetatable(L, POBJECT);
    luaL_register(L, NULL, py_object_lib);
    lua_pop(L, 1);

    /* Initialize Lua state in Python territory */
    if (!LuaState) LuaState = L;

    /* Initialize Python interpreter */
    if (!Py_IsInitialized()) {
        PyObject *luam, *mainm, *maind;
#if PY_MAJOR_VERSION >= 3
        wchar_t *argv[] = {L"<lua>", 0};
#else
        char *argv[] = {"<lua>", 0};
#endif
        Py_SetProgramName(argv[0]);
        PyImport_AppendInittab("lua", PyInit_lua);
        Py_Initialize();
        PySys_SetArgv(1, argv);
        /* Import 'lua' automatically. */
        luam = PyImport_ImportModule("lua");
        if (!luam) {
            luaL_error(L, "Can't import lua module");
        } else {
            mainm = PyImport_AddModule("__main__");
            if (!mainm) {
                luaL_error(L, "Can't get __main__ module");
            } else {
                maind = PyModule_GetDict(mainm);
                PyDict_SetItemString(maind, "lua", luam);
                Py_DECREF(luam);
            }
        }
    }

    /* Register 'none' */
    lua_pushliteral(L, "Py_None");
    rc = py_convert_custom(L, Py_None, 0);
    if (rc) {
        lua_pushliteral(L, "none");
        lua_pushvalue(L, -2);
        lua_rawset(L, -5); /* python.none */
        lua_rawset(L, LUA_REGISTRYINDEX); /* registry.Py_None */
    } else {
        lua_pop(L, 1);
        luaL_error(L, "failed to convert none object");
    }

    return 0;
}
开发者ID:10to8,项目名称:lunatic-python,代码行数:58,代码来源:pythoninlua.c


示例10: Py_SetProgramName

bool reservoirHandler::callReservoir(string fPython)
{
    //launch Xavier reservoir
    //string command = "cd " + pythonPath + " && python " + fPython;
    //bool bsys = system(command.c_str());
    //cout << "cd " << pythonPath << " && python " << fPython << endl;
    //return bsys;


    cout << "fPython : " << fPython << endl;
    FILE* file;
    int argc;
    char * argv[3];

    argc = 3;
    if (sCurrentActivity == "understanding")
    {
      argv[0] = "/mnt/data/Data/BuildLinux/Robot/RAD/src/iCub_language/action_performer.py";
      argv[1] = "/home/anne/.local/share/yarp/contexts/reservoirHandler/conf/AP_input_S.txt";
      Py_SetProgramName(argv[0]);
      Py_Initialize();
      PySys_SetArgv(argc, argv);
      file = fopen("/mnt/data/Data/BuildLinux/Robot/RAD/src/iCub_language/action_performer.py","r");

      PyRun_SimpleFile(file, "/mnt/data/Data/BuildLinux/Robot/RAD/src/iCub_language/action_performer.py");
    }
    else
    {
        argv[0] = "/mnt/data/Data/BuildLinux/Robot/RAD/src/iCub_language/spatial_relation.py";
        argv[1] = "/home/anne/.local/share/yarp/contexts/reservoirHandler/conf/SR_input_M.txt";
        Py_SetProgramName(argv[0]);
        Py_Initialize();
        PySys_SetArgv(argc, argv);
        file = fopen("/mnt/data/Data/BuildLinux/Robot/RAD/src/iCub_language/spatial_relation.py","r");

        PyRun_SimpleFile(file, "/mnt/data/Data/BuildLinux/Robot/RAD/src/iCub_language/spatial_relation.py");
    }


    //return Py_Finalize();
    return true;

}
开发者ID:traversaro,项目名称:wysiwyd,代码行数:43,代码来源:reservoirHandler.cpp


示例11: show

void show(int argc, char* argv[])
{
  Py_Initialize();
  PySys_SetArgv(argc, argv);
  PyRun_SimpleString( "import Tkinter" );
  PyRun_SimpleString( "root = Tkinter.Tk()" );
  PyRun_SimpleString( "root.mainloop()" );
  Py_Finalize();

}
开发者ID:bonly,项目名称:exercise,代码行数:10,代码来源:20090720_tkinter.cpp


示例12: text

int CPython::ExecFile(const std::vector<std::wstring> &argv, std::wstring &err, HANDLE hfile)
{
	int id = 0; FILE *pfile = nullptr; DWORD count = 0; 
	PyObject *poldout, *polderr, *pnewout, *pnewerr; 
	if (argv.size() <= 0) { 
		err = text("No python script file found"); return 1; 
	} 
	if (DuplicateHandle (
		GetCurrentProcess(), hfile, GetCurrentProcess(), &hfile, 
		0, false, DUPLICATE_SAME_ACCESS
	)) {
		id = open_osfhandle((intptr_t)hfile, _O_WRONLY); 
		pfile = fdopen(id,"w"); setvbuf(pfile,nullptr,_IONBF,1024);
		poldout = PySys_GetObject("stdout"); 
		polderr = PySys_GetObject("stderr");
		pnewout = PyFile_FromFile(pfile, "logger", "w", nullptr);
		pnewerr = PyFile_FromFile(pfile, "logger", "w", nullptr);
		PySys_SetObject("stdout", pnewout);
		PySys_SetObject("stderr", pnewerr);
	} else poldout = polderr = pnewout = pnewerr = nullptr;

	// Pack up the arguments ..
	std::vector<char*> args; int irslt = 0; 
	std::vector<std::wstring>::const_iterator itr, eitr; 
	std::wstring_convert<std::codecvt_utf8_utf16<wchar>> cvt; 
	itr = argv.cbegin(); eitr = argv.cend(); 
	for (size_t len = 0; itr != eitr; ++itr) { 
		// Allocate buffer each time, not good ..
		std::string str = cvt.to_bytes(*itr); 
		len = str.length(); char *arg = new char[len+1]; 
		strncpy_s(arg,len+1,str.data(),len); arg[len] = '\0'; 
		args.push_back(arg);
	}

	PySys_SetArgv(args.size(), args.data());	// pass args .
	PyObject *pobj = PyFile_FromString(args.at(0), "r");
	if (pobj == nullptr) {
		err = text("Internal error that PyFile_FromString fail"); 
		irslt = -1;
	} else {
		PyRun_SimpleFileEx(PyFile_AsFile(pobj), args.at(0), true);
		err = text("Execute python script file successfully .."); 
		irslt = 00;
	}

	// Free resource ...
	std::vector<char*>::iterator sitr, seitr;
	sitr = args.begin(); seitr = args.end();
	for (sitr; sitr != seitr; ++sitr) { if (*sitr) delete [] *sitr; }
	args.clear();

	if (pnewout != nullptr) PySys_SetObject("stdout", poldout);
	if (pnewerr != nullptr) PySys_SetObject("stderr", polderr);
	if (pfile != nullptr) fclose(pfile); return irslt;
}
开发者ID:zzydog,项目名称:OllyDog,代码行数:55,代码来源:Python.cpp


示例13: Py_FrozenMain

int
Py_FrozenMain(int argc, char **argv)
{
    char *p;
    int n, sts;
    int inspect = 0;
    int unbuffered = 0;

    Py_FrozenFlag = 1; /* Suppress errors from getpath.c */

    if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
        inspect = 1;
    if ((p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
        unbuffered = 1;

    if (unbuffered) {
        setbuf(stdin, (char *)NULL);
        setbuf(stdout, (char *)NULL);
        setbuf(stderr, (char *)NULL);
    }

#ifdef MS_WINDOWS
    PyInitFrozenExtensions();
#endif /* MS_WINDOWS */
    Py_SetProgramName(argv[0]);
    Py_Initialize();
#ifdef MS_WINDOWS
    PyWinFreeze_ExeInit();
#endif

    if (Py_VerboseFlag)
        fprintf(stderr, "Python %s\n%s\n",
            Py_GetVersion(), Py_GetCopyright());

    PySys_SetArgv(argc, argv);

    n = PyImport_ImportFrozenModule("__main__");
    if (n == 0)
        Py_FatalError("__main__ not frozen");
    if (n < 0) {
        PyErr_Print();
        sts = 1;
    }
    else
        sts = 0;

    if (inspect && isatty((int)fileno(stdin)))
        sts = PyRun_AnyFile(stdin, "<stdin>") != 0;

#ifdef MS_WINDOWS
    PyWinFreeze_ExeTerm();
#endif
    Py_Finalize();
    return sts;
}
开发者ID:0xcc,项目名称:python-read,代码行数:55,代码来源:frozenmain.c


示例14: _PythonVM_init

static void _PythonVM_init(JNIEnv *vm_env, jobject self,
                           jstring programName, jobjectArray args)
{
    const char *str = vm_env->GetStringUTFChars(programName, JNI_FALSE);
#ifdef linux
    char buf[32];

    // load python runtime for other .so modules to link (such as _time.so)
    sprintf(buf, "libpython%d.%d.so", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    dlopen(buf, RTLD_NOW | RTLD_GLOBAL);
#endif

    Py_SetProgramName((char *) str);

    PyEval_InitThreads();
    Py_Initialize();

    if (args)
    {
        int argc = vm_env->GetArrayLength(args);
        char **argv = (char **) calloc(argc + 1, sizeof(char *));

        argv[0] = (char *) str;
        for (int i = 0; i < argc; i++) {
            jstring arg = (jstring) vm_env->GetObjectArrayElement(args, i);
            argv[i + 1] = (char *) vm_env->GetStringUTFChars(arg, JNI_FALSE);
        }

        PySys_SetArgv(argc + 1, argv);

        for (int i = 0; i < argc; i++) {
            jstring arg = (jstring) vm_env->GetObjectArrayElement(args, i);
            vm_env->ReleaseStringUTFChars(arg, argv[i + 1]);
        }
        free(argv);
    }
    else
        PySys_SetArgv(1, (char **) &str);

    vm_env->ReleaseStringUTFChars(programName, str);
    PyEval_ReleaseLock();
}
开发者ID:ahua,项目名称:java,代码行数:42,代码来源:jcc.cpp


示例15: initialize_interpreter

void initialize_interpreter(const char **ENV_VARS, const char **ENV_VAR_VALS,
        char *PROGRAM, const char *MODULE, const char *FUNCTION, const char *PYVER, int IS_GUI,
        const char* exe_path, const char *rpath, int argc, const char **argv) {
    PyObject *pargv, *v;
    int i;
    Py_OptimizeFlag = 2;
    Py_NoSiteFlag = 1;
    Py_DontWriteBytecodeFlag = 1;
    Py_IgnoreEnvironmentFlag = 1;
    Py_NoUserSiteDirectory = 1;
    Py_HashRandomizationFlag = 1;

    //Py_VerboseFlag = 1;
    //Py_DebugFlag = 1;
    
    Py_SetProgramName(PROGRAM);

    char pyhome[1000];
    snprintf(pyhome, 1000, "%s/Python", rpath);
    Py_SetPythonHome(pyhome);

    set_env_vars(ENV_VARS, ENV_VAR_VALS, exe_path);

    //printf("Path before Py_Initialize(): %s\r\n\n", Py_GetPath());
    Py_Initialize();

    char *dummy_argv[1] = {""};
    PySys_SetArgv(1, dummy_argv);
    //printf("Path after Py_Initialize(): %s\r\n\n", Py_GetPath());
    char path[3000];
    snprintf(path, 3000, "%s/lib/python%s:%s/lib/python%s/lib-dynload:%s/site-packages", pyhome, PYVER, pyhome, PYVER, pyhome);

    PySys_SetPath(path);
    //printf("Path set by me: %s\r\n\n", path);

    PySys_SetObject("calibre_basename", PyBytes_FromString(PROGRAM));
    PySys_SetObject("calibre_module", PyBytes_FromString(MODULE));
    PySys_SetObject("calibre_function", PyBytes_FromString(FUNCTION));
    PySys_SetObject("calibre_is_gui_app", ((IS_GUI) ? Py_True : Py_False));
    PySys_SetObject("resourcepath", PyBytes_FromString(rpath));
    snprintf(path, 3000, "%s/site-packages", pyhome);
    PySys_SetObject("site_packages", PyBytes_FromString(pyhome));


    pargv = PyList_New(argc);
    if (pargv == NULL) exit(report_error(ERR_OOM));
    for (i = 0; i < argc; i++) {
        v = PyBytes_FromString(argv[i]);
        if (v == NULL) exit(report_error(ERR_OOM));
        PyList_SetItem(pargv, i, v);
    }
    PySys_SetObject("argv", pargv);

}
开发者ID:AEliu,项目名称:calibre,代码行数:54,代码来源:util.c


示例16: pModule

Oracle::Oracle(int argc, char* argv[], const std::string& model_name) : pModule(NULL){
	PySys_SetArgv(argc, argv);
	PyRun_SimpleString("import sys");
	PyRun_SimpleString("sys.path.append('./')");

	pModule = PyImport_ImportModule(model_name.c_str());
	if (!pModule){
		PyErr_Print();
		std::cout << "Oracle::Oracle() ERROR : get module failed!" << std::endl;
		assert(0);
	}
}
开发者ID:welkincrowns,项目名称:AlphaGo-UnlimitedGomokuWorks,代码行数:12,代码来源:Oracle.cpp


示例17: txt_test

void txt_test(int argc, char* argv[])
{
  Py_Initialize();
  PySys_SetArgv(argc, argv);
  PyRun_SimpleString( "from Tkinter import *" );
  PyRun_SimpleString( "root=Tk()" );
  PyRun_SimpleString( "w = Label(root,text = 'hello world')");
  PyRun_SimpleString( "w.pack()" );
  PyRun_SimpleString( "root.mainloop()" );

  Py_Finalize();
}
开发者ID:bonly,项目名称:exercise,代码行数:12,代码来源:20090720_tkinter.cpp


示例18: pythonExchangeValuesNoModelica

void pythonExchangeValuesNoModelica(const char * moduleName,
                          const char * functionName,
                          const double * dblValWri, size_t nDblWri,
                          double * dblValRea, size_t nDblRea,
                          const int * intValWri, size_t nIntWri,
                          int * intValRea, size_t nIntRea,
                          const char ** strValWri, size_t nStrWri,
                          void (*ModelicaFormatError)(const char *string,...))
{
  PyObject *pName, *pModule, *pFunc;
  PyObject *pArgsDbl, *pArgsInt, *pArgsStr;
  PyObject *pArgs, *pValue;
  Py_ssize_t pIndVal;
  PyObject *pItemDbl, *pItemInt;
  char* arg="";
  Py_ssize_t i;
  Py_ssize_t iArg = 0;
  Py_ssize_t nArg = 0;
  Py_ssize_t iRet = 0;
  Py_ssize_t nRet = 0;
  ////////////////////////////////////////////////////////////////////////////
  // Initialize Python interpreter
  Py_Initialize();
  // Set the entries for sys.argv.
  // This is required if a script uses sys.argv, such as bacpypes.
  // See also http://stackoverflow.com/questions/19381441/python-modelica-connection-fails-due-to-import-error
  PySys_SetArgv(0, &arg);

  ////////////////////////////////////////////////////////////////////////////
  // Load Python module
  pName = PyString_FromString(moduleName);
  if (!pName) {
    (*ModelicaFormatError)("Failed to convert moduleName '%s' to Python object.\n", moduleName);
  }

  pModule = PyImport_Import(pName);
  Py_DECREF(pName);
  if (!pModule) {
    //    PyErr_Print();
    PyObject *pValue, *pType, *pTraceBack;
    PyErr_Fetch(&pType, &pValue, &pTraceBack);
    if (pType != NULL)
      Py_DECREF(pType);
    if (pTraceBack != NULL)
      Py_DECREF(pTraceBack);
    // Py_Finalize(); // removed, see note at other Py_Finalize() statement
    (*ModelicaFormatError)("Failed to load \"%s\".\n\
This may occur if you did not set the PYTHONPATH environment variable\n\
or if the Python module contains a syntax error.\n\
The error message is \"%s\"",
                        moduleName,
                        PyString_AsString(PyObject_Repr(pValue)));
  }
开发者ID:SavaniYe,项目名称:modelica-buildings,代码行数:53,代码来源:pythonInterpreter.c


示例19: main

int main( int argc, char* argv[] ) {

    /** Must call pre_init before python initializes */
    PyQBind::pre_init();

    /** Initialize Python using either chars (Python 2) or whcars (Python 3)*/
#if PY_MAJOR_VERSION < 3
    Py_SetProgramName(argv[0]);
    Py_Initialize();
    PySys_SetArgv(1, argv);
#else
    wchar_t *wprogname = new wchar_t[255];
    mbstowcs(wprogname, argv[0], 255);
    Py_SetProgramName(wprogname);
    Py_Initialize();
    PySys_SetArgv(1, &wprogname);
#endif

    /** If we expect to need python threads, we can initialize them now */
    //PyEval_InitThreads();

    /** Finish PyQBind initialization */
    PyQBind::post_init();

    /** Now we can create our application and export it */
    QCoreApplication q(argc, argv);
    PyQBind::exportObject( &q );
    PyQBind::addToGlobalNamespace( &q, "app" );

    try {
        boost::python::object main = boost::python::import("__main__");
        boost::python::object dict = main.attr("__dict__");
        boost::python::exec("print dir(app)", dict, dict);
        boost::python::exec("print app.applicationName", dict, dict);
    } catch( boost::python::error_already_set& ) {
        PyErr_Print();
    }

}
开发者ID:sjackso,项目名称:pyqbind,代码行数:39,代码来源:main.cpp


示例20: python_start_script

/*
 * Start trace script
 */
static int python_start_script(const char *script, int argc, const char **argv)
{
	const char **command_line;
	char buf[PATH_MAX];
	int i, err = 0;
	FILE *fp;

	command_line = malloc((argc + 1) * sizeof(const char *));
	command_line[0] = script;
	for (i = 1; i < argc + 1; i++)
		command_line[i] = argv[i - 1];

	Py_Initialize();

	initperf_trace_context();

	PySys_SetArgv(argc + 1, (char **)command_line);

	fp = fopen(script, "r");
	if (!fp) {
		sprintf(buf, "Can't open python script \"%s\"", script);
		perror(buf);
		err = -1;
		goto error;
	}

	err = PyRun_SimpleFile(fp, script);
	if (err) {
		fprintf(stderr, "Error running python script %s\n", script);
		goto error;
	}

	err = run_start_sub();
	if (err) {
		fprintf(stderr, "Error starting python script %s\n", script);
		goto error;
	}

	free(command_line);
	fprintf(stderr, "perf trace started with Python script %s\n\n",
		script);

	return err;
error:
	Py_Finalize();
	free(command_line);

	return err;
}
开发者ID:KaZoom,项目名称:buildroot-linux-kernel-m3,代码行数:52,代码来源:trace-event-python.c



注:本文中的PySys_SetArgv函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PySys_SetObject函数代码示例发布时间:2022-05-30
下一篇:
C++ PySys_GetObject函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap