cppcheckdata: if 'import pathlib' fails then print a proper error message that explains how user can solve the problem.
This commit is contained in:
parent
54478bd6d3
commit
a5e0a9fe08
|
@ -9,8 +9,25 @@ License: No restrictions, use this as you need.
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pathlib
|
|
||||||
import sys
|
import sys
|
||||||
|
try:
|
||||||
|
import pathlib
|
||||||
|
except ImportError:
|
||||||
|
message = "Failed to load pathlib. Upgrade python to 3.x or install pathlib with 'pip install pathlib'."
|
||||||
|
error_id = 'pythonError'
|
||||||
|
if '--cli' in sys.argv:
|
||||||
|
msg = { 'file': '',
|
||||||
|
'linenr': 0,
|
||||||
|
'column': 0,
|
||||||
|
'severity': 'error',
|
||||||
|
'message': message,
|
||||||
|
'addon': 'cppcheckdata',
|
||||||
|
'errorId': error_id,
|
||||||
|
'extra': ''}
|
||||||
|
sys.stdout.write(json.dumps(msg) + '\n')
|
||||||
|
else:
|
||||||
|
sys.stderr.write('%s [%s]\n' % (message, error_id))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
|
|
Loading…
Reference in New Issue