equal
deleted
inserted
replaced
32 |
32 |
33 def create_dir(directory): |
33 def create_dir(directory): |
34 """create a directory if it doesn't exist yet""" |
34 """create a directory if it doesn't exist yet""" |
35 try: |
35 try: |
36 makedirs(directory) |
36 makedirs(directory) |
37 print 'created directory', directory |
37 print '-> created directory %s.' % directory |
38 except OSError, ex: |
38 except OSError, ex: |
39 import errno |
39 import errno |
40 if ex.errno != errno.EEXIST: |
40 if ex.errno != errno.EEXIST: |
41 raise |
41 raise |
42 print 'directory %s already exists' % directory |
42 print '-> directory %s already exists, no need to create it.' % directory |
43 |
43 |
44 def create_symlink(source, target): |
44 def create_symlink(source, target): |
45 """create a symbolic link""" |
45 """create a symbolic link""" |
46 if exists(target): |
46 if exists(target): |
47 remove(target) |
47 remove(target) |
54 shutil.copy2(source, target) |
54 shutil.copy2(source, target) |
55 |
55 |
56 def rm(whatever): |
56 def rm(whatever): |
57 import shutil |
57 import shutil |
58 shutil.rmtree(whatever) |
58 shutil.rmtree(whatever) |
59 print 'removed %s' % whatever |
59 print '-> removed %s' % whatever |
60 |
60 |
61 def show_diffs(appl_file, ref_file, askconfirm=True): |
61 def show_diffs(appl_file, ref_file, askconfirm=True): |
62 """interactivly replace the old file with the new file according to |
62 """interactivly replace the old file with the new file according to |
63 user decision |
63 user decision |
64 """ |
64 """ |
131 def restrict_perms_to_user(filepath, log=None): |
131 def restrict_perms_to_user(filepath, log=None): |
132 """set -rw------- permission on the given file""" |
132 """set -rw------- permission on the given file""" |
133 if log: |
133 if log: |
134 log('set %s permissions to 0600', filepath) |
134 log('set %s permissions to 0600', filepath) |
135 else: |
135 else: |
136 print 'set %s permissions to 0600' % filepath |
136 print '-> set %s permissions to 0600' % filepath |
137 chmod(filepath, 0600) |
137 chmod(filepath, 0600) |
138 |
138 |
139 def confirm(question, default_is_yes=True): |
139 def confirm(question, default_is_yes=True): |
140 """ask for confirmation and return true on positive answer""" |
140 """ask for confirmation and return true on positive answer""" |
141 if default_is_yes: |
141 if default_is_yes: |