Perform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an arg
(func, args, msg=None, verbose=0, dry_run=0)
| 287 | |
| 288 | |
| 289 | def execute (func, args, msg=None, verbose=0, dry_run=0): |
| 290 | """Perform some action that affects the outside world (eg. by |
| 291 | writing to the filesystem). Such actions are special because they |
| 292 | are disabled by the 'dry_run' flag. This method takes care of all |
| 293 | that bureaucracy for you; all you have to do is supply the |
| 294 | function to call and an argument tuple for it (to embody the |
| 295 | "external action" being performed), and an optional message to |
| 296 | print. |
| 297 | """ |
| 298 | if msg is None: |
| 299 | msg = "%s%r" % (func.__name__, args) |
| 300 | if msg[-2:] == ',)': # correct for singleton tuple |
| 301 | msg = msg[0:-2] + ')' |
| 302 | |
| 303 | log.info(msg) |
| 304 | if not dry_run: |
| 305 | func(*args) |
| 306 | |
| 307 | |
| 308 | def strtobool (val): |
no test coverage detected