Catch OSErrors when creating directories (LP: #671067)

This commit is contained in:
Stefano Rivera 2010-11-22 14:29:52 +02:00
parent 7126a9e894
commit 04eb3ada8b
2 changed files with 14 additions and 4 deletions

1
debian/changelog vendored
View File

@ -15,6 +15,7 @@ ubuntu-dev-tools (0.107) UNRELEASED; urgency=low
packages. 3.0 (quilt) has optional per-vendor patch series.
* pbuilder-dist:
- Refactor to use subprocess.popen instead of os.system (LP: #398974)
- Catch OSErrors when creating directories (LP: #671067)
[ Benjamin Drung ]
* wrap-and-sort: Remove duplicate items from sorted lists.

View File

@ -89,8 +89,13 @@ class pbuilder_dist:
self.base = os.path.expanduser(os.environ.get('PBUILDFOLDER', '~/pbuilder/'))
if not os.path.exists(self.base):
os.makedirs(self.base)
if not os.path.isdir(self.base):
try:
os.makedirs(self.base)
except os.OSError:
print >> stderr, ('Error: Cannot create base directory "%s"'
% self.base)
exit(1)
if 'PBUILDAUTH' in os.environ:
self.auth = os.environ['PBUILDAUTH']
@ -182,8 +187,12 @@ class pbuilder_dist:
self.logfile = os.path.normpath('%s/last_operation.log' % result)
if not os.path.isdir(result):
# Create the results directory, if it doesn't exist.
os.makedirs(result)
try:
os.makedirs(result)
except os.OSError:
print >> stderr, ('Error: Cannot create results directory "%s"'
% result)
exit(1)
if self.builder == 'pbuilder':
base = '--basetgz "%s-base.tgz"' % prefix