×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    3

    btsocket module is not comptible with socket module in pys60 1.9.x?

    I'm using libgmail and it works with regular socket module in PyS60 1.9.5. However, it asks access point 10+ times! So, I did the trick of loading btsocket as socket module, and set the default access point.

    Code:
    sys.modules['socket'] = __import__('btsocket')
    import libgmail
    Now, libgmail stops working with an error while loading it, saying;

    Code:
    Exception exceptions.AttributeError: "'_fileobject' object has no attribute '_so
    ck'" in <bound method _fileobject.__del__ of <btsocket._fileobject object at 0x1
    a21c70>> ignored
    So, I compared the _fileobject of both btsocket and socket module, and obviously btsocket._fileobject has fewer attributes, specifically _sock is missing. Is there any workaround?

    Code:
    >>> import socket
    >>> dir(socket._fileobject)
    ['__class__', '__del__', '__delattr__', '__doc__', '__getattribute__', '__hash__
    ', '__init__', '__iter__', '__module__', '__new__', '__reduce__', '__reduce_ex__
    ', '__repr__', '__setattr__', '__slots__', '__str__', '_close', '_get_wbuf_len',
     '_getclosed', '_rbuf', '_rbufsize', '_sock', '_wbuf', '_wbufsize', 'bufsize', '
    close', 'closed', 'default_bufsize', 'fileno', 'flush', 'mode', 'name', 'next',
    'read', 'readline', 'readlines', 'softspace', 'write', 'writelines']
    >>> import btsocket
    >>> dir(btsocket._fileobject)
    ['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__getattribute__
    ', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__
    ', '__repr__', '__setattr__', '__str__', '__weakref__', 'close', 'fileno', 'flus
    h', 'read', 'readline', 'readlines', 'write', 'writelines']

  2. #2
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: btsocket module is not comptible with socket module in pys60 1.9.x?

    Quote Originally Posted by moo1 View Post
    I'm using libgmail and it works with regular socket module in PyS60 1.9.5. However, it asks access point 10+ times! So, I did the trick of loading btsocket as socket module, and set the default access point.

    The modules socket and btsocket are two different modules and hence are not expected to be 'compatible'. You can set the default AP for socket module by using its set_default_access_point() API.

    Code:
    import socket
    import appuifw
    
    ap_names = []
    
    # Retrieve the list of access points available
    ap_list_of_dicts = socket.access_points()
    
    # Extract the access point names and ask the user to select the access point
    # to be set as default
    for item in ap_list_of_dicts:
        ap_names.append(ap_list_of_dicts[item]['name'])
    ap_offset = appuifw.popup_menu(ap_names, "Select default access point")
    socket.set_default_access_point(ap_names[ap_offset])

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    3

    Re: btsocket module is not comptible with socket module in pys60 1.9.x?

    Thanks a lot! This worked fine for me. I just want to ask a few things, though.

    1. Why does socket have different API from btsocket to search access points?

    2. Will access point related API in btsocket be obsolete?

    3. Please update documentation to include this.

    There's no mention of this additional feature in socket module in the API document. The other thing I experienced regarding poor documentation was camera module, which camera.image_sizes() takes parameter but not mentioned in the document.

    I wonder if there's possibility for community to update API doc, if Nokia PyS60 team does not have resource.

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: btsocket module is not comptible with socket module in pys60 1.9.x?

    Quote Originally Posted by moo1 View Post
    There's no mention of this additional feature in socket module in the API document. The other thing I experienced regarding poor documentation was camera module, which camera.image_sizes() takes parameter but not mentioned in the document.

    I wonder if there's possibility for community to update API doc, if Nokia PyS60 team does not have resource.
    To update official docs, you might make a defect report at:
    https://garage.maemo.org/tracker/?at...54&func=browse

    On the other hand we can write own manual To get things started I just created "Unofficial PyS60 1.9.x FAQ":
    http://wiki.forum.nokia.com/index.ph...yS60_1.9.x_FAQ

    Cheers,

    --jouni

  5. #5
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: btsocket module is not comptible with socket module in pys60 1.9.x?

    Quote Originally Posted by moo1 View Post
    1. Why does socket have different API from btsocket to search access points?
    If you are thinking about non availability of an API similar to select_access_point(), please log an enhancement request.

    Quote Originally Posted by moo1 View Post
    2. Will access point related API in btsocket be obsolete?
    No, this wont be obsolete.

    Quote Originally Posted by moo1 View Post
    3. Please update documentation to include this.
    There's no mention of this additional feature in socket module in the API document.
    The documentation is already updated with this info. Checkout the 1.9.5 PyS60 documentation [file:///C:/Program%20Files/PythonForS60/doc/lib/module-socket.html].

    Quote Originally Posted by moo1 View Post
    The other thing I experienced regarding poor documentation was camera module, which camera.image_sizes() takes parameter but not mentioned in the document.
    If you find any discrepancies in the documentation, please log a bug. This is the only way for us and also for the community to track them effectively.

Similar Threads

  1. [Announce] pygame for S60 for PyS60 1.9.x
    By GameDude in forum Python
    Replies: 57
    Last Post: 2011-02-21, 23:18
  2. How to create a sis using ensymble and Python 1.9.4 ?
    By marcelobarrosalmeida in forum Python
    Replies: 10
    Last Post: 2009-05-27, 10:16
  3. Replies: 6
    Last Post: 2009-04-21, 11:54
  4. Replies: 9
    Last Post: 2008-08-30, 07:05
  5. Carbide.j 1.5 and Netbeans 5.5 beta 2
    By ovjo12 in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2007-06-11, 05:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •