On Sun, Aug 12, 2007 at 03:01:06PM -0400, Tony Maro wrote: > Just read the text file at the specified location. Where we said "cat > XXXXXX", cat was just meaning dump the contents of that file to the console, > so you could just open that file like any text file and read the serial > number out of it. That's Linux 101, but certainly is alien to anyone who > has done Palm, PocketPC or Windows development. > > So in Python for instance, you might do: > > mypath = '/sys/devices/platform/mmci-omap.1/mmc1*/cid' > srcfile = open(mypath,'r')
Ah, no, Python's open won't process shell wildcards. You want glob for
that:
import glob
mypath = glob.glob('/sys/devices/platform/mmci-omap.1/mmc1*/cid')[0]
srcfile = open(mypath, 'r')
Be prepared to catch a KeyError if the path doesn't exist (because you
don't have a card inserted) and glob.glob() returns an empty list.
(It might be better to use that other file to determine the actual
directory name rather than globbing.)
> myserial = srcfile.readline()
> srcfile.close()
> # tada! no need for any include's either. Nice and simple.
Marius Gedminas
--
Press any key to continue, or any other key to cancel.
signature.asc
Description: Digital signature
_______________________________________________ maemo-developers mailing list [email protected] https://lists.maemo.org/mailman/listinfo/maemo-developers
