本文整理汇总了C#中IPythonInterpreterFactory.Run方法的典型用法代码示例。如果您正苦于以下问题:C# IPythonInterpreterFactory.Run方法的具体用法?C# IPythonInterpreterFactory.Run怎么用?C# IPythonInterpreterFactory.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPythonInterpreterFactory
的用法示例。
在下文中一共展示了IPythonInterpreterFactory.Run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateDbFile
private string GenerateDbFile(IPythonInterpreterFactory interpreter, string moduleName, string extensionModuleFilename, List<string> existingModules, string dbFile, FileStream fs) {
// we need to generate the DB file
dbFile = Path.Combine(ReferencesDatabasePath, moduleName + ".$project.idb");
int retryCount = 0;
while (File.Exists(dbFile)) {
dbFile = Path.Combine(ReferencesDatabasePath, moduleName + "." + ++retryCount + ".$project.idb");
}
using (var output = interpreter.Run(
PythonToolsInstallPath.GetFile("ExtensionScraper.py"),
"scrape",
"-", // do not use __import__
extensionModuleFilename, // extension module path
Path.ChangeExtension(dbFile, null) // output file path (minus .idb)
)) {
if (_cancel.CanBeCanceled) {
if (WaitHandle.WaitAny(new[] { _cancel.WaitHandle, output.WaitHandle }) != 1) {
// we were cancelled
return null;
}
} else {
output.Wait();
}
if (output.ExitCode == 0) {
// [FileName]|interpGuid|interpVersion|DateTimeStamp|[db_file.idb]
// save the new entry in the DB file
existingModules.Add(
String.Format("{0}|{1}|{2}|{3}|{4}",
extensionModuleFilename,
interpreter.Id,
interpreter.Configuration.Version,
new FileInfo(extensionModuleFilename).LastWriteTime.ToString("O"),
dbFile
)
);
fs.Seek(0, SeekOrigin.Begin);
fs.SetLength(0);
using (var sw = new StreamWriter(fs)) {
sw.Write(String.Join(Environment.NewLine, existingModules));
sw.Flush();
}
} else {
throw new CannotAnalyzeExtensionException(string.Join(Environment.NewLine, output.StandardErrorLines));
}
}
return dbFile;
}