stuck with PyOBEX

A

alejandro

So I installed the module and tryed to make it work but...
It gave me:

Traceback (most recent call last):
File "first.py", line 24, in <module>
client2.connect()
File "C:\Python25\lib\PyOBEX\client.py", line 359, in connect
return Client.connect(self, header_list = [headers.Target(uuid)])
File "C:\Python25\lib\PyOBEX\client.py", line 119, in connect
self.socket = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM,
AttributeError: 'module' object has no attribute 'AF_BLUETOOTH'>>> Exit
Code: 1


This module asks the socket module for AF_BLUETOOTH... in the socket module
there is no such thing as AF_BLUETOOTH. Could it be that the person that
made PyOBEX modified his socket module and forgot to give his socket module?
Or am I missing something? Maybe AF_BLUETOOTH stands for something that a
programmer would know but I am a beginner so...

Is there a OBEX module for Python on windows?
 
D

Diez B. Roggisch

alejandro said:
So I installed the module and tryed to make it work but...
It gave me:

Traceback (most recent call last):
File "first.py", line 24, in <module>
client2.connect()
File "C:\Python25\lib\PyOBEX\client.py", line 359, in connect
return Client.connect(self, header_list = [headers.Target(uuid)])
File "C:\Python25\lib\PyOBEX\client.py", line 119, in connect
self.socket = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM,
AttributeError: 'module' object has no attribute 'AF_BLUETOOTH'>>> Exit
Code: 1


This module asks the socket module for AF_BLUETOOTH... in the socket
module there is no such thing as AF_BLUETOOTH. Could it be that the person
that made PyOBEX modified his socket module and forgot to give his socket
module? Or am I missing something? Maybe AF_BLUETOOTH stands for something
that a programmer would know but I am a beginner so...

Is there a OBEX module for Python on windows?

AF_BLUETOOTH seems to be specific to *nix-systems. At least under debian and
ubuntu, I've got it defined.

So it seems it is not supported under windows - you should consider the
author if that's a mistake, or by design.

Diez
 
A

alejandro

Can you tell me what is it? Maybe I can search it and pass it in another
way... if it is an address or protocol name....
 
D

Diez B. Roggisch

alejandro said:
Can you tell me what is it? Maybe I can search it and pass it in another
way... if it is an address or protocol name....

I'm not entirely sure, but I guess no, you can't simply pass it in.

Unix uses streams as abstraction for a lot of things - all kinds of devices
for example.

Windows doesn't. It most probably has a dedicated API for dealing with
bluetooth - I found this document which backs this assumption:

http://tombell.org.uk/papers/bluetooth-detection.pdf

I can't comment on the feasibility of hooking the windows api into the inner
workings of PyOBEX - depending on it's design, it would be a major
overhaul.

Diez
 
D

David Robinow

Can you tell me what is it? Maybe I can search it and pass it in another
way... if it is an address or protocol name....

That won't help. The socket module is not compiled with bluetooth
support on Windows.
Microsoft supplies bluetooth support in the PSDK but it's not
compatible with the Linux support and that's all the socket module
supports.
To get bluetooth support in the socket module somebody will have to
use a Bluetooth Development Kit that is linux-compatible (I don't know
if that exists).
Alternatively, you might look at PuBluez
(http://code.google.com/p/pybluez/) which appears to wrap the
Microsoft bluetooth stuff. I don't know if that will help you do what
you want.
 
A

alejandro

The problem with Pybluez is that the module serves only to get the
addresses, ports, protocols... that the device uses but can't send or recive
files. So I am stuck again :-(
Maybe I should use dll-s.... and again another thing to learn... :)
 
D

David Boddie

AF_BLUETOOTH seems to be specific to *nix-systems. At least under debian
and ubuntu, I've got it defined.

Yes, it appears to be compiled into the socket module if the relevant
Bluetooth library (libbluetooth) and header file (bluetooth.h) were
available when Python was built.
So it seems it is not supported under windows - you should consider the
author if that's a mistake, or by design.

By design, though a previous, unreleased version used the bluetooth module
provided by PyBluez (http://code.google.com/p/pybluez/) which contains its
own BluetoothSocket class before I released that the socket module could
also support Bluetooth sockets.

I guess I could change the package to use BluetoothSocket if Bluetooth
support isn't provided by the user's socket module.

David
 
J

Jorgen Grahn

alejandro wrote:
[AF_BLUETOOTH]
Can you tell me what is it? Maybe I can search it and pass it in another
way... if it is an address or protocol name....

I'm not entirely sure, but I guess no, you can't simply pass it in.

Unix uses streams as abstraction for a lot of things - all kinds of devices
for example.

You mean "uses the BSD Socket API as an abstraction" here. That's the
framework where "AF_BLUETOOTH" apparently lives.

/Jorgen
 
Ð

Дамјан ГеоргиевÑки

This module asks the socket module for AF_BLUETOOTH... in the socket
module there is no such thing as AF_BLUETOOTH. Could it be that the
person that made PyOBEX modified his socket module and forgot to give
his socket module? Or am I missing something? Maybe AF_BLUETOOTH
stands for something that a programmer would know but I am a beginner
so...

Is there a OBEX module for Python on windows?


You could try lightblue http://lightblue.sourceforge.net/

and next time don't use windows
/kidding


--
дамјан ( http://softver.org.mk/damjan/ )

"We think it's a great consumer win, and it's a great industry win,
to be able to ensure that with good copy protection,
you can have so much functionality for the user",
Jordi Rivas, Microsoft Director of Technology
 
D

David Boddie

So I should connect trough pybluez and send with obex??

Yes, or you could try lightblue:

http://lightblue.sourceforge.net/

I've updated PyOBEX to try and be a bit more flexible when it comes to
Bluetooth socket implementations, so you might want to give that a try:

http://pypi.python.org/pypi/PyOBEX

If you use PyOBEX, you find devices with the bluetooth module (from PyBluez)
then connect and send using PyOBEX:

# Find device addresses.
devices = bluetooth.discover_devices()

# List services provided by a device with the given address.
bluetooth.find_service(address=device_address)

# Find the port used for the file transfer service.
port = bluetooth.find_service(uuid="E006",
address=device_address)[0]["port"]

# List the files in the device's root directory.
from PyOBEX.client import BrowserClient
client = BrowserClient(device_address, port)
client.connect()
client.listdir()
client.disconnect()

Good luck!

David
 
A

alejandro

I am having problems with connect() it says that it doesn't have sendall
atribute.

Error:

Traceback (most recent call last):
File "novi_pokusaj.py", line 25, in <module>
client.connect()
File "C:\Python25\lib\PyOBEX\client.py", line 356, in connect
return Client.connect(self, header_list = [headers.Target(uuid)])
File "C:\Python25\lib\PyOBEX\client.py", line 127, in connect
response = self._send_headers(request, header_list, max_length)
File "C:\Python25\lib\PyOBEX\client.py", line 81, in _send_headers
self.socket.sendall(request.encode())
AttributeError: BluetoothSocket instance has no attribute 'sendall'>>> Exit
Code: 1


Did you manage to run it under windows?
 
D

David Boddie

I am having problems with connect() it says that it doesn't have sendall
atribute.

Error:

Traceback (most recent call last):
File "novi_pokusaj.py", line 25, in <module>
client.connect()
File "C:\Python25\lib\PyOBEX\client.py", line 356, in connect
return Client.connect(self, header_list = [headers.Target(uuid)])
File "C:\Python25\lib\PyOBEX\client.py", line 127, in connect
response = self._send_headers(request, header_list, max_length)
File "C:\Python25\lib\PyOBEX\client.py", line 81, in _send_headers
self.socket.sendall(request.encode())
AttributeError: BluetoothSocket instance has no attribute 'sendall'>>>
Exit Code: 1

Did you manage to run it under windows?

I haven't tried to run it under Windows. I just assumed that BluetoothSocket
would have the same API on both Linux and Windows.

Looking around, it seems that this is something we can work around:

http://svn.navi.cx/misc/trunk/laserprop/client/BluetoothConduit.py

I'll send you an updated version to try if you would like to test it.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top