Holger brunck <holger.bru...@keymile.com> wrote:
>
>We are creating inside our buildsystem for an embedded system  a cram 
>filesystem
>image. Later on inside our build process we have to check the endianness,
>because it could be Little Endian or big endian (arm or ppc).
>
>The output of the "file" tool is for a little endian cramfs image:
><ourImage>: Linux Compressed ROM File System data, little endian size 1875968
>version #2 sorted_dirs CRC 0x8721dfc0, edition 0, 462 blocks, 10 files
>
>It would be possible to execute
>ret = os.system("file <ourImage> | grep "little endian")
>and evaluate the return code.

I wouldn't use os.system with grep and evaluate the return code.  Instead
I'd use subprocess.Popen("file <ourImage>") and read the text output of the
commdn directly.  By parsing that string, I can extract all kinds of
interesting information.

That is an entirely Unix-like way of doing things.  Don't reinvent the
wheel when there's a tool that already does what you want.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to