Python find

Discussion in 'Python' started by George Sakkis, May 25, 2004.

  1. Hi all,

    I started writing a module to reproduce Gnu-find functionality in python (as
    far as I know, there's not one available; pyfind
    (http://www.anti-particle.com/pyfind.shtml) seems a bit relevant from it's
    webpage, though most links there are broken - also it's more of a standalone
    GUI tool than a reusable module). Some questions I have for now:

    - How can one get the filesystem name from python (e.g. for testing
    'find -fstype nfs') ?
    - Does os.readlink perform a call to os.stat or os.lstat (or the equivalent
    C system calls) ? If yes, I would like to rewrite it for the case the stat
    info for a file has already been cached.
    - Before I write it from scratch, is there a converter for Unix permission
    strings (like "+go=rw") to numeric modes ?

    Thanks,

    George
    George Sakkis, May 25, 2004
    #1
    1. Advertising

  2. George Sakkis

    Jeff Epler Guest

    On Tue, May 25, 2004 at 12:36:51PM -0400, George Sakkis wrote:
    > - How can one get the filesystem name from python (e.g. for testing
    > 'find -fstype nfs') ?


    You need to call "statfs" which I don't believe is available in Python
    without an extension module.

    I only know of the incomplete list of magic numbers to filesystem types
    listed in "man statfs", not a real way to find the filesystem name.

    Another option would getmntent() or (linux only) parsing /proc/mounts
    parser.

    > - Does os.readlink perform a call to os.stat or os.lstat (or the equivalent
    > C system calls) ? If yes, I would like to rewrite it for the case the stat
    > info for a file has already been cached.


    No, at least on my system it uses the readlink syscall. I don't see the
    readlink information contained anywhere in the stat/lstat structure.

    > - Before I write it from scratch, is there a converter for Unix permission
    > strings (like "+go=rw") to numeric modes ?


    Not that I recall seeing...

    Jeff
    Jeff Epler, May 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Jones

    Find::Find

    Dan Jones, Oct 7, 2004, in forum: Perl
    Replies:
    1
    Views:
    786
    Joe Smith
    Oct 8, 2004
  2. ad
    Replies:
    2
    Views:
    855
  3. Wybo Dekker
    Replies:
    1
    Views:
    350
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    398
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    806
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page