[ubuntu-uk] Python Question
Juan J. Martínez
reidrac at usebox.net
Fri Sep 23 14:45:54 UTC 2011
On Fri, 2011-09-23 at 15:38 +0100, Dave Hanson wrote:
> [...]
> 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.
It won't work because you're using find. Your "popen" in running a
command (find) and it's not available on 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?
You can do it in a 100% pythonic way (not calling external commands),
although I would use platform specific code for that instead of scanning
the whole disk.
ie.
if sys.platform == 'win32':
# run windows code
elif sys.platform == 'darwing':
# run mac code
... etc ...
Then on windows import the required win32 crap to get firefox directory
from the registry.
On Linux you can guess that the directory will be on $HOME/.mozila/* and
the like, so use a list of possible directories.
Regards,
Juanjo
More information about the ubuntu-uk
mailing list