pythonaro.com

Pythonaro blog

30 April 2009

zipfile quirk

In Python 2.6.0, a bug in the zipfile module makes the newly-acquired extractall() method basically useless. The function is supposed to extract all members of a zipfile, "no questions asked", like Windows would do with a right-click "Extract All..."; unfortunately, the original implementation makes it fail when the zipfile contains subdirectories. The behaviour was corrected in one of the 2.6.x maintenance releases (and 3.0.x, and 2.7), but if you have the misfortune to be stuck with 2.6.0, here's the banal workaround:
zf = zipfile.ZipFile(zpath)
zlist = zf.namelist()
for filename in zlist:
 if filename.endswith("/"):
  destpath = os.path.join(path_to_extract,filename[:-1])
  if not os.path.exists(destpath): os.makedirs(destpath)
 else:
  zf.extract(filename,path_to_extract)

Labels: , ,

posted by GiacomoL @ 9:22 AM   0 comments links to this post

27 April 2009

Braindead policies of Libero.it

I have had a @libero.it email address for more than 10 years. I stopped using it regularly when they disabled POP/IMAP for people connecting through other providers, but still logged in occasionally every once in a while.

Today I went there and my saved emails were all gone. Apparently I didn't log on for three months (which may or may not be), and this "authorized" them to go and delete all I had left there for 10 years.

This policy is braindead and guaranteed to piss off people. Storage is cheap; if they really wanted to "temporarily disable the account" (in their words), they could have simply bounced incoming mail, and compressed the few megabytes (!) of data, ready to be restored the first time I logged in again.

This act of destruction was unnecessary, and carries the risk of being sued by angry people. This is the sort of decisions that made Libero.it (once at the forefront of internet-adoption waves in Italy) a fringe player; while Google and others ate their lunch, they were all busy penny-pinching, pissing off old-time users faster than they were making (very few) new customers.

Labels: , , ,

posted by GiacomoL @ 7:22 AM   1 comments links to this post

21 April 2009

On Toggl

I started tracking my activities using Toggl. The concept is very simple: the site gives you a timer that you can "toggle" to signal when you are starting a certain task. You define different tasks and group them into projects, and you can mark "billable" hours as such (clearly a feature for consultants / freelancers). It features reports (obviously) and other workgroup-related options, a dotNet-based offline tracker, and premium options for paid subscribers.

The first day I used it, it was enlightening: it turns out that I only spent about 3 hours doing actual "core" work. Most of the remaining time was wasted being sidetracked by other internal projects, plus random chitchat. Ok, it was the day Oracle bought Sun, and we were pretty psyched about it (especially me, as the first thought I had when news emerged about the botched IBM/SUN deal was "well, [Oracle] would be a much better fit than IBM; db appliances would be very sexy, and most of [Oracle]'s stack is Java-based already", and the others were all "yeah, keep dreaming!"... then Larry vindicated me), I expect the numbers to get better. If they don't, it means my routine needs improving and I'll work on that, but I feel that without Toggl I probably wouldn't have the sort of hindsight that gives a sense of achieving, which is necessary to maintain continuous efforts.

All in all, Toggl feels cool. Other project-management sites should take note.

Labels: , ,

posted by GiacomoL @ 6:43 AM   0 comments links to this post

15 April 2009

Phorm/Webwise must go down

Phorm / Webwise is a disgusting ex-spyware maker now intent in profiteering from your browsing habits without your consent, as described by this exhaustive explanation of the Phorm system and why it is bad for everyone. They will basically spy on all your network request and then inject their own advertising on somebody else's pages. This is bad for users (spied on without consent, with very low guarantees of anonymity), and extremely bad for any website holder (whose content is modified and exploited, again without consent, and probably infringing copyright laws).

Yesterday the European Union, usually so despised by British citizens, formally accused Britain of infringing the EU directive on data protection by implementing Phorm. Today, Amazon opted out of the system, as previously did Google, Facebook and many others. I personally opted out a few minutes ago, by sending an email to website-exclusion@phorm.com listing all my domains.

For the sake of the net, Phorm/Webwise MUST fail. If the system goes live, I will ask my ISP whether my traffic will go through BT, and if so, I will switch to a provider who can guarantee they will NOT take part in the system (i.e. not Virgin and not TalkTalk).

Labels: , , , , , , , , ,

posted by GiacomoL @ 2:27 PM   0 comments links to this post

13 April 2009

One of the (many) problems of modern education...

...is that logic and rhetoric are not taught well, or (like in my experience) not taught at all.

This is reflected in the political debate, which is getting dumbed-down to the point where rational arguments can be completely absent; and it can be seen all over "teh intarwebs", where multitudes of well-intentioned individuals routinely end up acting like trolls.

One should be able to understand when he is losing the rational argument, and either retreat, reformulate, move the subject onto a different field, or try to bluff his way through. By banging on about the same, lost point over and over again, one doesn't do himself any favour; he might be able to appeal to the basest instincts of some individuals, but he won't be able to win intelligent men to his cause.

I have to admit, I have been guilty of this behaviour several times during the years. I put it down to my lack of knowledge of the abovementioned fields. At school, they taught us how to analyse sentences for syntactical structure, but rarely for meaning, and never for logic. They told us how to write in a readable style, but didn't really ask us to understand where we are in a debate, how to interact strategically during a verbal confrontation, how to step back from the heat and think hard about your next rhetorical move.

Is it a form of large conspiracy, where upper classes try to maintain old privileges by "forgetting" to properly teach these subjects to the uninitiated? Or could it be that these are considered too dangerous a weapon, too prone to abuse, to be widely taught? Or is it simply that education topics are constantly squeezed by the furious pace of technological advancement, to the point where you need to teach kids how to work with newer and newer devices which are fundamental to the current way of life (computer, tv, ipods etc etc)?

In any case, it feels like some of the oldest fields of study ever taught ended up being victims of accomplished mass-scholarisation. I don't think this is helping the masses or anyone else, though.

Labels: , , , ,

posted by GiacomoL @ 6:58 PM   0 comments links to this post

10 April 2009

How to get precompiled documentation for Qt4

Memo to self: if you ever need to download the Qt4 documentation on Windows, instead of scraping the official site, just download the qt4-doc package for Debian, open it with 7-Zip and extract the .qch files to use with QtAssistant (which also gives you indexing etc).

Labels: ,

posted by GiacomoL @ 11:19 PM   0 comments links to this post

06 April 2009

ODBC proxy/rewriter

I have several ODBC (and JDBC) requests, all pointing to the same server. They are all queries coming from the same database user. However, depending on who the caller is, requests should be "rewritten" to point to a different schema (for Oracle) or database (for SQLServer). In short, the identity should be proxied, because I cannot manually change it client-side.

Can this be done transparently? Does anybody know of a tool that does it, even commercial ones?

I thought about using a simple network proxy and redirecting to different RDBMS instances, but that is not a scalable solution for us; we must be able to separate these requests but still keep them on the same instance.

I can't find anything on Google, I wonder if the LazyWeb can help...?

UPDATE: I realized I need something similar to Context Switching in SQLServer 2005/2008, to wrap all my requests with a "EXECUTE AS" request. I wonder what the equivalent is for Oracle.

Labels: , , , ,

posted by GiacomoL @ 4:53 PM   0 comments links to this post

02 April 2009

Come on Bosnia!

    P W D L F A GD PTS
1 Spain 6 6 0 0 13 2 11 18
2 Bosnia-Herzegovina 6 4 0 2 18 7 11 12
3 Turkey 6 2 2 2 6 5 1 8
4 Belgium 6 2 1 3 10 11 -1 7
5 Estonia 6 1 2 3 5 15 -10 5
6 Armenia 6 0 1 5 3 15 -12 1

Only Germany and Poland managed to score 18 goals. After champagne-football, will we have cevapcici-football ?

Labels: , ,

posted by GiacomoL @ 11:37 AM   0 comments links to this post

01 April 2009

Eric4 startup crash on Windows

This post is for google.

If your Eric4 for Windows keeps crashing on startup, try the following:

  1. Start eric4-tray.py (which should be in your PYTHON_HOME\Lib\site-packages\eric4)
  2. Right-click on the Eric icon tray, and select Preferences
  3. Change something in the Application section, and click Apply then Ok
  4. Right-click again on the icon, and select "Eric IDE". This time it should start ok.
  5. Now you should be able to quit the tray application and start Eric as usual

Labels: , , ,

posted by GiacomoL @ 9:10 AM   2 comments links to this post