Skip to content

Commit

Permalink
Re #7547. Move dgs_utils.py to python v2 API.
Browse files Browse the repository at this point in the history
This was harder than foreseen because of all the unicode around here,
which our Python API really doesn't like!
  • Loading branch information
RussellTaylor committed Jul 28, 2013
1 parent 39ecb10 commit 9bbf31b
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Forced to use version 1 API.
IS_IN_MANTIDPLOT = False
try:
import mantidplot
from MantidFramework import *
mtd.initialise(False)
from mantidsimple import *
import mantidplot

from mantid.kernel import config
from mantid.api import AnalysisDataService
from mantid.simpleapi import LoadEmptyInstrument
IS_IN_MANTIDPLOT = True
except:
pass
Expand All @@ -26,15 +23,14 @@ def __init__(self, inst_name):

def _load_param_file(self, inst_name):
InstrumentParameters.instrument_name = inst_name
ws_name = "__emptyInst_" + inst_name
if IS_IN_MANTIDPLOT:
idf_loc = ConfigService().getInstrumentDirectory()
idf_loc = config.getInstrumentDirectory()
idf_pattern = os.path.join(idf_loc, "%s_Definition*.xml") % inst_name
import glob
idf_files = glob.glob(idf_pattern)
output = LoadEmptyInstrument(Filename=idf_files[0],
OutputWorkspace=ws_name)
InstrumentParameters._instrument = output.workspace().getInstrument()
emptyInst = LoadEmptyInstrument(Filename=str(idf_files[0]))
InstrumentParameters._instrument = emptyInst.getInstrument()
AnalysisDataService.remove(str(emptyInst)) # Don't need to keep workspace

def _self_check(self):
if self._instrument is None:
Expand Down

0 comments on commit 9bbf31b

Please sign in to comment.