source: asadb/util/misc.py

fysm-4-1space-accessstablestagetest-hooks
Last change on this file was 595915c, checked in by Alex Dehnert <adehnert@…>, 15 years ago

Add a mkdir -p equivalent

  • Property mode set to 100644
File size: 547 bytes
Line 
1import traceback
2import os, errno
3
4def log_and_ignore_failures(logfile):
5    def decorator(f):
6        def new_f(*args, **kwargs):
7            try:
8                return f(*args, **kwargs)
9            except Exception:
10                fd = open(logfile, 'a')
11                traceback.print_exc(file=fd, )
12                fd.close()
13        return new_f
14    return decorator
15
16def mkdir_p(path):
17    try:
18        os.makedirs(path)
19    except OSError as exc: # Python >2.5
20        if exc.errno == errno.EEXIST:
21            pass
22        else: raise
Note: See TracBrowser for help on using the repository browser.