Skip to content

Commit f990197

Browse files
committed
Update error type
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 8f49bf8 commit f990197

File tree

5 files changed

+7
-17
lines changed

5 files changed

+7
-17
lines changed

src/attributecode/api.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ def request_license_data(api_url, api_key, license_key):
6969
msg = (u"Authorization denied. Invalid '--api_key'. "
7070
u"License generation is skipped.")
7171
errors.append(Error(ERROR, msg))
72-
"""
73-
The invalid license is handled
74-
75-
else:
76-
# Since no api_url/api_key/network status have
77-
# problem detected, it yields 'license' is the cause of
78-
# this exception.
79-
msg = u"Invalid 'license': %s" % license_key
80-
errors.append(Error(ERROR, msg))
81-
"""
8272
except Exception as e:
8373
errors.append(Error(ERROR, str(e)))
8474

src/attributecode/gen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def check_about_resource_filename(arp):
112112
if invalid_chars(arp):
113113
msg = ("Invalid characters present in 'about_resource' "
114114
"field: " + arp)
115-
return (Error(CRITICAL, msg))
115+
return (Error(ERROR, msg))
116116
return ''
117117

118118

@@ -184,7 +184,7 @@ def load_inventory(location, from_attrib=False, base_dir=None, scancode=False, r
184184
for f in required_fields:
185185
if f not in fields:
186186
msg = "Required field: %(f)r not found in the <input>" % locals()
187-
errors.append(Error(ERROR, msg))
187+
errors.append(Error(CRITICAL, msg))
188188
return errors, abouts
189189
afp = fields.get(model.About.ABOUT_RESOURCE_ATTR)
190190

src/attributecode/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def validate_field_name(name):
720720
if not is_valid_name(name):
721721
msg = ('Field name: %(name)r contains illegal name characters '
722722
'(or empty spaces) and is ignored.')
723-
return Error(CRITICAL, msg % locals())
723+
return Error(ERROR, msg % locals())
724724

725725

726726
class License:
@@ -954,7 +954,7 @@ def hydrate(self, fields):
954954
if illegal_name_list:
955955
msg = ('Field name: %(illegal_name_list)r contains illegal name characters '
956956
'(or empty spaces) and is ignored.')
957-
errors.append(Error(CRITICAL, msg % locals()))
957+
errors.append(Error(ERROR, msg % locals()))
958958
return errors
959959

960960
def process(self, fields, about_file_path, running_inventory=False,

tests/test_gen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_check_about_resource_filename(self):
6969
arp2 = '/test/t!est.c'
7070
msg = ("Invalid characters present in 'about_resource' "
7171
"field: " + arp2)
72-
expected2 = Error(CRITICAL, msg)
72+
expected2 = Error(ERROR, msg)
7373
result1 = gen.check_about_resource_filename(arp1)
7474
result2 = gen.check_about_resource_filename(arp2)
7575
assert result1 == ''
@@ -103,7 +103,7 @@ def test_load_inventory_with_errors(self):
103103
base_dir = get_temp_dir()
104104
errors, abouts = gen.load_inventory(location, base_dir=base_dir)
105105
expected_errors = [
106-
Error(CRITICAL, "Field name: ['confirmed copyright'] contains illegal name characters (or empty spaces) and is ignored."),
106+
Error(ERROR, "Field name: ['confirmed copyright'] contains illegal name characters (or empty spaces) and is ignored."),
107107
Error(INFO, 'Field about_resource: Path'),
108108
Error(INFO, "Field ['resource', 'test'] is a custom field.")
109109
]

tests/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ def test_About_rejects_non_ascii_names_and_accepts_unicode_values(self):
582582
test_file = get_test_loc('test_model/parse/non_ascii_field_name_value.about')
583583
a = model.About(test_file)
584584
expected = [
585-
Error(CRITICAL, "Field name: ['mat\xedas'] contains illegal name characters (or empty spaces) and is ignored.")
585+
Error(ERROR, "Field name: ['mat\xedas'] contains illegal name characters (or empty spaces) and is ignored.")
586586
]
587587
assert expected == a.errors
588588

0 commit comments

Comments
 (0)