X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils.py;h=96c61dbfc95d9e94476f6707d123fcb56614dbcb;hb=73299e3d3d571ea12e5a08248420b8f93340cc0b;hp=97df03c06d818f32a878a187dfd8e8f1c3a2cb7e;hpb=9fa337542a3305a3e6efa863b92e8ff17677377b;p=dak.git diff --git a/utils.py b/utils.py index 97df03c0..96c61dbf 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ # Utility functions # Copyright (C) 2000, 2001 James Troup -# $Id: utils.py,v 1.38 2002-02-12 23:15:23 troup Exp $ +# $Id: utils.py,v 1.40 2002-03-14 14:12:04 ajt Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -63,15 +63,16 @@ def touch_file(filename): ###################################################################################### -# From reportbug -def our_raw_input(): - sys.stdout.flush() +def our_raw_input(prompt=""): + if prompt: + sys.stdout.write(prompt); + sys.stdout.flush(); try: - ret = raw_input() + ret = raw_input(); return ret except EOFError: - sys.stderr.write('\nUser interrupt (^D).\n') - raise SystemExit + sys.stderr.write('\nUser interrupt (^D).\n'); + raise SystemExit; ###################################################################################### @@ -300,7 +301,7 @@ def poolify (source, component): ###################################################################################### -def move (src, dest, overwrite = 0): +def move (src, dest, overwrite = 0, perms = 0664): if os.path.exists(dest) and os.path.isdir(dest): dest_dir = dest; else: @@ -320,10 +321,10 @@ def move (src, dest, overwrite = 0): if not os.access(dest, os.W_OK): raise cant_overwrite_exc shutil.copy2(src, dest); - os.chmod(dest, 0664); + os.chmod(dest, perms); os.unlink(src); -def copy (src, dest, overwrite = 0): +def copy (src, dest, overwrite = 0, perms = 0664): if os.path.exists(dest) and os.path.isdir(dest): dest_dir = dest; else: @@ -343,7 +344,7 @@ def copy (src, dest, overwrite = 0): if not os.access(dest, os.W_OK): raise cant_overwrite_exc shutil.copy2(src, dest); - os.chmod(dest, 0664); + os.chmod(dest, perms); ######################################################################################