Skip to content

Commit

Permalink
Changed import try/catch for compatibility with python2
Browse files Browse the repository at this point in the history
  • Loading branch information
progwriter committed Oct 4, 2017
1 parent 45776f9 commit 16317b2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/sol/opt/gurobiwrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ from __future__ import division, print_function
import sys

from sol.utils.const import ERR_NO_GUROBI
from sol.utils.logger import logger

# Deal with different package names based on the version
try:
from gurobi import *
except (ImportError, ModuleNotFoundError) as e:
except ImportError as e:
try:
from gurobipy import *
except (ImportError, ModuleNotFoundError) as e:
print(ERR_NO_GUROBI)
raise e
except ImportError as e:
logger.error(ERR_NO_GUROBI)
logger.error('Optimization capabilities will not be available!')

import warnings

Expand All @@ -44,7 +45,6 @@ from cpython cimport bool
from sol.utils.exceptions import SOLException, InvalidConfigException
from sol.topology.traffic cimport TrafficClass
from sol.topology.topologynx cimport Topology
from sol.utils.logger import logger
from sol.opt.varnames cimport xp, al, be, bn, bp
from sol.opt import NetworkCaps
from sol.utils.const import *
Expand Down

0 comments on commit 16317b2

Please sign in to comment.