0

In a mule project, I have a Python script component that needs to access a cert.pem file.

In AnyPointStudio I've placed it in the ./src/main/resources/ folder. When I create a Mule Deployable Archive, it ends up in the ./target/classes/ folder.

What path should I specify to access this file.

I've tried

path = 'cert.pem'

## And ## 

cwd = os.getcwd()
path = os.path.join(cwd, 'classes','cert.pem')
path = os.path.join(cwd, 'target','classes','cert.pem')
path = os.path.join(cwd, 'src','main', 'resources','cert.pem')

None of which work.
Any advice?

Side Question: In CloudHub simple print() statements in the .py script don't log, I tried log("message") but that raised an exception. Any ideas?

The Pulsing Eye
  • 161
  • 3
  • 11

2 Answers2

0

I don't know python, but the file should just be available on the classpath. So everything in src/main/resources will be available on the classpath. So 'src/main/resources/cert.pem' should just be referenced as 'cert.pem'

Ryan Carter
  • 11,441
  • 2
  • 20
  • 27
0

So, at least with Python, the classes path isn't the same as working directory path. But I did eventually figure out how to get at the classes path using the MULE_HOME env variable.

base = os.path.join(os.getenv('MULE_HOME'), 'apps', 'your-app-name', 'classes')

Then you can get the certfile like this:

certfile = os.path.join(base, 'cert.pem')
The Pulsing Eye
  • 161
  • 3
  • 11