473,801 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting errno from OSError exception?

Can somebody loan me a clue as to how to check the errno on
an OSError, as described below?

try:
os.makedirs(d)
except OSError:
# if errno == 17 then silently ignore the error because the
# other process won the race condition and created the directory
# otherwise, allow the exception to percolate up the call stack
# and be caught by the standard error reporter
Many TIA!
Mark

--
Mark Harrison
Pixar Animation Studios
Jul 18 '05 #1
1 8261
Mark Harrison wrote:

Can somebody loan me a clue as to how to check the errno on
an OSError, as described below?

try:
os.makedirs(d)
except OSError:
# if errno == 17 then silently ignore the error because the
# other process won the race condition and created the directory
# otherwise, allow the exception to percolate up the call stack
# and be caught by the standard error reporter


What about this?

try:
os.makedirs(d)
except OSError, e:
if e.errno == 17:
do_something
- george
Jul 18 '05 #2

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

Similar topics

3
3650
by: Kali K E | last post by:
Hi, I could not understand how I can do the following things in Python. Please help me. 1. First I have to find the current directory from where the script is invoked. 2. Next I have to form a directory structure there. If the current directory in step 1 is /home/mylogin, then from there I have to build a directory structure like /home/mylogin/result
3
16601
by: Scott Whitney | last post by:
oldName=/backup/backups/data/WWW_httpd.conf_backups/20050204.httpd.conf newName=/backup_old/data/WWW_httpd.conf_backups/20050204.httpd.conf os.rename(oldName,newName) gives: OSError: Invalid cross-device link mv from the shell works fine.
11
7875
by: Alec Wysoker | last post by:
Using Python 2.3.5 on Windows XP, I occasionally get OSError: Permission denied when calling os.remove(). This can occur with a file that is not used by any other process on the machine, and is created by the python.exe invocation that is trying to delete it. It can happen with various pieces of my system - almost anywhere I try to delete a file. I have assumed that the problem is that I was holding on to a handle to the file that I...
0
3978
by: Joram Agten | last post by:
Please put me in CC When running the following program I get frequent errors like this one Exception in thread Thread-4: Traceback (most recent call last): File "C:\Python24\lib\threading.py", line 442, in __bootstrap self.run() File "os.remove.py", line 25, in run os.remove(filename)
10
5786
by: k r fry | last post by:
Hi, I am new to this list and also programming with python. I have an error: oserror not a directory "katiescint.py" The piece of code causing the problem is: for subdir in os.listdir(DATADIR): #loop through list of strings
0
1954
by: robert | last post by:
e.g. open/os module functions (os.path.getmtime...) and win32api/win32file functions fail on long paths (>~255 chars) even the '\\?\' trick from http://www.google.com/url?sa=D&q=http://msdn.microsoft.com/library/default.asp%3Furl%3D/library/en-us/fileio/fs/naming_a_file.asp does not work: >>> os.path.getmtime('\\\\?\\'+fabs) Traceback (most recent call last): File "<interactive input>", line 1, in ?
5
2914
by: Gregory Piñero | last post by:
Hi Guys, I'm sure this is documented somewhere, I just can't locate it. Say I have this code: try: myfile=file('greg.txt','r') except IOError, error: #now psuedo code because this is what I'm trying to figure out if error.errno=='file doesn't exist':
2
7580
by: Michael George Lerner | last post by:
Hi, (Python 2.5, OS X 10.4.10) I have a program called pdb2pqr on my system. It is installed so that "pdb2pqr" is in my path and looks like: #\!/bin/zsh -f /sw/share/pdb2pqr/pdb2pqr.py "$@" When I call it via this script:
3
6226
by: Rainy | last post by:
Hello! I'm having some trouble with pyserial package, I'm sending commands and reading responses from a custom pcb, and sometimes I get a proper response, at other times I get nothing, and sometimes I get about half of the response string with beginning cut off. About half the time an empty string is returned, the other ~half time good response, and more rarely I get partial response. When I try to use the same Serial instance to...
0
9556
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10516
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10292
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10262
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10052
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7589
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6829
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.