Re: [pyusb-users] Compatibility with Python 3.3?

2013-01-27 Thread Xiaofan Chen
On Tue, Jan 22, 2013 at 2:09 PM, Xiaofan Chen  wrote:
> So it seems to me maybe the DLL finding method in Python 3.3
> is a bit different.
>
> Google seems to suggest this is a Python 3.3 bug.
> http://bugs.python.org/issue16283
> Title:  ctypes.util.find_library does not find all DLLs anymore
> Type:   behaviorStage:
> Components: ctypes  Versions:   Python 3.3
>

The work-around seems to speel out the full name ".dll".
Maybe this can be done in pyusb.

In the bug report, there is a test script attached.

http://bugs.python.org/file27618/ct_test.py

import sys
import os
import ctypes.util

lookup_path = "C:\\Windows\\system32"
dll_file = os.path.join(lookup_path, "OpenAL32.dll")

print("Python build: %s" % sys.version)

print("Path '%s' exists in $PATH: %s" % (lookup_path, lookup_path in
os.environ["PATH"].split(os.pathsep)))
print("File '%s' exists: %s" % (dll_file, os.path.exists(dll_file) and
os.path.isfile(dll_file)))

print("ctypes says for '%s': %s" % ("OpenAL32.dll",
ctypes.util.find_library("OpenAL32.dll")))
  --- this works.
print("ctypes says for '%s': %s" % ("OpenAL32",
ctypes.util.find_library("OpenAL32")))
  --- this does not work.

-- 
Xiaofan

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Issue 10 feedback

2013-01-27 Thread Xiaofan Chen
On Sun, Jan 27, 2013 at 5:22 AM, Emmanuel Blot  wrote:
>> I not like that change. If someone want to use both versions, rename
>> it and use..
>
> I agree: who many installations would be broken once pyusb is updated?
> All Python modules that depends on "pyusb" would have to be updated,
> this is not a trivial task.
>

I agree with you here.

As for distro, probably they will wait for the formal release to package
pyusb. Usually distros tend to lag behind.



-- 
Xiaofan

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Wander Lairson Costa
2013/1/27 Steven Michalske :
>
>
> On Jan 27, 2013, at 3:35 PM, Wander Lairson Costa 
> wrote:
>
> _interop.as_array(s.encode('ut8'))
>
>
> Ahh, I read the _ and thought it was a private module.
>

Yes, it is, but any public function will forward user parameter to
this function...

-- 
Best Regards,
Wander Lairson Costa

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Steven Michalske


On Jan 27, 2013, at 3:35 PM, Wander Lairson Costa  
wrote:

> _interop.as_array(s.encode('ut8'))

Ahh, I read the _ and thought it was a private module.--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Wander Lairson Costa
2013/1/27 Steven Michalske :
> How can the user decide in your method?  I don't see it.
>

_interop.as_array(s.encode('ut8'))

-- 
Best Regards,
Wander Lairson Costa

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Steven Michalske

On Jan 26, 2013, at 11:04 AM, wander.lair...@gmail.com wrote:

> From: Wander Lairson Costa 
> 
> In usb/_interop.py in the as_array function, the array typecodes 'c' and
> 'u' are used. The 'c' typecode was removed from python 3.3 and 'u' will
> is deprecated. The solution is to use the fromstring array method, but
> it has the side effect of adding only the first byte of Unicode strings.
> ---
> usb/_interop.py |7 +++
> 1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/usb/_interop.py b/usb/_interop.py
> index 5abdcdb..d6d0a6c 100644
> --- a/usb/_interop.py
> +++ b/usb/_interop.py
> @@ -131,8 +131,7 @@ def as_array(data=None):
> except TypeError:
> # When you pass a unicode string or a character sequence,
> # you get a TypeError if first parameter does not match
> -try:
> -return array.array('c', data)
> -except TypeError:
> -return array.array('u', data)
> +a = array.array('B')
> +a.fromstring(data)
> +return a
> 

This code when run in python 2.7.4 raises an exception with unicode text as 
data.

In [12]: import array

In [13]: a=array.array('B')

In [14]: s=u"abcꬨ"

In [15]: a.fromstring(s)
---
UnicodeEncodeErrorTraceback (most recent call last)
 in ()
> 1 a.fromstring(s)

UnicodeEncodeError: 'ascii' codec can't encode character u'\uab28' in position 
3: ordinal not in range(128)

In [16]:

> -- 
> 1.7.10.4
> 
> 
> --
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users


--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Steven Michalske
How can the user decide in your method?  I don't see it.

Steve




On Jan 27, 2013, at 3:15 AM, Wander Lairson Costa  
wrote:

> 2013/1/26 Steven Michalske :
>> What about this?
>> Tested in python 2.7 and 3.3
>> 
>> a = array.array("B")
>> s=u"abcꬦ"
>> try:
>>a.fromstring(s.encode('ascii'))
>> except UnicodeEncodeError:
>>a.fromstring(s.encode('utf8'))
>> print(a)
>> array('B', [97, 98, 99, 234, 172, 166])
>> 
>> a = array.array("B")
>> s="abc"
>> try:
>>a.fromstring(s.encode('ascii'))
>> except UnicodeEncodeError:
>>a.fromstring(s.encode('utf8'))
> 
> I think is better to let the user decides which encoding he prefers.
> 
> -- 
> Best Regards,
> Wander Lairson Costa
> 
> --
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Issue 10 feedback

2013-01-27 Thread Xiaofan Chen
On Sun, Jan 27, 2013 at 7:04 PM, Emmanuel Blot  wrote:
> [OT] "libusb-1.0-0" on Debian is now using libusbx, which is quite confusing.
>

Actually most of the Linux distros are now using libusbx as the
libusb-1.0 API provider, Fedora, Debian/Ubuntu, Arch, etc.

libusbx.org have some more information if you feel it is
confusing.
http://libusbx.org/

-- 
Xiaofan

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Wander Lairson Costa
2013/1/26 Steven Michalske :
> What about this?
> Tested in python 2.7 and 3.3
>
> a = array.array("B")
> s=u"abcꬦ"
> try:
> a.fromstring(s.encode('ascii'))
> except UnicodeEncodeError:
> a.fromstring(s.encode('utf8'))
> print(a)
> array('B', [97, 98, 99, 234, 172, 166])
>
> a = array.array("B")
> s="abc"
> try:
> a.fromstring(s.encode('ascii'))
> except UnicodeEncodeError:
> a.fromstring(s.encode('utf8'))
>
>

I think is better to let the user decides which encoding he prefers.

-- 
Best Regards,
Wander Lairson Costa

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Issue 10 feedback

2013-01-27 Thread Emmanuel Blot
> Debian/ubuntu packages..
> when you make: apt-get install python-usb
>
> the latest (in the dev branch) is 0.4.3-1
> The 1.0 (alfa 1, 2, 3.. etc..) must be packaged !

I do prefer using pip to manage Python package on Debian / Ubuntu /
whatever / .. OS X.
The main reason is actually to use several versions of Python modules
on the same host, thanks to virtualenv.
It is far more versatile and flexible, especially with Python modules
that evolve far more quickly than Debian official repositories.

PyUSB is actually packaged on PyPi btw.

[OT] "libusb-1.0-0" on Debian is now using libusbx, which is quite confusing.

Cheers,
Manu

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Issue 10 feedback

2013-01-27 Thread Wander Lairson Costa
2013/1/26 Alan Jhonn Aguiar Schwyn :
>> From: wander.lair...@gmail.com
>> Date: Sat, 26 Jan 2013 16:56:13 -0200
>> To: pyusb-users@lists.sourceforge.net
>> Subject: Re: [pyusb-users] Issue 10 feedback
>
>>
>> 2013/1/26 Alan Jhonn Aguiar Schwyn :
>> > I not like that change. If someone want to use both versions, rename
>> > it and use..
>> >
>> > I think that PyUSB 1.0 must be called "stable" (I use and not have
>> > problems
>> > of the library).
>> >
>> > Another problem: only PyUSB 0.4 is packaged. Who is the packager?
>> >
>>
>> What do you mean by 'packaged'? Windows binaries? Distribution repository?
>
> Debian/ubuntu packages..
>
> when you make: apt-get install python-usb
>
> the latest (in the dev branch) is 0.4.3-1
>
> The 1.0 (alfa 1, 2, 3.. etc..) must be packaged !
>

So you should ask for distribution packagers, who pick USB up and put
it in the repositories.

-- 
Best Regards,
Wander Lairson Costa

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users