[IronPython] Help me IronPython + pybluez + VBNET

Sebastian Urbanski sebaurbanski at gmail.com
Sat Aug 21 19:33:15 CEST 2010


Hello, i'm a student from Argentina

I am developing an application that send and receive SMS messages.

This works fine in Python + Pybluez, but when i want to execute this code
from VBNET, i have problems. Ironpython can't resolve the bluetooth import

I am using NET 2008, python 2.6, Iron python 2.6 and
PyBluez-0.18.win32-py2.6.exe


Here i have a testing class "HelloWorl.py" to try to import package
bluetooth. The error result in NET is "global name 'discover_devices' is not
defined"

import clr
import sys
sys.path.append(r"C:\Python26\Lib")
sys.path.append(r"C:\Python26\Lib\site-packages")
import bluetooth
import select
clr.AddReference('prueba')
from prueba import HelloWorldVB
class HelloWorldIronPython(HelloWorldVB):
    def HelloWorld(self, name):
        return "Hello '" + name + "' from IronPython"
Bluetooth's package is installed in the following path:
C:\Python26\Lib\site-packages\bluetooth

I founded the function discover_devices and it is in bluez.py

If i try to import directly the bluez.py i have another error. Ironpython
not found the _bluetooth import.

import sys
import struct
import binascii
from btcommon import *
import _bluetooth as _bt
import array
import fcntl

Here my code for NET (solutions name is "prueba"):


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
AsSystem.EventArgs)
Handles Button1.Click

Dim helloWorld As New HelloWorldVB()

MsgBox(helloWorld.HelloWorld("Maurice"))

Dim runtime As ScriptRuntime =
IronPython.Hosting.Python.CreateEngine.Runtime

Dim scope As ScriptScope = runtime.ExecuteFile("HelloWorld.py")

Dim pythonType As PythonType = scope.GetVariable(Of PythonType)(
"HelloWorldIronPython")

helloWorld = CType(runtime.Operations.Invoke(pythonType), HelloWorldVB)

MsgBox(helloWorld.HelloWorld("Maurice"))

End Sub


Public Class HelloWorldVB

Public Overridable Function HelloWorld(ByVal name As String) As String

Return String.Format("Hello '{0}' from Visual Basic", name)

End Function

End Class


Any idea to import correctly the package bluetooth????


Thanks!!!


Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100821/79f30521/attachment.html>


More information about the Ironpython-users mailing list