On 23 September 2011 15:38, Dave Hanson <[email protected]> wrote:
> Hello Everyone,
>
> I have scoured the web and can only find half baked answers to my question
> - I'm hoping someone here can help?
>
> I know that Python is classed as a portable programming language (it will
> run on anything) So I'm wondering how do you code in such a way that your
> script can just be 'ported' over to another OS?
>
> I have this code to locate the Firefox directory:
>
> from subprocess import Popen, PIPE
>> li = Popen(['find', '/', '-iname', '*.default'],
>> stdout=PIPE).stdout.read().split('\n')
>> flag = 1
>> for item in li:
>> if item.find('firefox') != -1:
>> print >>outfile, "Firefox Directory: ", item
>> flag = 0
>> break
>
>
> It works fine on my Ubuntu machine, It won't run on a Windows machine
> (haven't tested) I think because I'm calling the unix version of find and
> also my path is /, obviously this would be c: in windows.
>
> I want to search the entire disk of any OS to find the Firefox cache
> directory. Is it even possible to do this? I don't particularly need the
> code to do it (I don't mind if you want to share though!) What I'm really
> after is - Am I wasting my time even trying?
>
Simple answer is that there probably isn't anything that's universal so it
would be easier to detect the OS using sys.platform and write specific code
for each platform.
s/
--
Twitter: @sfgreenwood
"Is this your sanderling?"
--
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk
https://wiki.ubuntu.com/UKTeam/