{"id":586,"date":"2009-12-22T23:34:11","date_gmt":"2009-12-22T13:34:11","guid":{"rendered":"http:\/\/www.erisian.com.au\/wordpress\/?p=586"},"modified":"2009-12-22T23:34:11","modified_gmt":"2009-12-22T13:34:11","slug":"python-on-nokias60","status":"publish","type":"post","link":"https:\/\/www.erisian.com.au\/wordpress\/2009\/12\/22\/python-on-nokias60","title":{"rendered":"Python on Nokia\/S60"},"content":{"rendered":"<p>I finally got a smartphone a week or two ago. I ended up getting a <a href=\"http:\/\/www.gsmarena.com\/nokia_n86_8mp-2713.php\">Nokia N86<\/a>, based on a combination of form factor (I would&#8217;ve preferred a flip phone, but apparently not enough people do for there to be lots of different models, and I&#8217;m still a bit reluctant to go for touch interfaces), camera spec (optical zoom would&#8217;ve been a killer feature, but if you&#8217;re not <a href=\"http:\/\/www.gsmarena.com\/samsung_sch_w880_amoled_12m-review-398.php\">Korean<\/a>, apparently not until next year), and hackability. There seem to be a variety of smartphone flavours at the moment: there&#8217;s Windows CE (which I had on an old phone, and which sucked worse than I expected), there&#8217;s Blackberry (which is kinda closed and corporate, and tends to come with relatively crappy cameras for the price), there&#8217;s the iPhone (which has a mediocre camera, and no Python support at least as far as the app store is concerned), there&#8217;s Symbian (Nokia and Sony-Ericsson and maybe Samsung smartphones), and then there&#8217;s the Linux variants: Maemo (Nokia N900), WebOS (Palm Pre), and Android. Android would probably have been my preference there, but any of the Linuxes would work too, and I found out Symbian had decent Python support so that works too. And as it turned out the older Linux phones didn&#8217;t really match my feature list, and <a href=\"http:\/\/www.gsmarena.com\/motorola_milestone-3001.php\">the newer ones<\/a>, while pretty, are either as yet unavailable or kinda expensive (or both). So an N86 it was. Which has turned out to do pretty much everything I wanted so far.<\/p>\n<p>Nokia&#8217;s phone roadmap is pretty confusing (which seems to be par for the course for the telco industry admittedly) supporting both Maemo as well as different versions of Symbian everywhere (the most recent ones of which are apparently open sourced) as well as lower end &#8220;feature&#8221; phones. Apparently my Symbian version is &#8220;S60 3rd Edition&#8221;, and if you want to write apps the difference between that and &#8220;2nd edition&#8221; is a major one. S60 3rd ed is also, apparently, known as &#8220;Symbian OS 9.3&#8221;, the followup to which is &#8220;Symbian^1&#8221; which is also known as &#8220;S60 5th Edition&#8221; (4th Edition got skipped because 4 is unlucky for some). It&#8217;s on the latest Nokia smart phones &#8212; N97, 5800 XPressMusic, etc. &#8220;Symbian^2&#8221; and beyond will apparently be the open source versions, except that maybe it&#8217;ll be &#8220;Symbian^3&#8221; before any phones ship with it. There was also S90 which was more advanced than S60 at the time, but then got merged back in, so now it&#8217;s obsolete and S60 is better. Apparently the way phone OSes work is that you only upgrade when you get new hardware, so all the different versions ever are still floating around on old phones.<\/p>\n<p>Anyway, add ons for Symbian come packaged in &#8220;sis&#8221; files (&#8220;Symbian Installation Source&#8221; supposedly), which come signed in various different ways (some are signed for only a particular phone, in part to make it harder to write viruses, eg) and with different listed capabilities (so if your app doesn&#8217;t need to use gps or wifi, it will be blocked by the OS from doing so). When I first got the phone, the deal was you&#8217;d scour the web, and discover that you could download Python for S60 1.9.7 from <a href=\"https:\/\/garage.maemo.org\/projects\/pys60\">garage.maemo.org<\/a> &#8212; which is a SourceForge-clone that presumably was originally for Maemo stuff, but is now for anything Nokia-ish. Of course, there was no Python 1.9.7, and this is really Python 2.5.4 with miscellaneous Symbian extensions. In order to get a Python REPL prompt, you need to install both the Python_1.9.7.sis runtime and the PythonScriptShell sis, of which there are a few with different capabilities. Of course, you can only do this after unpacking the PythonForS60_1.9.7.tar.gz, which you can&#8217;t do on the phone.<\/p>\n<p>Anyway, get that done and look at the <a href=\"http:\/\/pys60.garage.maemo.org\/doc\/s60\/s60.html\">docs<\/a> and you can actually do something, which is kinda cool. I&#8217;ve been just plugging it into my laptop as USB mass storage and copying py scripts across, then running them from the ScriptShell menu so far, which is a bit kludgy but at least usable. So far it seems like lots of little bits of the API aren&#8217;t quite implemented for Python &#8212; I haven&#8217;t found a way to change the top right softkey hint from &#8220;Back&#8221; or &#8220;Exit&#8221; to &#8220;Save&#8221; or &#8220;Hide&#8221;; but that might just be unfamiliarity. More concerning was that when I tried to use time.mktime to get a Unix timestamp, the interpretor just crashed entirely, so it seems like there are some bugs around too. But the fact that you seem to be able to get at pretty much all the phone features (camera, gps, gsm location, sms, etc, etc) from pretty simple python still makes it a win in my book.<\/p>\n<p>Shortly after I&#8217;d gotten that far, I did a random invocation of the &#8220;SW Update&#8221; app to see if there was any new stuff for me, and got informed &#8220;Python for S60 2.0&#8221; was available for download. Neato, I thought, and went looking to see what the deal was &#8212; but there&#8217;s almost nothing out there discussing it. I tried installing it anyway, but apparently the download got cut off, and SW Update isn&#8217;t smart enough to continue or start again in that event. But deleting the partial download and trying again worked, and eventually I got me some Python for S60 2.0, which seems to be the same 2.5.4 version 1.9.7 was. The advantage, in theory, should be that programs written in python can just have a sis file that says &#8220;I need Python&#8221; and the official version will be automatically downloaded. But my first go at making that happen seems to indicate that the dependency used to be on &#8220;Python for S60&#8221;, but maybe now needs to be on &#8220;Python runtime&#8221;. Which, of course, is hardcoded into the app (ensymble), and although that&#8217;s an open source Python app (and packaged for Debian at that), it&#8217;s distributed as a base64 encoded blob so you have to go right back to the source to change the appropriate seven characters. Assuming, of course, that I&#8217;m on the right track in my guess as to what the problem is.<\/p>\n<p>As far as I can tell, there&#8217;s still not much in the way of any sort of official announcement as to what&#8217;s going on with PyS60 2.0, but <a href=\"http:\/\/discussion.forum.nokia.com\/forum\/showthread.php?t=188842\">it seems<\/a> that they&#8217;re rolling it out to some handsets, and the N86 is just lucky on that score. It&#8217;s bizarre to me that the Nokia devteam aren&#8217;t doing any bragging about getting Python for S60 up to 2.0 and into the official distribution, but I get the impression there isn&#8217;t much communication going on in general. I haven&#8217;t been able to spot the source for 2.0 either, though I haven&#8217;t exactly looked very hard.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally got a smartphone a week or two ago. I ended up getting a Nokia N86, based on a combination of form factor (I would&#8217;ve preferred a flip phone, but apparently not enough people do for there to be lots of different models, and I&#8217;m still a bit reluctant to go for touch interfaces), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[21],"_links":{"self":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/586"}],"collection":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/comments?post=586"}],"version-history":[{"count":1,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/586\/revisions"}],"predecessor-version":[{"id":587,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/586\/revisions\/587"}],"wp:attachment":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/media?parent=586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/categories?post=586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/tags?post=586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}