473,395 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

check whether directory is readable

Hello,
how can I check whether a directory is readable or not. Are there
differences between unix and windows?
Thank you for your hints, Eels

Aug 23 '05 #1
2 5929
eels wrote:
Hello,
how can I check whether a directory is readable or not. Are there
differences between unix and windows?


As far as I know there aren't any differences,

code:

import os
if access("/root", os.R_OK):
print "You are able to read the /root dir"

Aug 23 '05 #2
eels <ee**@nikocity.de> wrote:
how can I check whether a directory is readable or not. Are there
differences between unix and windows?


The Pythonic way would be to just do what you need to do (in this
case, presumably, read the directory) and catch the specific exception
(in this case, presumably, OSError).

try:
# Do whatever needs a readable directory
normal_reading_stuff()

except OSError, e:
# Do whatever we need to when the directory is unreadable
print "Unable to read stuff:", e.strerror

--
\ "I got contacts, but I only need them when I read, so I got |
`\ flip-ups." -- Steven Wright |
_o__) |
Ben Finney
Aug 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Praveen | last post by:
Hi All, I'm new to DB2, I have installed DB2 UDB V8 on Solaris machine. And i tried to create a stored proc.But, gives the following error.. -- LOG FILE P2093405.log FOR PROCEDURE...
2
by: Ponnurangam | last post by:
Hi, I need to check whether a file named flower exists with different extensions. I know only file name. I don't the the extension(may be .bmp, .ipg, or ..gif). And if there are files with...
4
by: Stephen | last post by:
Hi all, Suppose I am monitoring a Folder C:\Temp and I drop either a file or directory into this folder How will i programmatically know whether the "item" dropped is a file or a folder ...
18
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning...
5
by: GenCode | last post by:
What is the best way to read a "readable" web directory... I know I can do this Client.DownloadFile("http://www.mydomain.com/readabledir/", c:\ \dir.txt"); But that gives me the html and all...
6
by: Alexander Vasilevsky | last post by:
How do I know whether the file is text or binary? http://www.alvas.net - Audio tools for C# and VB.Net developers + Christmas discount
5
by: hammer45 | last post by:
Modify payroll program so that it uses a class to store and retrive the employee's name, hourly rate and the number of hours worked. Use a constructor to initialize the employee information, and a...
55
by: lovecreatesbea... | last post by:
Do you check all error conditions for all library calls in you code? Is it necessary to check all errors? Is it convenient to check all errors (or how to make code clean and readable with mass of...
4
by: pwu | last post by:
Hi, I am doing an automated scan of a large number of UNIX machines which can be Solaris, AIX or HPUX. I want to find out for a machine via a script if: 1) DB2 is installed? 2) If installed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.