Re: [IronPython] IPY and multitasking
I'm prepare simple test for problem demonstration. http://files.roinet.net/DLRTest.zip Module utils imported 6-7 times on 2x Dual-Core Opteron 2216 machine, but method IronPythonHelper.CreateScript() called one time. On Core 2 Quad this problem has detected 4 times. On Core 2 Duo problem has not detected. In file out.txt console output with exceptions and logging information. Dino Viehland wrote: You're only using 1 ScriptEngine class? That should be fine based upon the code below but I just want to make sure I understand the scenario. Is citypay.utils being ran multiple times when you run the code in the multi-threaded scenario? If you have a console app you could put a print statement in utils.py to see if it's getting executed multiple times. If it's not a console app you could put some other logging into it. Executing Struct's definition multiple times might cause the exceptions you're seeing but I don't know why it would get executed multiple times. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] n-dimensional array
Hello everyone, I'm developing an application for my research project. I'm using IronPython as a scripting engine to allow easy data manipulation like Matlab. I require a high performance n-dimensional array class. Does anyone know of any .net library which provides a powerful n-dimensional array? I would like to do slicing operations on the array like in NumPy. (A[:2, :5] etc.) And also things like ones(.) zeros(.). I tried to use NumPy with Ironclad but im having some issues and would prefer if I could have a .net/ Ironpython ndarray library. Can you please recommend me any such library? Thanks Aravin ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] n-dimensional array
Aravin wrote: Hello everyone, I’m developing an application for my research project. I’m using IronPython as a scripting engine to allow easy data manipulation like Matlab. I require a high performance n-dimensional array class. Does anyone know of any .net library which provides a powerful n-dimensional array? I would like to do slicing operations on the array like in NumPy. (A[:2, :5] etc.) I doubt you will find a .NET library that supports slicing in the same way as numpy... You might try looking at Math.NET though: http://www.mathdotnet.com/About.aspx And also things like ones(…) zeros(…). I tried to use NumPy with Ironclad but im having some issues Have you reported those issues? All the best, Michael Foord and would prefer if I could have a .net/ Ironpython ndarray library. Can you please recommend me any such library? Thanks Aravin ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- http://www.ironpythoninaction.com/ ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] .NET attributes for methods
This looks very promising but I cannot make it work. I have changed product.py in DevHawk's example to: #from clrtypeold import ClrMetaclass import clrtype class Product(object): #__metaclass__ = ClrMetaclass __metaclass__ = clrtype.ClrClass _clrnamespace = DevHawk.IronPython.ClrTypeSeries #_clrproperties = { #name:str, #cost:float, #quantity:int, #} def __init__(self, name, cost, quantity): self.name = name self.cost = cost self.quantity = quantity def calc_total(self): return self.cost * self.quantity @property @clrtype.accepts() @clrtype.returns(str) def name(self): return self._name @name.setter @clrtype.accepts(str) @clrtype.returns() def name(self, value): self._name = value When I run it I don't see any items in the listbox. When I check the name, it is a property: py a.root.listbox1.Items[0] = Product object at 0x002B py a.root.listbox1.Items[0].GetType().GetProperties() = Array[PropertyInfo]((System.Reflection.RuntimePropertyInfo object at 0x002C [System.String name])) Whe I used the old clrtype with _clrproperties = {'name': str, ...}, it worked. -- -- Lukáš Shri Borde wrote: Here is an updated version of clrtype.py that uses @property + @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead of using _clrproperties. I think its more Pythonic in general, but also you should be able to modify @notify_property to work with it. Note that notify_property won't just work. You will have to change it to propagate the func_name, arg_types, and return_type properties from the old getter/setter function objects to the new getter/setter function objects since these values are used by clrtype to generate the CLR members. Something like this: class notify_property(property): def propagate_attributes(old_function, new_function): new_function.func_name = old_function.func_name new_function.arg_types = old_function.arg_types new_function.return_type = old_function.return_type def __init__(self, getter): def newgetter(slf): try: return getter(slf) except AttributeError: return None propagate_attributes(getter, newgetter) super(notify_property, self).__init__(newgetter) def setter(self, setter): def newsetter(slf, newvalue): oldvalue = self.fget(slf) if oldvalue != newvalue: setter(slf, newvalue) slf.OnPropertyChanged(setter.__name__) propagate_attributes(setter, newsetter) return property( fget=self.fget, fset=newsetter, fdel=self.fdel, doc=self.__doc__) *From:* Lukas Cenovsky [mailto:cenov...@bakalari.cz] *Sent:* Thursday, November 12, 2009 11:01 AM *To:* Shri Borde *Subject:* Re: [IronPython] .NET attributes for methods Shri Borde wrote: So the new clrtype.py still works - cool! Yep ;-) I am not an expert on data binding, so I don't have any suggestions. Why do you say that the decorator approach will not work with Silverlight? Does @notifiy_property from http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html use any feature not available in Silverlight? It does not (as far as I know because it is pure IronPython). But @notify_property does not work with clrtypes: class ViewModel(NotifyPropertyChangedBase): __metaclass__ = clrtype.ClrMetaclass _clrnamespace = Cenda.ViewModel _clrproperties = {'size': str} def __init__(self): super(ViewModel, self).__init__() # must be string to two-way binding work correctly self.size = '10' @notify_property def size(self): return self._size @size.setter def size(self, value): self._size = value print 'Size changed to %r' % self.size When I run this code, the size is still clr property and Python getter and setter are not run. So basically I need to override/enhance clr getter and setter created by clrtype._clrproperties. -- -- Lukáš *From:* Lukas Cenovsky [mailto:cenov...@bakalari.cz] *Sent:* Thursday, November 12, 2009 8:09 AM *To:* Shri Borde *Subject:* Re: [IronPython] .NET attributes for methods Thanks, that works! What do you think would be the best approach to create notifiable properties for Silverlight? I did it for WPF (via decorators: http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html) but it seems to me it won't be possible to do it similarly for Silverlight... -- -- Lukáš Shri Borde wrote: Can you use _clrproperties instead of _clrfields? DevHawk's same created a field and a property even when you just used _clrfields. I don't do that anymore. So you will need to use _clrproperties to get properties, which SL must use for data binding. *From:*
[IronPython] DLR Hosting, IronPython Engine shutdown issues
Hi everyone, In the old IronPython hosting API there used to be a simple pyEngine.Shutdown() command. And then for cleanup we used: pyEngine.Dispose() What is the equivalent in the new hosting API's? (am using IronPython 2.0.3) I found that there is something like: pyEngine.Runtime.Shutdown(); Does that do the same as the old Shutdown() method? And what can I use instead of the Dispose() command that doesn't seem to exist anymore? Thanks, Matan ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] .NET attributes for methods
I also tested creating interfaces and it fails with the exception below. Does this mean it will not be possible to use IronPython interface in Silverlight because of AppDomain? -- -- Lukáš SystemError: Application code cannot access System.AppDomain.get_CurrentDomain() using Reflection. clrtype.py |Line 180: validate_clr_types(b) Line 181: if not ClrInterface.interface_module_builder: Line 182: assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(AssemblyName(interfaces), AssemblyBuilderAccess.Run) Line 183: ClrInterface.interface_module_builder = assembly_builder.DefineDynamicModule(interfaces) Line 184: attrs = TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract | SystemError |at define_interface in clrtype.py, line 182 at __clrtype__ in clrtype.py, line 213 at app.py in app.py, line 12 CLR Stack Trace: at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[] args, Boolean shouldOptimize) at IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`1.Call0(CallSite site, CodeContext context, TFuncType func) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at IronPython.Runtime.Types.BuiltinFunction.Call0(CodeContext context, SiteLocalStorage`1 storage, Object instance) at IronPython.Runtime.Types.ReflectedProperty.CallGetter(CodeContext context, PythonType owner, SiteLocalStorage`1 storage, Object instance) at IronPython.Runtime.Types.ReflectedProperty.TryGetValue(CodeContext context, Object instance, PythonType owner, Object value) at IronPython.Runtime.Binding.MetaPythonType.FastGetBinderHelper.SlotAccessDelegate.Target(CodeContext context, Object self, Object result) at IronPython.Runtime.Types.TypeGetBase.RunDelegatesNoOptimize(Object self, CodeContext context) at IronPython.Runtime.Types.SystemTypeGet.Target(CallSite site, Object self, CodeContext context) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at clrtype$3.define_interface$21(PythonFunction $function, Object typename, Object bases) at IronPython.Runtime.PythonFunction.FunctionCaller`2.Call2(CallSite site, CodeContext context, Object func, T0 arg0, T1 arg1) at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at clrtype$3.__clrtype__$23(PythonFunction $function, Object self) at IronPython.Runtime.PythonFunction.FunctionCaller`1.Call1(CallSite site, CodeContext context, Object func, T0 arg0) at CallSite.Target(Closure , CallSite , CodeContext , Object ) at IronPython.NewTypes.IronPython.Runtime.Types.PythonType_1$1.__clrtype__() at IronPython.Runtime.Types.PythonType.InitializeUserType(CodeContext context, String name, PythonTuple bases, PythonDictionary vars) at IronPython.Runtime.Types.PythonType..ctor(CodeContext context, String name, PythonTuple bases, PythonDictionary dict) at IronPython.NewTypes.IronPython.Runtime.Types.PythonType_1$1..ctor(CodeContext context, PythonType cls, String name, PythonTuple bases, PythonDictionary dict) at CallSite.Target(Closure , CallSite , CodeContext , BuiltinFunction , PythonType , Object , Object , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute6[T0,T1,T2,T3,T4,T5,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) at IronPython.Runtime.Types.UserInstanceCreator.CreateInstance(CodeContext context, Object arg0, Object arg1, Object arg2) at IronPython.Runtime.Types.PythonType.CreateInstance(CodeContext context, Object arg0, Object arg1, Object arg2) at IronPython.Runtime.Types.PythonType.__new__(CodeContext context, PythonType cls, String name, PythonTuple bases, PythonDictionary dict) at CallSite.Target(Closure , CallSite , CodeContext , Object , String , PythonTuple , PythonDictionary ) at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at CallSite.Target(Closure , CallSite , CodeContext , Object , String , PythonTuple , PythonDictionary ) at IronPython.Runtime.Operations.PythonOps.MakeClass(CodeContext context, String name, Object[] bases, String selfNames, PythonDictionary vars) at IronPython.Runtime.Operations.PythonOps.MakeClass(Object body, CodeContext parentContext,
Re: [IronPython] .NET attributes for methods
I can help you create a property. And I can help you get it to work with your decorators (you can check if the name property exposes your @notify_property wrapper methods or not, and presumably that works). Beyond that, you are on your own :) I would try calling the property methods to make sure they are accessible. Something like this. If that works, I am not sure what Silverlight needs to make databinding happy. props = a.root.listbox1.Items[0].GetType().GetProperties() prop = props[0] prop.GetGetMethod.Invoke(a, None) # call using Reflection About the SystemError: Application code cannot access System.AppDomain.get_CurrentDomain() using Reflection. error when defining interfaces, it could be worked around. We need to call AppDomain.DefineDynamicAssembly, and IronPython itself does do this. So its just a question of figuring out the right way to access an AppDomain instance. Will look into it, but I doubt it will help you with data binding. From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Friday, November 13, 2009 5:42 AM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods This looks very promising but I cannot make it work. I have changed product.py in DevHawk's example to: #from clrtypeold import ClrMetaclass import clrtype class Product(object): #__metaclass__ = ClrMetaclass __metaclass__ = clrtype.ClrClass _clrnamespace = DevHawk.IronPython.ClrTypeSeries #_clrproperties = { #name:str, #cost:float, #quantity:int, #} def __init__(self, name, cost, quantity): self.name = name self.cost = cost self.quantity = quantity def calc_total(self): return self.cost * self.quantity @property @clrtype.accepts() @clrtype.returns(str) def name(self): return self._name @name.setter @clrtype.accepts(str) @clrtype.returns() def name(self, value): self._name = value When I run it I don't see any items in the listbox. When I check the name, it is a property: py a.root.listbox1.Items[0] = Product object at 0x002B py a.root.listbox1.Items[0].GetType().GetProperties() = Array[PropertyInfo]((System.Reflection.RuntimePropertyInfo object at 0x002C [System.String name])) Whe I used the old clrtype with _clrproperties = {'name': str, ...}, it worked. -- -- Lukáš Shri Borde wrote: Here is an updated version of clrtype.py that uses @property + @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead of using _clrproperties. I think its more Pythonic in general, but also you should be able to modify @notify_property to work with it. Note that notify_property won't just work. You will have to change it to propagate the func_name, arg_types, and return_type properties from the old getter/setter function objects to the new getter/setter function objects since these values are used by clrtype to generate the CLR members. Something like this: class notify_property(property): def propagate_attributes(old_function, new_function): new_function.func_name = old_function.func_name new_function.arg_types = old_function.arg_types new_function.return_type = old_function.return_type def __init__(self, getter): def newgetter(slf): try: return getter(slf) except AttributeError: return None propagate_attributes(getter, newgetter) super(notify_property, self).__init__(newgetter) def setter(self, setter): def newsetter(slf, newvalue): oldvalue = self.fget(slf) if oldvalue != newvalue: setter(slf, newvalue) slf.OnPropertyChanged(setter.__name__) propagate_attributes(setter, newsetter) return property( fget=self.fget, fset=newsetter, fdel=self.fdel, doc=self.__doc__) From: Lukas Cenovsky [mailto:cenov...@bakalari.cz] Sent: Thursday, November 12, 2009 11:01 AM To: Shri Borde Subject: Re: [IronPython] .NET attributes for methods Shri Borde wrote: So the new clrtype.py still works - cool! Yep ;-) I am not an expert on data binding, so I don't have any suggestions. Why do you say that the decorator approach will not work with Silverlight? Does @notifiy_property from http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html use any feature not available in Silverlight? It does not (as far as I know because it is pure IronPython). But @notify_property does not work with clrtypes: class ViewModel(NotifyPropertyChangedBase): __metaclass__ = clrtype.ClrMetaclass _clrnamespace = Cenda.ViewModel _clrproperties = {'size': str} def __init__(self): super(ViewModel, self).__init__() # must be string to two-way binding work correctly self.size = '10'
Re: [IronPython] .NET attributes for methods
Help with getting properties to work will hopefully resolve the databinding as well ;-) The property getter looks wrong but I have no idea what's wrong: py props = a.root.listbox1.Items[0].GetType().GetProperties() py props = Array[PropertyInfo]((System.Reflection.RuntimePropertyInfo object at 0x002C [System.String name])) py prop = props[0] py prop.GetGetMethod() = System.Reflection.RuntimeMethodInfo object at 0x002B [System.String name()] py prop.GetGetMethod().Invoke(a.root.listbox1.Items[0], None) System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. at module in string, line 0 Just for clarification a is Silverlight Application instance As for the interface error - this is a different strory. You may remember I created WCF service in IronPython with just interface defined in C#. To be able to move interface to IronPython, I need such interface to work with Silverlight too because Silverlight is the cause why I am building WCF services. -- -- Lukáš Shri Borde wrote: I can help you create a property. And I can help you get it to work with your decorators (you can check if the name property exposes your @notify_property wrapper methods or not, and presumably that works). Beyond that, you are on your own :) I would try calling the property methods to make sure they are accessible. Something like this. If that works, I am not sure what Silverlight needs to make databinding happy. props = a.root.listbox1.Items[0].GetType().GetProperties() prop = props[0] prop.GetGetMethod.Invoke(a, None) # call using Reflection About the SystemError: Application code cannot access System.AppDomain.get_CurrentDomain() using Reflection. error when defining interfaces, it could be worked around. We need to call AppDomain.DefineDynamicAssembly, and IronPython itself does do this. So its just a question of figuring out the right way to access an AppDomain instance. Will look into it, but I doubt it will help you with data binding. *From:* users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] *On Behalf Of *Lukas Cenovsky *Sent:* Friday, November 13, 2009 5:42 AM *To:* Discussion of IronPython *Subject:* Re: [IronPython] .NET attributes for methods This looks very promising but I cannot make it work. I have changed product.py in DevHawk's example to: #from clrtypeold import ClrMetaclass import clrtype class Product(object): #__metaclass__ = ClrMetaclass __metaclass__ = clrtype.ClrClass _clrnamespace = DevHawk.IronPython.ClrTypeSeries #_clrproperties = { #name:str, #cost:float, #quantity:int, #} def __init__(self, name, cost, quantity): self.name = name self.cost = cost self.quantity = quantity def calc_total(self): return self.cost * self.quantity @property @clrtype.accepts() @clrtype.returns(str) def name(self): return self._name @name.setter @clrtype.accepts(str) @clrtype.returns() def name(self, value): self._name = value When I run it I don't see any items in the listbox. When I check the name, it is a property: py a.root.listbox1.Items[0] = Product object at 0x002B py a.root.listbox1.Items[0].GetType().GetProperties() = Array[PropertyInfo]((System.Reflection.RuntimePropertyInfo object at 0x002C [System.String name])) Whe I used the old clrtype with _clrproperties = {'name': str, ...}, it worked. -- -- Lukáš Shri Borde wrote: Here is an updated version of clrtype.py that uses @property + @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead of using _clrproperties. I think its more Pythonic in general, but also you should be able to modify @notify_property to work with it. Note that notify_property won't just work. You will have to change it to propagate the func_name, arg_types, and return_type properties from the old getter/setter function objects to the new getter/setter function objects since these values are used by clrtype to generate the CLR members. Something like this: class notify_property(property): def propagate_attributes(old_function, new_function): new_function.func_name = old_function.func_name new_function.arg_types = old_function.arg_types new_function.return_type = old_function.return_type def __init__(self, getter): def newgetter(slf): try: return getter(slf) except AttributeError: return None propagate_attributes(getter, newgetter) super(notify_property, self).__init__(newgetter) def setter(self, setter): def newsetter(slf, newvalue): oldvalue = self.fget(slf) if oldvalue != newvalue: setter(slf, newvalue) slf.OnPropertyChanged(setter.__name__)
Re: [IronPython] DLR Hosting, IronPython Engine shutdown issues
pyEngine.Runtime.Shutdown() is the equivalent. As far as Python is concerned the only interesting thing this does is run sys.exitfunc if it's been set - there's some other stuff that happens but it's logging and some cleanup which will happen on its own. So there's no need to really call a Dispose type method. From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of matan keret Sent: Friday, November 13, 2009 6:09 AM To: Discussion of IronPython Subject: [IronPython] DLR Hosting, IronPython Engine shutdown issues Hi everyone, In the old IronPython hosting API there used to be a simple pyEngine.Shutdown() command. And then for cleanup we used: pyEngine.Dispose() What is the equivalent in the new hosting API's? (am using IronPython 2.0.3) I found that there is something like: pyEngine.Runtime.Shutdown(); Does that do the same as the old Shutdown() method? And what can I use instead of the Dispose() command that doesn't seem to exist anymore? Thanks, Matan ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] DLR Hosting, IronPython Engine shutdown issues
OK thank you for the fast reply! On Fri, Nov 13, 2009 at 7:23 PM, Dino Viehland di...@microsoft.com wrote: pyEngine.Runtime.Shutdown() is the equivalent. As far as Python is concerned the only interesting thing this does is run sys.exitfunc if it’s been set - there’s some other stuff that happens but it’s logging and some cleanup which will happen on its own. So there’s no need to really call a Dispose type method. *From:* users-boun...@lists.ironpython.com [mailto: users-boun...@lists.ironpython.com] *On Behalf Of *matan keret *Sent:* Friday, November 13, 2009 6:09 AM *To:* Discussion of IronPython *Subject:* [IronPython] DLR Hosting, IronPython Engine shutdown issues Hi everyone, In the old IronPython hosting API there used to be a simple pyEngine.Shutdown() command. And then for cleanup we used: pyEngine.Dispose() What is the equivalent in the new hosting API's? (am using IronPython 2.0.3) I found that there is something like: pyEngine.Runtime.Shutdown(); Does that do the same as the old Shutdown() method? And what can I use instead of the Dispose() command that doesn't seem to exist anymore? Thanks, Matan ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Hello,
Hi My names is Luis Bilar , I'm from brazil, I have a problem, with I call libary in ironpython ? -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Hello,
On 11/13/09, luis bilar luis.bi...@gmail.com wrote: Hi My names is Luis Bilar , I'm from brazil, I have a problem, with I call libary in ironpython ? -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. Luis, Can you provide some code or background? If you're getting started, this is a good site: www.ironpython.info Carl T. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Hello,
Hi, I need implematation this's code in ironpython from pytesser import* image = Image.open('fnord.tf') print image_to_string(image) but need call libary pytesser. please help me :( 2009/11/13 Carl Trachte ctrac...@gmail.com On 11/13/09, luis bilar luis.bi...@gmail.com wrote: Hi My names is Luis Bilar , I'm from brazil, I have a problem, with I call libary in ironpython ? -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. Luis, Can you provide some code or background? If you're getting started, this is a good site: www.ironpython.info Carl T. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] .NET attributes for methods
Thanks to Shri and the new clrtype both issues are resolved. I will post details soon on my blog. -- -- Lukáš Lukas Cenovsky wrote: Help with getting properties to work will hopefully resolve the databinding as well ;-) The property getter looks wrong but I have no idea what's wrong: py props = a.root.listbox1.Items[0].GetType().GetProperties() py props = Array[PropertyInfo]((System.Reflection.RuntimePropertyInfo object at 0x002C [System.String name])) py prop = props[0] py prop.GetGetMethod() = System.Reflection.RuntimeMethodInfo object at 0x002B [System.String name()] py prop.GetGetMethod().Invoke(a.root.listbox1.Items[0], None) System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. at module in string, line 0 Just for clarification a is Silverlight Application instance As for the interface error - this is a different strory. You may remember I created WCF service in IronPython with just interface defined in C#. To be able to move interface to IronPython, I need such interface to work with Silverlight too because Silverlight is the cause why I am building WCF services. -- -- Lukáš Shri Borde wrote: I can help you create a property. And I can help you get it to work with your decorators (you can check if the name property exposes your @notify_property wrapper methods or not, and presumably that works). Beyond that, you are on your own :) I would try calling the property methods to make sure they are accessible. Something like this. If that works, I am not sure what Silverlight needs to make databinding happy. props = a.root.listbox1.Items[0].GetType().GetProperties() prop = props[0] prop.GetGetMethod.Invoke(a, None) # call using Reflection About the SystemError: Application code cannot access System.AppDomain.get_CurrentDomain() using Reflection. error when defining interfaces, it could be worked around. We need to call AppDomain.DefineDynamicAssembly, and IronPython itself does do this. So its just a question of figuring out the right way to access an AppDomain instance. Will look into it, but I doubt it will help you with data binding. *From:* users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] *On Behalf Of *Lukas Cenovsky *Sent:* Friday, November 13, 2009 5:42 AM *To:* Discussion of IronPython *Subject:* Re: [IronPython] .NET attributes for methods This looks very promising but I cannot make it work. I have changed product.py in DevHawk's example to: #from clrtypeold import ClrMetaclass import clrtype class Product(object): #__metaclass__ = ClrMetaclass __metaclass__ = clrtype.ClrClass _clrnamespace = DevHawk.IronPython.ClrTypeSeries #_clrproperties = { #name:str, #cost:float, #quantity:int, #} def __init__(self, name, cost, quantity): self.name = name self.cost = cost self.quantity = quantity def calc_total(self): return self.cost * self.quantity @property @clrtype.accepts() @clrtype.returns(str) def name(self): return self._name @name.setter @clrtype.accepts(str) @clrtype.returns() def name(self, value): self._name = value When I run it I don't see any items in the listbox. When I check the name, it is a property: py a.root.listbox1.Items[0] = Product object at 0x002B py a.root.listbox1.Items[0].GetType().GetProperties() = Array[PropertyInfo]((System.Reflection.RuntimePropertyInfo object at 0x002C [System.String name])) Whe I used the old clrtype with _clrproperties = {'name': str, ...}, it worked. -- -- Lukáš Shri Borde wrote: Here is an updated version of clrtype.py that uses @property + @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead of using _clrproperties. I think its more Pythonic in general, but also you should be able to modify @notify_property to work with it. Note that notify_property won't just work. You will have to change it to propagate the func_name, arg_types, and return_type properties from the old getter/setter function objects to the new getter/setter function objects since these values are used by clrtype to generate the CLR members. Something like this: class notify_property(property): def propagate_attributes(old_function, new_function): new_function.func_name = old_function.func_name new_function.arg_types = old_function.arg_types new_function.return_type = old_function.return_type def __init__(self, getter): def newgetter(slf): try: return getter(slf) except AttributeError: return None propagate_attributes(getter, newgetter) super(notify_property, self).__init__(newgetter) def setter(self, setter): def newsetter(slf, newvalue): oldvalue = self.fget(slf) if oldvalue
Re: [IronPython] Hello,
On 11/13/09, luis bilar luis.bi...@gmail.com wrote: Hi, I need implematation this's code in ironpython from pytesser import* image = Image.open('fnord.tf') print image_to_string(image) but need call libary pytesser. please help me :( Luis, OK, you're in the wrong place (on the wrong list). You need to use the standard implementation of Python 2.4 from www.python.org. Good luck. We can't help you here any more. Here is the google code link for pytesser: http://code.google.com/p/pytesser/ PyTesser PyTesser is an Optical Character Recognition module for Python. It takes as input an image or image file and outputs a string. PyTesser uses the Tesseract OCR engine, converting images to an accepted format and calling the Tesseract executable as an external script. A Windows executable is provided along with the Python scripts. The scripts should work in other operating systems as well. Dependencies PIL is required to work with images in memory. PyTesser has been tested with Python 2.4 in Windows XP. Usage Example from pytesser import * image = Image.open('fnord.tif') # Open image object using PIL print image_to_string(image) # Run tesseract.exe on imagefnord print image_file_to_string('fnord.tif')fnord(more examples in README) Carl T. 2009/11/13 Carl Trachte ctrac...@gmail.com On 11/13/09, luis bilar luis.bi...@gmail.com wrote: Hi My names is Luis Bilar , I'm from brazil, I have a problem, with I call libary in ironpython ? -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. Luis, Can you provide some code or background? If you're getting started, this is a good site: www.ironpython.info Carl T. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Hello,
Tks the best. 2009/11/13 Carl Trachte ctrac...@gmail.com On 11/13/09, luis bilar luis.bi...@gmail.com wrote: Hi, I need implematation this's code in ironpython from pytesser import* image = Image.open('fnord.tf') print image_to_string(image) but need call libary pytesser. please help me :( Luis, OK, you're in the wrong place (on the wrong list). You need to use the standard implementation of Python 2.4 from www.python.org. Good luck. We can't help you here any more. Here is the google code link for pytesser: http://code.google.com/p/pytesser/ PyTesser PyTesser is an Optical Character Recognition module for Python. It takes as input an image or image file and outputs a string. PyTesser uses the Tesseract OCR engine, converting images to an accepted format and calling the Tesseract executable as an external script. A Windows executable is provided along with the Python scripts. The scripts should work in other operating systems as well. Dependencies PIL is required to work with images in memory. PyTesser has been tested with Python 2.4 in Windows XP. Usage Example from pytesser import * image = Image.open('fnord.tif') # Open image object using PIL print image_to_string(image) # Run tesseract.exe on imagefnord print image_file_to_string('fnord.tif')fnord(more examples in README) Carl T. 2009/11/13 Carl Trachte ctrac...@gmail.com On 11/13/09, luis bilar luis.bi...@gmail.com wrote: Hi My names is Luis Bilar , I'm from brazil, I have a problem, with I call libary in ironpython ? -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDUhttp://cesar.edu/ The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. Luis, Can you provide some code or background? If you're getting started, this is a good site: www.ironpython.info Carl T. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDUhttp://cesar.edu/ The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- Thanks Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited. ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com