ironpython

how to sort list of FileInfo in IronPython

落花浮王杯 提交于 2019-12-24 10:56:18
问题 Given a list of FileInfo objects, how do I sort them by date? Specifically I want to sort them by CreationTime in descending order. 回答1: The Pythonic way of doing this would be: fileInfos = list(DirectoryInfo(path).GetFiles()) fileInfos.sort(key=lambda f: f.CreationTime, reverse=True) The list sort method takes a key function that is used to get the sort key for each item. 回答2: DirectoryInfo.GetFiles() returns an array of FileInfo objects. I created a generic list to hold the FileInfo objs,

Determining when a process has finalized initialization

爷,独闯天下 提交于 2019-12-24 10:40:53
问题 I'm building an IronPython module that initializes an instance of AutoCAD and I need to return 1 to the module calling it after AutoCAD has finished initializing, entered its message loop and is in a stable (not loading dependencies/anything) state. I've tried using System.Diagnostics.Process.WaitForInputIdle() with no luck. Here's what I have so far: import System.Diagnostics as sysdiag def start_autocad(self): print("\"C:\\Program Files\\Autodesk\\Autodesk AutoCAD Civil 3D 2014\\acad.exe\"

is sqlite caching the results of the query for optimization?

99封情书 提交于 2019-12-24 09:08:09
问题 I've noticed this behavior in sqlite. When I re-use the cursor object, the working set memory in the task manager keeps increasing until my program throws a out of memory exception. I refactored the code such that each time I query I open a connection to the sqlite file query what I want and then close the connection. The latter somehow seems to be not so memory-hungry. It doesn't increase beyond a certain point. All I do with my sqlite db is simple select (which contains two aggregations)

IronPython: double keyword not recognised?

▼魔方 西西 提交于 2019-12-24 07:41:11
问题 In IronPython I can do: Console.WriteLine(int.MaxValue) where int is not a variable but rather System.Int32. I get back: Max of int: 2137483647 Yet if I try something similar for double (System.Double), I get: NameError: name 'double' is not defined. Similary for char (System.Char). How come? 回答1: See Mapping between Python builtin types and .NET types int is not a keyword, it is a builtin type in Python, and IronPython implements it using System.Int32 . Similarly float is implemented using

Reference a library in IronPython using Visual Studio

让人想犯罪 __ 提交于 2019-12-24 06:33:09
问题 I'm new at Python, and I'm trying to write my first Python application on Visual Studio CE 2015 using IronPython. I finally managed to execute the most basic .NET-compatible code importing the clr module (which comes with the whole IronPython package) but, since my goal is writing an application that reads from a USB scale following this blog post, I'm stuck at trying to import the usb module. I downloaded and installed both pyUSB and libusb, so I thought I had to simply add the reference in

Reference a library in IronPython using Visual Studio

限于喜欢 提交于 2019-12-24 06:32:42
问题 I'm new at Python, and I'm trying to write my first Python application on Visual Studio CE 2015 using IronPython. I finally managed to execute the most basic .NET-compatible code importing the clr module (which comes with the whole IronPython package) but, since my goal is writing an application that reads from a USB scale following this blog post, I'm stuck at trying to import the usb module. I downloaded and installed both pyUSB and libusb, so I thought I had to simply add the reference in

numpy 64bit support in PTVS and numpy System.Int64 casting

倖福魔咒の 提交于 2019-12-24 06:25:17
问题 I am trying to write some code with IronPython and numpy that calls a .NET assembly. Version info: numpy-2.0.0-1 scipy-1.0.0-2 IronPython 2.7.1 I installed scipy and numpy according to the instructions given here: http://www.enthought.com/repo/.iron/ When I try to run with ipy64.exe I get the following: Failed while initializing NpyCoreApi: BadImageFormatException:An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000 B) NumpyDotNet stack trace: at

KitchenPC and Ironpython

冷暖自知 提交于 2019-12-24 04:03:18
问题 I am attempting to work with KitchenPC using IronPython. I am working with the Database Provisioning example here: http://blog.kitchenpc.com/2014/02/11/kitchenpc-database-provisioning-101/ I am successfully referencing and importing all the dlls and their namespaces: import clr clr.AddReference("System") from System import * from System.Reflection import * from System.Reflection import Assembly L4N = Assembly.LoadFrom('C://KitchenPC//DLL//log4net.dll') clr.AddReference(L4N) NU= Assembly

KitchenPC and Ironpython

青春壹個敷衍的年華 提交于 2019-12-24 04:03:08
问题 I am attempting to work with KitchenPC using IronPython. I am working with the Database Provisioning example here: http://blog.kitchenpc.com/2014/02/11/kitchenpc-database-provisioning-101/ I am successfully referencing and importing all the dlls and their namespaces: import clr clr.AddReference("System") from System import * from System.Reflection import * from System.Reflection import Assembly L4N = Assembly.LoadFrom('C://KitchenPC//DLL//log4net.dll') clr.AddReference(L4N) NU= Assembly

Is it possible to use IronPython to return the path of the current *.dxp project as a string?

自作多情 提交于 2019-12-24 03:48:08
问题 This should (I think) have a simple answer, assuming that an answer exists. Is it possible to use IronPython to return the path of the current *.dxp project as a string? I use something similar in VBA frequently, and it's become pretty useful. I've tried looking, but I have a hard time working through TIBCO's Python material. :\ 回答1: The script below should help you with this. There are 2 ways to get the path of the analysis depending on if you are using a library file or a .dxp. Your