| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,7 @@ | |||
| 37 | 37 | #include "utilities/shared_utils.h" | |
| 38 | 38 | #include "export_main.h" | |
| 39 | 39 | #include "modules/entities/entities_entity_wrap.h" | |
| 40 | + #include "icommandline.h" | ||
| 40 | 41 | ||
| 41 | 42 | BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(CBaseEntity) | |
| 42 | 43 | ||
@@ -112,6 +113,24 @@ bool CPythonManager::Initialize( void ) | |||
| 112 | 113 | ||
| 113 | 114 | // Print some information | |
| 114 | 115 | DevMsg(1, MSG_PREFIX "Python version %s initialized!\n", Py_GetVersion()); | |
| 116 | + | ||
| 117 | + // Set sys.argv and update sys.path | ||
| 118 | + DevMsg(1, MSG_PREFIX "Setting sys.argv...\n"); | ||
| 119 | + ICommandLine* pCommandLine = CommandLine(); | ||
| 120 | + | ||
| 121 | + int iParamCount = pCommandLine->ParmCount(); | ||
| 122 | + wchar_t** argv = new wchar_t*[iParamCount]; | ||
| 123 | + for (int i=0; i < iParamCount; i++) | ||
| 124 | + { | ||
| 125 | + const char* szParam = pCommandLine->GetParm(i); | ||
| 126 | + int iParamLength = strlen(szParam); | ||
| 127 | + | ||
| 128 | + wchar_t* wszParam = new wchar_t[iParamLength]; | ||
| 129 | + V_strtowcs(szParam, -1, wszParam, iParamLength+1); | ||
| 130 | + | ||
| 131 | + argv[i] = wszParam; | ||
| 132 | + } | ||
| 133 | + PySys_SetArgv(iParamCount, argv); | ||
| 115 | 134 | ||
| 116 | 135 | // Make sure sys is imported. | |
| 117 | 136 | PyRun_SimpleString("import sys"); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments