summaryrefslogtreecommitdiffstats
path: root/BuildManager/fileutil.py
diff options
context:
space:
mode:
Diffstat (limited to 'BuildManager/fileutil.py')
-rw-r--r--BuildManager/fileutil.py48
1 files changed, 27 insertions, 21 deletions
diff --git a/BuildManager/fileutil.py b/BuildManager/fileutil.py
index 93dd09d..aeba0eb 100644
--- a/BuildManager/fileutil.py
+++ b/BuildManager/fileutil.py
@@ -25,27 +25,31 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
try:
try:
fsrc = open(src, 'rb')
- except os.error, (errno, errstr):
- raise Error, "could not open %s: %s" % (src, errstr)
+ except os.error as xxx_todo_changeme2:
+ (errno, errstr) = xxx_todo_changeme2.args
+ raise Error("could not open %s: %s" % (src, errstr))
try:
fdst = open(dst, 'wb')
- except os.error, (errno, errstr):
- raise Error, "could not create %s: %s" % (dst, errstr)
+ except os.error as xxx_todo_changeme3:
+ (errno, errstr) = xxx_todo_changeme3.args
+ raise Error("could not create %s: %s" % (dst, errstr))
while 1:
try:
buf = fsrc.read(buffer_size)
- except os.error, (errno, errstr):
- raise Error, "could not read from %s: %s" % (src, errstr)
+ except os.error as xxx_todo_changeme:
+ (errno, errstr) = xxx_todo_changeme.args
+ raise Error("could not read from %s: %s" % (src, errstr))
if not buf:
break
try:
fdst.write(buf)
- except os.error, (errno, errstr):
- raise Error, "could not write to %s: %s" % (dst, errstr)
+ except os.error as xxx_todo_changeme1:
+ (errno, errstr) = xxx_todo_changeme1.args
+ raise Error("could not write to %s: %s" % (dst, errstr))
finally:
if fdst:
@@ -80,8 +84,8 @@ def copy_file (src, dst, preserve_mode=1, preserve_times=1, link=None,
from stat import ST_ATIME, ST_MTIME, ST_MODE, S_IMODE
if not os.path.isfile(src):
- raise Error, "can't copy '%s': " \
- "doesn't exist or not a regular file" % src
+ raise Error("can't copy '%s': " \
+ "doesn't exist or not a regular file" % src)
if os.path.isdir(dst):
dir = dst
@@ -92,7 +96,7 @@ def copy_file (src, dst, preserve_mode=1, preserve_times=1, link=None,
try:
action = _copy_action[link]
except KeyError:
- raise ValueError, "invalid value '%s' for 'link' argument" % link
+ raise ValueError("invalid value '%s' for 'link' argument" % link)
if os.path.basename(dst) == os.path.basename(src):
logger.info("%s %s to %s" % (action, src, dir))
else:
@@ -141,38 +145,40 @@ def move_file (src, dst, dryrun=False):
return dst
if not isfile(src):
- raise Error, "can't move %s: not a regular file" % src
+ raise Error("can't move %s: not a regular file" % src)
if isdir(dst):
dst = os.path.join(dst, basename(src))
elif exists(dst):
- raise Error, "can't move %s: destination %s already exists" % \
- (src, dst)
+ raise Error("can't move %s: destination %s already exists" % \
+ (src, dst))
if not isdir(dirname(dst)):
- raise Error, "can't move %s: destination %s not a valid path" % \
- (src, dst)
+ raise Error("can't move %s: destination %s not a valid path" % \
+ (src, dst))
copy_it = 0
try:
os.rename(src, dst)
- except os.error, (num, msg):
+ except os.error as xxx_todo_changeme5:
+ (num, msg) = xxx_todo_changeme5.args
if num == errno.EXDEV:
copy_it = 1
else:
- raise Error, "couldn't move %s to %s: %s" % (src, dst, msg)
+ raise Error("couldn't move %s to %s: %s" % (src, dst, msg))
if copy_it:
copy_file(src, dst)
try:
os.unlink(src)
- except os.error, (num, msg):
+ except os.error as xxx_todo_changeme4:
+ (num, msg) = xxx_todo_changeme4.args
try:
os.unlink(dst)
except os.error:
pass
- raise Error, "couldn't move %s to %s by copy/delete: " \
- "delete %s failed: %s" % (src, dst, src, msg)
+ raise Error("couldn't move %s to %s by copy/delete: " \
+ "delete %s failed: %s" % (src, dst, src, msg))
return dst