python Programming Glossary: stat
What user do python scripts run as in windows? http://stackoverflow.com/questions/1213706/what-user-do-python-scripts-run-as-in-windows and provide an exception handler like this import errno os stat shutil def handleRemoveReadonly func path exc excvalue exc 1.. os.remove and excvalue.errno errno.EACCES os.chmod path stat.S_IRWXU stat.S_IRWXG stat.S_IRWXO # 0777 func path else raise.. and excvalue.errno errno.EACCES os.chmod path stat.S_IRWXU stat.S_IRWXG stat.S_IRWXO # 0777 func path else raise shutil.rmtree..
How do you get a directory listing sorted by creation date in python? http://stackoverflow.com/questions/168409/how-do-you-get-a-directory-listing-sorted-by-creation-date-in-python dates at least on Windows . # usr bin env python from stat import S_ISREG ST_CTIME ST_MODE import os sys time # path to.. sys.argv 2 else r'.' # get all entries in the directory w stats entries os.path.join dirpath fn for fn in os.listdir dirpath.. dirpath fn for fn in os.listdir dirpath entries os.stat path path for path in entries # leave only regular files insert..
Checking File Permissions in Linux with Python http://stackoverflow.com/questions/1861836/checking-file-permissions-in-linux-with-python than effective IDs to help out with suid situations . os.stat is the right way to get more general info about a file including.. and others. The st_mode attribute of the object that os.stat returns has the permission bits for the file. To help interpret.. file. To help interpret those bits you may want to use the stat module. Specifically you'll want the bitmasks defined here and..
Return a list of imported Python modules used in a script? http://stackoverflow.com/questions/2572582/return-a-list-of-imported-python-modules-used-in-a-script opcode _struct _warnings math shlex fcntl genericpath stat string warnings UserDict inspect repr struct sys pwd imp getopt.. AST to parse the code for runtime dependencies that a more static analysis would miss. Worked up a command example to demonstrate..
Python: shutil.rmtree fails on Windows with 'Access is denied' http://stackoverflow.com/questions/2656322/python-shutil-rmtree-fails-on-windows-with-access-is-denied Usage ``shutil.rmtree path onerror onerror `` import stat if not os.access path os.W_OK # Is the error an access error..
Inverse Distance Weighted (IDW) Interpolation with Python http://stackoverflow.com/questions/3104781/inverse-distance-weighted-idw-interpolation-with-python Currently I'm using RPy2 to interface with R and its gstat module. Unfortunately the gstat module conflicts with arcgisscripting.. interface with R and its gstat module. Unfortunately the gstat module conflicts with arcgisscripting which I got around by.. still like to remove my dependency on installing R. The gstat website does provide a stand alone executable which is easier..
How to find the mountpoint a file resides on? http://stackoverflow.com/questions/4453602/how-to-find-the-mountpoint-a-file-resides-on find the longest common prefix with your path or use the stat system call to get the device a file resides on and go up the.. up the tree until you get to a different device. In Python stat may be used as follows untested and may have to be extended.. path path os.path.abspath path orig_dev os.stat path .st_dev while path ' ' dir os.path.dirname path if os.stat..
Python - How to check if a file is used by another application? http://stackoverflow.com/questions/589407/python-how-to-check-if-a-file-is-used-by-another-application more or less every X seconds where X is larger than 2 T . stat the file subtract file's modification time from now yielding..
Compiling Python 2.6.6 and need for external packages wxPython, setuptools, etc… in Ubuntu http://stackoverflow.com/questions/6079128/compiling-python-2-6-6-and-need-for-external-packages-wxpython-setuptools-etc a more positive check run it like this # strace e trace stat fstat open python imports.py strace.txt 2 1 # grep v ' 1' strace.txt.. positive check run it like this # strace e trace stat fstat open python imports.py strace.txt 2 1 # grep v ' 1' strace.txt..
Splitting out the output of ps using Python http://stackoverflow.com/questions/682446/splitting-out-the-output-of-ps-using-python outputs a list of processes with multiple columns for each stat. e.g. USER PID CPU MEM VSZ RSS TTY STAT START TIME COMMAND .....
Python, want logging with log rotation and compression http://stackoverflow.com/questions/8467978/python-want-logging-with-log-rotation-and-compression way possible. import time import re import os import stat import logging import logging.handlers as handlers class SizedTimedRotatingFileHandler..
|