ironpython

which argtypes for NetShareAdd

最后都变了- 提交于 2019-12-07 19:27:25
The win32 function NetShareDel takes three arguments, LPCWSTR LPCWSTR and DWORD. So I use the following list for argtypes: C.windll.Netapi32.NetShareDel.argtypes = [LPCWSTR, LPCWSTR, c_int] C.windll.Netapi32.NetShareDel.restype = c_int C.windll.Netapi32.NetShareDel(server, shareName, 0) That works fine, but I can't figure out what to use for NetShareAdd, especialle the byte array for NET_SHARE_INFO struct and the last byref(c_int) argument. Here's the code: def Share(server, shareName, dir): info = SHARE_INFO_2() STYPE_DISKTREE = 0 info.shi2_netname = shareName info.shi2_path = dir info.shi2

Distributing IronPython applications

扶醉桌前 提交于 2019-12-07 18:10:45
问题 I'm thinking of developing a small application using IronPython, however I want to distribute my app to non-techies and so ideally I want to be able to give them a standard shortcut to my application along with the instructions that they need to install IronPython first. If possible I even want my shortcut to detect if IronPython is not present and display a suitable warning if this is the case (which I can do using a simple VbScript) The trouble is that IronPython doesn't place itself in the

Using `dynamic` keyword in C# doesn't compile

元气小坏坏 提交于 2019-12-07 14:03:08
问题 I'm trying to compile a piece of C# code that contains the dynamic keyword. (I need this keyword for using ironpython.) However, it doesn't compile, complaining that error CS1980: Dynamic keyword requires `System.Runtime.CompilerServices.DynamicAttribute' to be defined. Are you missing System.Core.dll assembly reference? The compiler I'm using is Mono JIT compiler version 2.10.8.1 . I don't have System.Runtime.CompilerServices.DynamicAttribute in the list of possible references. How can I

Accessing .Net enums in Iron python

半城伤御伤魂 提交于 2019-12-07 12:59:42
问题 I'm trying to access .Net(C#) enums in IronPython, lets say we have Test.dll // Contains Several Enums enum TestType{..} enum TestQuality{..} .... .... enum TestStatus{..} //Similarly Multiple functions public void StartTest(TestType testType, TestQuality testQuality){..} .... .... public TestStatus GetTestStatus(){..} and now if I try to call the above functions, I need to choose the appropriate enum parameters and so far what I did is this, Iron Python [vs2012] import clr clr.AddReference(

Pass a C# Class Object to a Python file

筅森魡賤 提交于 2019-12-07 12:03:17
问题 Okay... I'm trying to pass an Object which I declare in C# to a Python file with IronPython. So this is what I was thinking off: C# class: public class ParamObj { private string Obj_String; private int Obj_Int; public ParamObj(string lObjS, string lObjI) { Obj_String = lObjS; Obj_Int = lObjI; } public string getString() { return Obj_String; } public int getInt() { return Obj_Int; } public setString(string lStr) { Obj_String = lStr; } public setInt(int lInt) { Obj_Int = lInt; } } So i have my

Performance of Mass-Evaluating Expressions in IronPython

这一生的挚爱 提交于 2019-12-07 11:14:28
问题 In an C#-4.0 application, I have a Dictionary of strongly typed ILists having the same length - a dynamically strongly typed column based table. I want the user to provide one or more (python-)expressions based on the available columns that will be aggregated over all rows. In a static context it would be: IDictionary<string, IList> table; // ... IList<int> a = table["a"] as IList<int>; IList<int> b = table["b"] as IList<int>; double sum = 0; for (int i = 0; i < n; i++) sum += (double)a[i] /

IronPython - JSON choices

江枫思渺然 提交于 2019-12-07 10:55:11
问题 What is the best way to deal with JSON in IronPython 2.0.1. The native Python "standard library" json looks to be not implemented yet. If I wanted to use the Newtonsoft Json.NET library how do I do this? I could add the assembly to the GAC, but what are my other choices? 回答1: This link provides an overview of the ways to add refernces to .Net dlls with IronPython: Haibo Luo's weblog : IronPython: clr.AddReference So, for example, if you'd likle to avoid placing the Json.NET library in the GAC

Importing mgcv fails because Rlapack.dll cannot be found

筅森魡賤 提交于 2019-12-07 09:55:15
问题 I want to link to the R statistical package in IronPython by using the R.NET library. It's been working fine, but now I need to use R's mgcv library. Importing mgcv fails (import is done with the command rdn.r.EagerEvaluate("library(mgcv)") , where rdn is an IronPython object that wraps the R.NET library). When the import fails, Windows opens a dialog box that says: "The program can't start because Rlapack.dll is missing from your computer. Try reinstalling the program to fix this problem."

execute a python script in C#

℡╲_俬逩灬. 提交于 2019-12-07 07:51:22
问题 I am trying to execute a python code in C#. Normally it should be done using IronPython and after installing PTVS (I'm using VS 2010). var pyEngine = Python.CreateEngine(); var pyScope = pyEngine.CreateScope(); try { pyEngine.ExecuteFile("plot.py", pyScope); } catch (Exception ex) { Console.WriteLine("There is a problem in your Python code: " + ex.Message); } The problem is that it seems that IronPython doesn't recognize some libraries like numpy, pylab or matplotlib. I took a look a little

C# / IronPython Interop and the “float” data type

倖福魔咒の 提交于 2019-12-07 05:55:16
问题 Working on a project that uses some IronPython scripts to as plug-ins, that utilize functionality coded in C#. In one of my C# classes, I have a property that is of type: Dictionary<int, float> I set the value of that property from the IronPython code, like this: mc = MyClass() mc.ValueDictionary = Dictionary[int, float]({1:0.0, 2:0.012, 3:0.024}) However, when this bit of code is run, it throws the following exception: Microsoft.Scripting.ArgumentTypeException was unhandled by user code