ironpython

Calling IronPython object from C# with mono

99封情书 提交于 2019-12-31 01:44:08
问题 I have the following IronPython code. class Hello: def __init__(self): pass def add(self, x, y): return (x+y) I need to call this from C#, and I came up with the following code. using System; using IronPython.Hosting; using IronPython.Runtime; using IronPython; using Microsoft.Scripting.Hosting; using Microsoft.Scripting; class Hello { public static void Main() { ScriptEngine engine = Python.CreateEngine(); ScriptSource script = engine.CreateScriptFromSourceFile("myPythonScript.py");

Using SQL Alchemy and pyodbc with IronPython 2.6.1

元气小坏坏 提交于 2019-12-30 05:27:06
问题 I'm using IronPython and the clr module to retrieve SQL Server information via SMO. I'd like to retrieve/store this data in a SQL Server database using SQL Alchemy, but am having some trouble loading the pyodbc module. Here's the setup: IronPython 2.6.1 (installed at D:\Program Files\IronPython) CPython 2.6.5 (installed at D:\Python26) SQL Alchemy 0.6.1 (installed at D:\Python26\Lib\site-packages\sqlalchemy) pyodbc 2.1.7 (installed at D:\Python26\Lib\site-packages) I have these entries in the

Installing Python Packages - IronPython

半世苍凉 提交于 2019-12-30 04:51:04
问题 I'd like to add the PRAW package to an IronPython solution in VS however it's proving to be a pain in the butt. Here are steps I'm taking right-click on IronPython Environment, select install python package. type in "Praw" using pip I get a prompt telling me that pip needs to get installed. I then see the following: Installing 'pip' package manager. Downloading distribute from https://go.microsoft.com/fwlink/?LinkID=306663 Installing from distribute-0.6.45 Before install bootstrap. Scanning

Extending C# .NET application - build a custom scripting language or not?

梦想与她 提交于 2019-12-30 03:05:10
问题 I need to build a scripting interface for my C# program that does system level testing of embedded firmware. My application contains libraries to fully interact with the devices. There are separate libraries for initiating actions, getting output and tracking success/failure. My application also has a GUI for managing multiple devices and assigning many scripts to be run. For the testers (non-programmers, but technical), I need to provide a scripting interface that will allow them to come up

Iron Python Error: expected <type 'bytes'> or bytearray, got <type 'str'> for Serial comm

梦想的初衷 提交于 2019-12-25 01:13:50
问题 Unable to understand this: When I run using python shell it works but doesn't: when invoked using Iron python. It throws above error C#: scriptEngine.ExecuteFile(path); var testFn = scriptScope.GetVariable("InputSelection"); var stream = new MemoryStream(); scriptEngine.Runtime.IO.SetOutput(stream, Encoding.Default); scriptEngine.Operations.Invoke(testFn); Python: def send_data(message,check): if message: ser.write(message.encode('utf-8')) time.sleep(2) response = ser.read(1024) def

IronPython hosting caching imported module?

大憨熊 提交于 2019-12-24 20:12:07
问题 I'm embedding IronPython in my application. Everything goes fine but I found that when I use CreateScriptSourceFromFile to execute a file, it seems that IronPython cached other imported module. For example I have another file as foo.py : foo = 'foo' And I use IronPython hosting API to execute bar.py : from foo import foo print foo If I make changes to bar.py then without exiting the host application I can see my changes made take effect. But if I edit foo.py then I have to reboot my

IronPython: Message: expected c_double, got c_double_Array_3

核能气质少年 提交于 2019-12-24 19:48:31
问题 I’m currently developing a script using the python script editor in Rhino. As I’m currently working in a Windows machine, the script editor uses IronPython as language. In the same script, I want to interact with an FE software (Straus7) which has a Python API. When doing so, I have experienced some problems as the ctypes module does not seem to work in IronPython the same way it does in regular Python . Especially, I’m finding problems when initializing arrays using the command: ctypes.c

Binding to a property of an object through object[property] rather than object.property

与世无争的帅哥 提交于 2019-12-24 19:12:58
问题 I've read through the WPF Data Binding Overview and I feel like this should be possible but I can't quite make the mental leap here. I know that if I set a binding's Path to foo , and set the Source to obj , then the binding will look at obj.foo . In other words, obj.__getattr__() will be accessed. All I want is to make it look at obj[foo] instead. I'm using Ironpython and in this case my obj class has an overridden __getitem__() that calls a member function and returns a value, which is why

How to draw chart using WPF and IronPython

半腔热情 提交于 2019-12-24 17:01:45
问题 I'm a french beginner dev and I need to draw charts using WPF and IronPython. I'm coding with MVS2010 and I didn't find any help on Google. Does anybody have an idea ? Something to help me ? Thanks all, Ben 回答1: Charting is difficult, and it's usually best to rely on a tried-and-true library like ChartFX and invest your time and energy into solving real business problems. If you have difficulty convincing your management to purchase the library, divide the cost by your weekly pay and think

“No module named fcntl” when py script run from c# but works from windows command line

蹲街弑〆低调 提交于 2019-12-24 13:06:36
问题 I am calling a python script that uses imaplib.py and get the "no module named fcntl" error. From searching I found that this module is only available in unix and so I wonder if the py script is confused about what os it is running under. Again, script works fine under windows run directly from the python directory. var engine = Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); var ops = engine.Operations; var script = engine.CreateScriptSourceFromFile("PyTest.py");