Added exception handling for prettytable and serial modules - gracefuly handle missing imports.

pull/401/head^2
Przemek Wirkus 2014-07-11 11:24:03 +01:00
parent 41a7dada69
commit 0725b33375
2 changed files with 21 additions and 2 deletions

View File

@ -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

View File

@ -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