Re: detect endianness of a binary with python

2010-07-23 Thread Robert Kern
On 7/23/10 12:44 AM, Tim Roberts wrote: I wouldn't use os.system with grep and evaluate the return code. Instead I'd use subprocess.Popen("file") and read the text output of the commdn directly. By parsing that string, I can extract all kinds of interesting information. Small correction: subp

Re: detect endianness of a binary with python

2010-07-22 Thread Tim Roberts
Holger brunck 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 endi

Re: detect endianness of a binary with python

2010-07-22 Thread Daniel Fetchinson
>>> Something like the "file" utility for linux would be very helpfull. >>> >>> Any help is appreciated. > >>You're going to have to describe in detail what's in the file before >>anybody can help. > > We are creating inside our buildsystem for an embedded system a cram > filesystem > image. Later

Re: detect endianness of a binary with python

2010-07-21 Thread Grant Edwards
On 2010-07-21, Thomas Jollans wrote: >> It would be possible to execute ret = os.system("file | >> grep "little endian") and evaluate the return code. But I don't like >> to evaluate a piped system command. If there is an way without using >> the os.system command this would be great. > > Files

Re: detect endianness of a binary with python

2010-07-21 Thread MRAB
Thomas Jollans wrote: On 07/21/2010 05:29 PM, Holger brunck wrote: Something like the "file" utility for linux would be very helpfull. Any help is appreciated. You're going to have to describe in detail what's in the file before anybody can help. We are creating inside our buildsystem for an

Re: detect endianness of a binary with python

2010-07-21 Thread Thomas Jollans
On 07/21/2010 05:29 PM, Holger brunck wrote: > >>> Something like the "file" utility for linux would be very helpfull. >>> >>> Any help is appreciated. > >> You're going to have to describe in detail what's in the file before >> anybody can help. > > We are creating inside our buildsystem for an

Re: detect endianness of a binary with python

2010-07-21 Thread Holger brunck
>> Something like the "file" utility for linux would be very helpfull. >> >> Any help is appreciated. >You're going to have to describe in detail what's in the file before >anybody can help. We are creating inside our buildsystem for an embedded system a cram filesystem image. Later on inside o

Re: detect endianness of a binary with python

2010-07-21 Thread Michael Torrie
On 07/21/2010 08:02 AM, Grant Edwards wrote: > On 2010-07-21, Holger brunck wrote: > >> I use python 2.5 and I am looking for a possibility to determine a >> file type. Especially the endianness of a file is needed for me. Is >> there a way to detect this easily in python? > > Only if you alread

Re: detect endianness of a binary with python

2010-07-21 Thread Grant Edwards
On 2010-07-21, Holger brunck wrote: > I use python 2.5 and I am looking for a possibility to determine a > file type. Especially the endianness of a file is needed for me. Is > there a way to detect this easily in python? Only if you already know what's going to be in the file. > Something like

detect endianness of a binary with python

2010-07-21 Thread Holger brunck
Hi all, I use python 2.5 and I am looking for a possibility to determine a file type. Especially the endianness of a file is needed for me. Is there a way to detect this easily in python? Something like the "file" utility for linux would be very helpfull. Any help is appreciated. Best regards Hol