Skip to content

Commit 05cfac1

Browse files
committed
#22 update message error when iop is not init
1 parent 270e9c6 commit 05cfac1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/iop/_utils.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def setup(path:str = None):
2828
# for retrocompatibility load grongier.pex
2929
path = pkg_resources.resource_filename('grongier', 'cls')
3030

31-
_Utils.raise_on_error(iris.cls('%SYSTEM.OBJ').LoadDir(path,'cubk',"*.cls",1))
31+
if path:
32+
_Utils.raise_on_error(iris.cls('%SYSTEM.OBJ').LoadDir(path,'cubk',"*.cls",1))
3233

3334
@staticmethod
3435
def register_component(module:str,classname:str,path:str,overwrite:int=1,iris_classname:str='Python'):
@@ -47,10 +48,12 @@ def register_component(module:str,classname:str,path:str,overwrite:int=1,iris_cl
4748
:type iris_classname: str
4849
:return: The return value is a string.
4950
"""
50-
path = os.path.normpath(path)
51-
# get the absolute path of the folder
52-
path = os.path.abspath(path)
53-
return iris.cls('Grongier.PEX.Utils').dispatchRegisterComponent(module,classname,path,overwrite,iris_classname)
51+
path = os.path.abspath(os.path.normpath(path))
52+
try:
53+
iris.cls('IOP.Utils').dispatchRegisterComponent(module,classname,path,overwrite,iris_classname)
54+
except RuntimeError as e:
55+
# New message error : Make sure the iop package is installed in iris
56+
raise RuntimeError("Make sure the iop package is installed in iris eg: iop --init.") from e
5457

5558
@staticmethod
5659
def register_folder(path:str,overwrite:int=1,iris_package_name:str='Python'):
@@ -333,7 +336,7 @@ def register_production(production_name,xml):
333336
production_name = production_name.split('.')[-1]
334337
stream = _Utils.string_to_stream(xml)
335338
# register the production
336-
_Utils.raise_on_error(iris.cls('Grongier.PEX.Utils').CreateProduction(package,production_name,stream))
339+
_Utils.raise_on_error(iris.cls('IOP.Utils').CreateProduction(package,production_name,stream))
337340

338341
@staticmethod
339342
def export_production(production_name):
@@ -348,7 +351,7 @@ def postprocessor(path, key, value):
348351
return key, ''
349352
return key, value
350353
# export the production
351-
xdata = iris.cls('Grongier.PEX.Utils').ExportProduction(production_name)
354+
xdata = iris.cls('IOP.Utils').ExportProduction(production_name)
352355
# for each chunk of 1024 characters
353356
string = _Utils.stream_to_string(xdata)
354357
# convert the xml to a dictionary

0 commit comments

Comments
 (0)