Converting Orca to Python 3.0
|
Something we've got to be thinking about soon is seeing what needs to be done to get Orca to run with Python 3.0, which is planned to be available in Auguest 2008. |
So I thought I'd give it a try now with the current Python 3.0a3 download.
Building it was trivial:
$ cd /home/richb/Python-3.0a3 $ ./configure --prefix=/usr $ make $ sudo make install
Guido and team have even made the conversion trivial. There is a tool called 2to3 in the Tools directory that will do the refactor for you.
I checked out a clean copy of the Orca sources from SVN and converted it with:
$ cd /home/richb/Python-3.0a3/Tools/2to3 $ python refactor.py /home/richb/gnome/orca/trunk/src >/tmp/diffs
This generated about 115KB of patch diffs on standard out which I then applied to the Orca source code:
$ cd /home/richb/gnome/orca/trunk $ patch -p0 </tmp/diffs
I then configured, built and installed Orca with:
$ cd /home/richb/gnome/orca/trunk $ ./autogen.sh --prefix=/usr $ make $ sudo make install
As it was byte-compiling all the Orca Python modules it bitched about the following two problems:
orca.py", line 1306
+ Q_("option|main-window") + "]", end=' ')
^
SyntaxError: invalid syntax
orca_prefs.py", line 636
os.close(os.open(initFile, os.O_CREAT, 0o700))
^
SyntaxError: invalid syntax
For the second one, it looks like "0o700" should be "o0700" but I couldn't work out what was wrong with the first one. The original code was:
print "-e, --enable=[" \
+ Q_("option|speech") + "|" \
+ Q_("option|braille") + "|" \
+ Q_("option|braille-monitor") + "|" \
+ Q_("option|magnifier") + "|" \
+ Q_("option|main-window") + "]",
and it refactored it to:
print("-e, --enable=[" \
+ Q_("option|speech") + "|" \
+ Q_("option|braille") + "|" \
+ Q_("option|braille-monitor") + "|" \
+ Q_("option|magnifier") + "|" \
+ Q_("option|main-window") + "]", end=' ')
According to the What's New in Python 3.0 web page, that seems okay. For now I've just removed the "end=' '" part and I have a successful install (with a minor run-time formatting error when you print out the usage message).
When I run Orca, everything seems to work fine. No tracebacks and Orca is happy brailling and speaking away.
What worries me is that when I check the version number of
/usr/bin/python (which is the same binary as
/usr/bin/python3.0) I get:
$ /usr/bin/python3.0 --version Python 2.5.2
So I'm not convinced I've done everything correctly.
Still it was nice to know that the conversion should hopefully be fairly trouble free when we do it for real. I guess that comes from pylinting the code to within an inch of its life.
( Mar 06 2008, 05:56:29 PM PST ) [Listen] Permalink Comments [5]
Whither Decent/Working Amazon API For Amazon Associates Web Service?
|
I have several small Python scripts that use the Amazon E-Commerce Web Service 3.0 to do things like read my Amazon wish lists and lookup books via their ISBN numbers. |
Last week I received an email from the Amazon Web Services folks. It states:
We are writing to remind you that the Amazon E-Commerce Web Service 3.0 will be deprecated on March 31st, 2008. Our monitoring indicates that your Subscription Id was passed into calls to Amazon E-Commerce Service 3.0 between February 17th and 24th, 2008. After March 31st, 2008, we will no longer accept Amazon ECS 3.0 requests. Please upgrade to the Amazon Associates Web Service (previously called Amazon E-Commerce Web Service 4.0) by then to ensure that you or your customers are not affected by the deprecation (if you migrated your application after February 24th, 2008, you will be unaffected). Please also note that none of the links you generate from Associates Central are affected by the deprecation. Any links, widgets or banner ads that you may have on your site will continue to function after March 31st.
Their meaning of "deprecated" is obviously different than the Java API's, where deprecated methods continued to work for several years.
It's true that Amazon have given fair warning about this change which was announced in February 2007. They even point to a migration guide.
My usual approach to things like this is "if it ain't broke, don't fix it", but it really looks like this is going to break in about 3-4 weeks, so I've been doing a bit of research.
I see nothing in the Amazon migration guide that points to new Python API that would help here. I have been using pyamazon and on that web page it states:
Kun Xi is starting a fork of PyAmazon to support some of the new features of AWS 4.x. This project is being hosted on Sourceforge. Initial code is available at: https://svn.sourceforge.net/svnroot/pyaws/.
The link is wrong. You can find it here.
I had a look at that. I got his example to work, but it really does seem incomplete. (He calls it pre-alpha for a reason). The documentation is sparse, and there aren't a lot of examples. Because of this, perhaps I'm not understanding how it fully works, but I don't see the equivalent of pyamazon calls like:
books = amazon.searchByASIN(asin)
So what are people using to access the new Amazon Associates Web Service? Is there a simple decent working Python API? Is there something somewhere that can easily map the old pyamazon API calls like:
amazon.setLicense(amazonAccessKey)
books = amazon.searchByASIN(asin)
results = amazon.searchByWishlist(amazonWishListID, page=pageNo)
books = amazon.searchByAuthor(author, page=pageNo)
to similar easy-to-understand new ones?
Inquiring minds wanna know...
[Technorati Tag: Web Services]
( Mar 06 2008, 08:50:24 AM PST ) [Listen] Permalink
Dog Biscuits
|
Our dog Dusti loves Jerky Tenders or similar products as a treat. This is like crunchy chicken jerky for dogs. The problem is that they are really expensive for what they are. A little while ago I tried googling to see if I could find a way to make something similar at a fraction of the cost. |
I couldn't find exactly what I was looking for (if anybody has a recipe, then please share), but I did find this one for Peanut Butter n' Honey Oat Crunchies. It's got two of the main food groups that dogs love: crunchy peanut butter and chicken (broth).
Earlier in the week I made up a batch. I think I used every flat metal baking tray we have. And both ovens. I now have a huge ziplock bag full of them. Luckily Dusti likes them too.
There are several other interesting dog recipes on that web page. We'll have to give them a try when she's finished this lot.
When you start cooking just for your dog, then you know that she is no longer just a pet, but has become a loving member of your family.
( Mar 06 2008, 08:00:43 AM PST ) [Listen] Permalink Comments [3]















