Radek Krejci | b2feaac | 2017-09-21 13:16:54 +0200 | [diff] [blame] | 1 | """ |
| 2 | Manipulation with the YANG schemas. |
| 3 | File: schemas.py |
| 4 | Author: Radek Krejci <rkrejci@cesnet.cz> |
| 5 | """ |
| 6 | |
Radek Krejci | 67c922d | 2017-09-21 13:56:41 +0200 | [diff] [blame] | 7 | import os |
| 8 | import errno |
| 9 | |
| 10 | from liberouterapi import config |
Radek Krejci | b2feaac | 2017-09-21 13:16:54 +0200 | [diff] [blame] | 11 | |
| 12 | from .error import NetopeerException |
| 13 | |
Radek Krejci | d1fa33b | 2017-10-17 14:41:36 +0200 | [diff] [blame] | 14 | INVENTORY = config['netopeer'].get('usersdata_path', './') |
Radek Krejci | 2b9bbc2 | 2017-09-21 13:20:48 +0200 | [diff] [blame] | 15 | |
Radek Krejci | b2feaac | 2017-09-21 13:16:54 +0200 | [diff] [blame] | 16 | def inventory_check(path): |
| 17 | try: |
| 18 | os.makedirs(path, mode=0o750) |
| 19 | except OSError as e: |
| 20 | if e.errno == errno.EEXIST and os.path.isdir(path): |
| 21 | pass |
| 22 | elif e.errno == errno.EEXIST: |
| 23 | raise NetopeerException('User\'s inventory (' + path + ') already exists and it\'s not a directory.') |
| 24 | else: |
| 25 | raise NetopeerException('Unable to use inventory path ' + path +' (' + str(e) + ').') |
| 26 | |