intersystems-community / embedded-python-bugreports

Please submit bugs you found in Embedded Python here
0 stars 1 forks source link

Python fails with exit code 3 #5

Open daimor opened 1 year ago

daimor commented 1 year ago

When using IPM

Empty IPM Module, like below, with nothing at all

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
  <Document name="demo.ZPM">
    <Module>
      <Name>demo</Name>
      <Version>1.0.0</Version>
      <Keywords>demo</Keywords>
      <Description>demo</Description>
      <Packaging>module</Packaging>
      <SourcesRoot>src</SourcesRoot>
    </Module>
  </Document>
</Export>

And python code, which installs it

import iris

iris.cls("%ZPM.PackageManager").Shell("load /home/irisowner/app -v")
print('done')

Crashes, right after the execution in %ZPM, with exit code 3, will not print done

grongierisc commented 1 year ago

workaround to load zpm libs :

credit to @daimor : https://github.com/intersystems-community/zpm-dockerhub/blob/master/iris_ipm.py

def ipm(cmd, *args):
    """
    Executes shell command with IPM:

    Parameters
    ----------
    cmd : str
        The command to execute

    Examples
    --------
    `ipm('help')`
    `ipm('load /home/irisowner/dev -v')`
    `ipm('install webterminal')`
    """

    import multiprocessing

    def shell(cmd, status):
        import iris

        status.put(True)

        res = iris.cls("%ZPM.PackageManager").Shell(cmd)
        print('')
        if res != 1:
            status.get()
            status.put(False)

    manager = multiprocessing.Manager()
    status = manager.Queue()
    process = multiprocessing.Process(
        target=shell,
        args=(
            cmd,
            status,
        ),
    )
    process.start()
    process.join()
    return status.get()
grongierisc commented 1 year ago

can't be reproduce on :

iris @ https://github.com/grongierisc/iris-embedded-python-wrapper/releases/download/v0.0.4/iris-0.0.4-py3-none-any.whl
>>> iris.cls("%ZPM.PackageManager").Shell("load /irisdev/app/test -v")

Load started on 09/08/2023 14:02:25
Loading file /irisdev/app/test/module.xml as xml
Imported document: demo.ZPM
Load finished successfully.

Skipping preload - directory does not exist.
Load started on 09/08/2023 14:02:25
Loading file /irisdev/app/test/module.xml as xml
Imported document: demo.ZPM
Load finished successfully.

Loading demo in process 3782
[IRISAPP|demo]  Reload START (/irisdev/app/test/)
Skipping preload - directory does not exist.
Load of directory started on 09/08/2023 14:02:25
Loading file /irisdev/app/test/tests/test.cls as cls
Imported class: test.tests.test
Load finished successfully.

[IRISAPP|demo]  Reload SUCCESS
[demo]  Module object refreshed.
[IRISAPP|demo]  Validate START
[IRISAPP|demo]  Validate SUCCESS
[IRISAPP|demo]  Compile START
[IRISAPP|demo]  Compile SUCCESS
[IRISAPP|demo]  Activate START
[IRISAPP|demo]  Configure START
[IRISAPP|demo]  Configure SUCCESS
Studio project created/updated: demo.PRJ
[IRISAPP|demo]  Activate SUCCESS1
grongierisc commented 1 year ago

@alexatwoodhead can you try reproduce it on windows ?

alexatwoodhead commented 1 year ago

I can get the command iris.cls("%ZPM.PackageManager").Shell("load [ windows dir with module ]") to run directly, successfully. The "def ipm" had issues on my local windows, but maybe this file is only required within the docker appliance ( Ubuntu ).