VarianAPIs / PyESAPI

Python interface to Eclipse Scripting API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyESAPI: Getting Started

sama2689 opened this issue · comments

I am trying the first line of the getting started workshop script, but right away I am getting an error. The notebook says "Create one instance of the eclipse scripting application" by which I am assuming (could this be clarified?) they mean to open external beam planning and then open tools>scripts.

This is what I have done and I run

import pyesapi
import atexit
app = pyesapi.CustomScriptExecutable.CreateApplication('python_demo')

but then get the error

TpsNetInitializationException: [10/8/2021 10:46 AM] TPS.NET ApplicationNonAppFrame: Initialization FAILED. Here is the initialization log:
[10/8/2021 10:46 AM] TPS.NET ApplicationNonAppFrame: START initializtion, m_initCounter=1, status=NotInitialized.
[10/8/2021 10:46 AM] TPS.NET ApplicationNonAppFrame: Only one Application object is supported at a time.

   at VMS.TPS.Common.Model.ApplicationInitGuard.ThrowInitError(Exception innerException)
   at VMS.TPS.Common.Model.ApplicationInitGuard.Begin()
   at VMS.TPS.Common.Model.ApplicationInitGuard.InitializeApplicationImpl(Delegate initDelegate, Object[] args)
   at VMS.TPS.Common.Model.ApplicationNonAppFrame.Initialize(IStartupParameters startupParameters, IApplicationContextInfo applicationContextInfo)
   at VMS.TPS.Common.Model.API.Application.CreateApplicationCommon(String scriptName, Func`2 createExecutionGuardFunc)

So I assume this means that the scripting application is an instance too many and needs to be closed, so I close out and run the same, but again I get the same error. When I run without ARIA or eclipse open in the background, I instead get the error

app = pyesapi.CustomScriptExecutable.CreateApplication('python_demo')

ArgumentNullException: Value cannot be null.
 at System.Threading.Monitor.Enter(Object obj)
 at VMS.TPS.Common.Model.ApplicationBase.remove_OnDataReload(Action value)
 at VMS.TPS.Common.Model.StructureCodeTable.ResetInstance()
 at VMS.TPS.Common.Model.ApplicationBase.UninitializeDataObjectCache()
 at VMS.TPS.Common.Model.ApplicationNonAppFrame._Dispose()
 at VMS.TPS.Common.Model.ApplicationNonAppFrame.Dispose(Boolean A_0)
 at VMS.TPS.Common.Model.ApplicationBase.Dispose()
 at VMS.TPS.Common.Model.API.Application.CreateApplicationCommon(String scriptName, Func`2 createExecutionGuardFunc)

I think the script must be having trouble finding the Varian dlls, however these are stored in C:\Program Files (x86)\Varian\RTM\15.6\esapi\API which is in my PYTHONPATH variable.

you might try looking into current ESAPI version which is in init.py file of your pyesapi package:

ESAPI_PATH = os.environ.get('ESAPI_PATH')

if ESAPI_PATH is not None:
    # optionally set ESAPI_PATH env var with location of DLLs
    sys.path.append(ESAPI_PATH)
else:
    # do some soul searching
    rpaths = [os.path.join("esapi", "API"), "ExternalBeam"]
    # versions = ["15.5", "15.6"] # this was originally in the file I changed it to 17.0 version to avoide doubles
    versions = ["17.0"]
    base = os.path.join("Program Files (x86)", "Varian", "RTM")
    drives = ["C:", "D:"]  # Could potentially list local drives, but Eclispe should be on C or D

For anaconda the file location is sth like:
...\anaconda3\envs\pyesapi38\lib\site-packages\pyesapi

The other question would be if you have .NET installed on your system?

WhGetting this error while installing pyesapi

C:\Users\varian.RADONC>pip install https://api.github.com/repos/VarianAPIs/PyESAPI/tarball
Defaulting to user installation because normal site-packages is not writeable
Collecting https://api.github.com/repos/VarianAPIs/PyESAPI/tarball
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)'))': /VarianAPIs/PyESAPI/legacy.tar.gz/refs/heads/master
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)'))': /VarianAPIs/PyESAPI/legacy.tar.gz/refs/heads/master
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)'))': /VarianAPIs/PyESAPI/legacy.tar.gz/refs/heads/master
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)'))': /VarianAPIs/PyESAPI/legacy.tar.gz/refs/heads/master
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)'))': /VarianAPIs/PyESAPI/legacy.tar.gz/refs/heads/master
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='codeload.github.com', port=443): Max retries exceeded with url: /VarianAPIs/PyESAPI/legacy.tar.gz/refs/heads/master (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)')))