python

Python code to post photos and videos to a blog using APP or XML-RPC?

For a sekrit mobile :-) project I am doing with Jen, looking for open source python code that uses NewMediaObject on XML-RPC or the equivalent in the Atom Publishing Protocol to post photos and videos. Jen has looked and only found code to do text blog posts. Lazyweb?

Emacs over SSH - How I develop python programs directly on the N900

Here's how I write Python programs on the N900 on my Mac

  1. installed the ssh package, open ssh server
  2. via ssh, I use terminal.app to the ip address of the N900 (which I can see at all times with the personal IP address widget) and test stuff out interactively using python's command line interpreter, aka the python REPL
  3. when i am happy with the code that I have tested the REPL, I add it to the file on the N900 which I edit on emacs running on my mac using ange-ftp
  4. test the code out on the n900 from terminal.app, 90% of the time it just works since I tested it in the REPL unlike my C/C++ days when something you never thought of always required you to re-compile

Easy, peasy. No need to learn silly :-) Java or C+ or wait for compilation and access to the full power of your Mac for google searches plus you can execute on the N900 directly. No need for silly :-) emulators which in my experience aren't very useful.

PyMaemo is Python 2.5.4 and uses Numeric instead of Numpy

During my Python GPS experiments when I ported Matthew Brown's gamelan pygame python program to the N900's python aka pyamaemo,  found out the following which I am documenting so I won't forget:

  1. current version of PyMaemo is python 2.5.4
  2. python 2.5.4 uses the Numeric floating package (bug 1038, although I think installing NumPy manually instead of waiting for python 2.6 from PyMaemo is the road to yak-shaving madness :-) ! )instead of python 2.6's NumPy
  3. Numeric and NumPy are mostly compatible; there are very subtle differences which are easy to fix; so easy to fix that even I who know almost nothing about Python was able to fix it!

50000 photos & 6 years with a Camera Phone

Inspired by Jen's 2,045 Days with a Camera Phone:

  1. I have over 35000 (35823 as of this writing) public photos tagged "cameraphone" on flickr: http://www.flickr.com/photos/roland/tags/cameraphone since I bought my Nokia 7610 1 megapixel cameraphone back in June 2004
  2. Over 90% of those were with Nokia Cameraphones
  3. most of them were with the N95 (7643) and N82 (20, 554 as of this writing)
  4. Combine the 35000 public plus over 10000 on my private kid flickr account plus the ones that I didn't download and I have over 50000
  5. Needless to say I love my N82 :-) and its "triumph of the lofi" sensor
  6. I also love the non blurriness of my digital SLR and Lightroom but hate the fact that WiFi and GPS are not built into DSLRs (they both should be! All cameras including cameraphones and SLRs and point and shoots will be social cameras in 10 years or less!!!!)
  7. And like Jen I have tried the N8 under NDA and it's fantastic
  8. Therefore even though (like Jen), Symbian is not my fav operating system anymore:
  9. N8 + ShoZu + gravity = a winner so I am getting one (and an iPhone 4 as previously blogged; it would be silly for me not to use the awesome cameraphone power of the iPhone 4)
  10. And Jen, I assume when you write:
    1. " I will be purchasing a Nokia N8 and then tracking down a QT developer to help me flesh out the code of my mobile app idea. Here's to 2,045 more days of camera phone photography. ;o)"
    2. that python is ok? Right Jen :-) ? If so I'll help you write a prototype. I don't do C++ :-)

gpsgamelan.py is ok, but i want real music - use 12 major keys with 10 chords

Continuing to have a great time with Python on the N900. I'll have to post later about how awesome it is to run N900 Python aka PyMaemo scripts  from a Terminal.app window on my Mac edited in Aquamacs using ange-ftp (or whatever it's called in the 21st century).

Anyhow came up with gpsgamelan.py which is a modification of the script from latlongsound.py to play gamelan (indonesian scale) music (using the code from PyGSoundTestTest_3.py from Matthew Brown, thanks!) based on the jitter from GPS Lat/Long (10 different sounds based on latitude and another 10 different gamelan sounds based on longitude)

Here's what it sounds like (short video from flickr):

Not so great sound. My next idea is to play more pleasing music

  • e.g. for each neighbourhood, pick a major key (there are twelve possible major keys in Western music AFAIK)
  • based on the latitude, play a major chord (one of 10 possible)
  • based on the longitude, play a minor chord (one of 10 possible)

My guess is this will produce more melodic and pleasing sound

Random GPS driven sounds from an N900 in python

Check out latlongsound.py, my N900 hack to produce random sounds from GPS coordinates (it's basically an unholy :-)  combination of keyboard5.py from MIT and the PyMaemo Location API sample sound code using PyGame, thanks to the MIT and Maemo folks for sharing!). What should I do with this next? I have lots of ideas, love to hear what would be cool from others!

N900 PyMaemo - How to synthesize sounds & read the GPS simultaneously?

Just for fun, I am writing a little PyMaemo python script (sorry but I don't do C++ anymore so that's out :-) !) to compute and then play sounds based on my GPS coordinates (using the N900 Python Location API).

The easiest way to synthesize (rather than just play sounds) seems to be to use the PyGame sound synth (e.g. keyboard5.py from MIT computes some nice sounds) but I don't know how to make it work with the PyMaeMo GPS loop.

LazyWeb, anybody have some sample Python code :-) ? I of course will do my homework and post on the official very hard to follow forum (should I ask in talk.maemo.org OR the pymaemo list?) , but any help would be much appreciated.

REAL - Read, Evaluate, Art, Loop - N900 is the closest thing to a "REAL" machine

What I am looking for in my ongoing mobile art experiments is REAL!

  1. Read the sensors (GPS, accelerometer, compass, etc)
  2. Evaluate the data from the sensors
  3. Art - Make some art (sound, graphic, image, etc) and display and store it on the mobile
  4. Loop - Back to step 1

And I want to do it in a dynamic environment that doesn't force me to do yak shaving like spawning separate threads for each of the sensors or other such needless complexity that's not needed by my artistic algorithms. Nor the slings and arrows of outrageous certificates or certifications or developer programs or DRM malarkey :-) !

After reading the N900 technical reviews from the Maemo summit, it appears that the unlocked version of the N900 is the closest current device that could do this:

  1. It's Linux so assuming the sensor APIs are available from a standard Linux C (i.e. not using some non standard craziness like Carbide C++ for Symbian) library, Python, Ruby, name your favourite dynamic language here, etc (C++ and Java are just not malleable and easily hackable enough, sorry!) bindings could be (and probably are or are in the process of being) built to those C libraries
  2. No need for developer fees or ridiculous certificates
  3. It has all the sensors I want for my current experiments
  4. It's NOT mass market, but it's mass market enough for hackers (unlike Bug Labs Bug which I love but already probably has less than 1/10 the amount of developers working on it as the N900).

Am I right? Time for me to watch the blogs for signs of the N900 and Maemo 5 and 6 making dynamic languages first class citizens unlike on Symbian where S60 Python was far too many steps behind Carbide C++  (and time for to save up for the N910 since the N900 will probably be crippled in some significant way as all 1st gen Nokia devices are e.g. N95-1 not having enough memory)

Can't record video from S60 Python on an N93, how do I record video at 640x480?

Aaargh, it turnes out (thanks to Forum Nokia people for responding to my query!) that I can't record video from S60 Python on an N93 (see my earlier S60 video python post) without installing a MultimediaDD certificate which for some reason (bug?) is not present on an N93. Please Nokia update the N93 firmware to include he Multimedia DD certificate !

Questions:

  1. Since it's extremely unlikely there will be further N93 firmware updates, how do I install a Multimedia DD certificate on my N93?
  2. How do I get camera.start_record() to record 640x480 video on an N95? Is there some size parameter I need to specify in order to record at 640x480 resolution? There is nothing in the docs about a parameter that specifies the video resolution

 

How Do I record a Video using S60 Python 1.4.1?

I tried to record a video using the new video APIs in S60 Python 1.4.1 but I can't get it to work. My code (inspired by instaflickr code from the S60 Python Book Sample code) runs but the red light doesn't come on on my N93 and nothing is recorded. I am guessing (Forum Nokia post, SourceForge Bug Report) I have an error in camera.start_record() in the following code (which is also attached):

import appuifw

import e32, key_codes, os, os.path, camera, graphics

def cb(im):

  try:

    canvas.blit(im)

  except:

    appuifw.note(u'cb')

def cb2(im, blah):

  try:

    x = 1

  except:

    appuifw.note(u'cb2')

def start_viewfinder():

  camera.start_finder(cb)

  camera.start_record('E:\\Python\\whatever.mp4', cb2 )

  canvas = appuifw.Canvas()

  appuifw.app.body = canvas

  start_viewfinder()

  e32.ao_sleep(30) # record video for 30 seconds

  camera.stop_record()

  camera.stop_finder()

If anybody can help, please email roland AT rolandtanglao.com, call +1 604 729 7924, skype: rtanglao or Jabber: roland@bryght.com

AttachmentSize
mvlog.py.txt490 bytes

S60 Python Success - Got Sample code to work, Nokia camera.py doesn't work

Yay! Go my hello world program to work and finally got the OS X Bluetooth console to work. The trick is to:

ls -l /dev

and use the last tty for the screen command

e.g. if the last modified tty is tty.bt_console6

then you have to do screen /dev/tty.bt_console6

Now on to to create a program to create video in ego blogging mode (i.e. with screen facing you) using the high res camera.

I can't get the following code to work:

import appuifw

import camera
import e32
from camera import *
   
def cb(im):
  try:
    canvas.blit(im)
    #appuifw.app.body.blit(im)
  except:
    appuifw.note(u'cb')

def cb2(im):
  try:
    appuifw.app.body.blit(im)
  except:
    appuifw.note(u'cb2')

import graphics

canvas = appuifw.Canvas()
appuifw.app.body = canvas

start_finder(cb)

start_record('E:\\Python\whatever.mp4', cb2 )
#stop_record()

and I can't get the Nokia camera.py from Nokia's python sample code wiki page to work, help!

Nitobi Hack Day - desperately seeking S60 python help

Streaming video live from Nitobi Hack Day (247 Abbott, 3rd floor, come on down!) at rolandtanglao.com/mogulus and desperately seeking S60 python help (still can't get Bluetooth Console to work, help!)

Couldn't get Bluetooth console working with Python on my N93 - Super Happy Dev House Redux Part 2

I couldn't do the most basic thing and connect my terminal.app with my Python running on my Nokia N93. Aaargh!

I followed the Using the Python for Series 60 Bluetooth Console from OS X HOW TO from Erk Smartt but was unsuccessful.

Invoking the Bluetooth console from the python app on the Nokia N93 worked but then after typing "screen /dev/tty.BT_CONSOLE", I get the following error messages: "Cannot open line '/dev/tty.BT_CONSOLE' for R/W: Resource busy " followed by "Sorry, could not find a PTY. ".

What am I doing wrong? I know I had this working with my Mac and Series 60 Python on the N70 back in the day so it's a bit frustrating!

Apache ported to Symbian Series 60

I've downloaded this now and I am patiently awaiting my Gateway ID! Go Raccoon go!

FROM NRC - Phone Software:

QUOTE

Apache Modules

The following Apache modules have been built in: mod_alias, mod_auth, mod_autoindex, mod_dav, mod_dav_fs, mod_dir, mod_log_config, mod_mime, mod_rewrite, mod_setenvif and last, but definitely not least, mod_python.

Mod_python integrates Python for S60 with Apache and thus you can create content using Python scripting and also Python Server Pages. As it is possible to write your own Python extension modules, the entire S60 API is in principle available, even though the source for the Symbian port of Apache httpd is not yet provided.

The port of Apache httpd is based on version 2.0.52 and the port of mod_python on version 3.1.3.

...

In order to be able to browse to your mobile website you need to have an account on our gateway. Simply send a mail with the subject Raccoon Account and we will create one for you. If your name and preferred email-address are not evident from the mail headers, then specify them explicitly in the email body.

END QUOTE

Subscribe to RSS - python