Skip to content

Commit

Permalink
Added more flexible logic to find location of Eclipse API dlls (and e…
Browse files Browse the repository at this point in the history
…nabled searching for libraries on D drive locations) (#2)

Customer added logic to search for ESAPI DLLs in generic manner, includes D drive as possible location.
  • Loading branch information
clmw83 authored and fizxmike committed Oct 15, 2018
1 parent 75b59b7 commit 2c9e157
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions pyesapi/__init__.py
@@ -1,14 +1,30 @@
import sys
import sys, os
import pythoncom
pythoncom.CoInitialize() # enforces single thread apartment mode

# add 15.5 paths
sys.path.append("C:\\Program Files (x86)\\Varian\\RTM\\15.5\\esapi\\API")
sys.path.append("C:\\Program Files (x86)\\Varian\\RTM\\15.5\\ExternalBeam")

# add 15.6 paths
sys.path.append("C:\\Program Files (x86)\\Varian\\RTM\\15.6\\esapi\\API")
sys.path.append("C:\\Program Files (x86)\\Varian\\RTM\\15.6\\ExternalBeam")
rpaths=[os.path.join("esapi","API"),"ExternalBeam"]
versions=["15.5","15.6"]
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

# Add paths that exist
paths=[]
spaths=[]
for drive in drives:
for ver in versions:
for rp in rpaths:
p=os.path.join(drive,os.sep,base,ver,rp)
spaths.append(p)
if os.path.isdir(p):
paths.append(p)

if len(paths) < 2:
raise Exception("Did not find required library paths! Searched for:\n %s"%(",\n".join(spaths)))
if len(paths) > 2:
print("WARNING: Found multiple possible VMS dll locations:\n %s"%(",\n".join(spaths)))

for p in paths:
sys.path.append(p)

import clr # pip install pythonnet

Expand Down

0 comments on commit 2c9e157

Please sign in to comment.