Well, my problem in Python, is that I need to know the PATH of the SDK in order to use it.
I am using the SDK to have access to the data which is inside a database. Once I have the data I want to use Julia.
How do I import “sys” and “os” (which are from Python) into Julia?
With py"""
I assume you could add something to the python path using PyCall, but I am afraid I again don’t understand what you want to do.
It would be greatly helpful if you could describe as clearly as possible what is it exactly that you are trying to do so people would be able to recommend the best way to do that in Julia.
PyCall is what you need to run python code from Julia. If your goal is to call some python function from this splunk sdk you should indeed use PyCall.
“splunk-sdk-python” is in this PATH: ~/splunk-sdk-python
My script is in this PATH: ~/roc/my_script.py
When I execute it, it says that it cannot find the “splunklib”. So with that piece of code I am giving the PATH where the SDK is located.
All the python code is:
import sys, os
pa = os.path.join(os.path.abspath(os.path.join('', os.pardir)), "splunk-sdk-python")
sys.path.insert(0, pa)
import splunklib.client as client
HOST = "localhost"
PORT = 8089
USERNAME = "admin"
PASSWORD = "passwdSPLUNK"
# Create a Service instance and log in
service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD)
# Print installed apps to the console to verify login
for app in service.apps:
print (app.name)
I guess I have to use a push! (LOAD_PATH, string(@__DIR__) or something like that.