mirror of https://github.com/ARMmbed/mbed-os.git
Added exception handling for prettytable and serial modules - gracefuly handle missing imports.
parent
41a7dada69
commit
0725b33375
|
|
@ -15,8 +15,14 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
"""
|
||||
|
||||
# Check if 'serial' module is installed
|
||||
try:
|
||||
from serial import Serial
|
||||
except ImportError, e:
|
||||
print "Error: Can't import 'serial' module: %s"% e
|
||||
exit(-1)
|
||||
|
||||
from optparse import OptionParser
|
||||
from serial import Serial
|
||||
from time import sleep
|
||||
from sys import stdout
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,20 @@ File format example: muts_all.json
|
|||
|
||||
"""
|
||||
|
||||
# Check if 'prettytable' module is installed
|
||||
try:
|
||||
from prettytable import PrettyTable
|
||||
except ImportError, e:
|
||||
print "Error: Can't import 'prettytable' module: %s"% e
|
||||
exit(-1)
|
||||
|
||||
# Check if 'serial' module is installed
|
||||
try:
|
||||
from serial import Serial
|
||||
except ImportError, e:
|
||||
print "Error: Can't import 'serial' module: %s"% e
|
||||
exit(-1)
|
||||
|
||||
import sys
|
||||
import json
|
||||
import optparse
|
||||
|
|
@ -77,7 +91,6 @@ import pprint
|
|||
import re
|
||||
import os
|
||||
from types import ListType
|
||||
from prettytable import PrettyTable
|
||||
|
||||
from os.path import join, abspath, dirname, exists, basename
|
||||
from shutil import copy
|
||||
|
|
|
|||
Loading…
Reference in New Issue