Skip to content

Commit db9e15d

Browse files
authored
Fix crash when failing to write schema (#3)
1 parent ff068e0 commit db9e15d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

ipb_homework_checker/schema_manager.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,18 @@ def __init__(self, file_name):
6262
self.__validated_yaml = self.__schema.validate(contents)
6363
except SchemaError as exc:
6464
sys.exit(exc.code)
65-
# Write the schema every time we run this code.
66-
with open(SCHEMA_FILE, 'w') as outfile:
67-
str_dict = SchemaManager.__sanitize_value(
68-
self.__schema._schema)
69-
yaml.dump(str_dict, outfile)
65+
# Write the schema every time we run this code while developing. We
66+
# don't want to run this when the package is installed as this we won't
67+
# have the permission. This is intended to keep the schema file up to
68+
# date when we add new stuff to it.
69+
try:
70+
with open(SCHEMA_FILE, 'w') as outfile:
71+
str_dict = SchemaManager.__sanitize_value(
72+
self.__schema._schema)
73+
yaml.dump(str_dict, outfile)
74+
except OSError:
75+
log.debug(
76+
"Cannot write schema file. We only use this while developing.")
7077

7178
def __to_simple_list(commented_seq):
7279
simple_list = []

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from setuptools import setup
77
from setuptools.command.install import install
88

9-
VERSION_STRING = '0.0.4'
9+
VERSION_STRING = '0.0.5'
1010

1111
PACKAGE_NAME = 'ipb_homework_checker'
1212

0 commit comments

Comments
 (0)