Transport Celonis CTP file via Python

#1

Hello Team,

I am doing the use case to import transport file of Celonis CTP via Python and after importing i have to select the project and load the data source and map the tables and do import of tables via python.

Steps I have done :-

  1. Established the connection to Celonis :

            from celonis_tools.api import CelonisSession
            from celonis_tools.model import *
    
            with CelonisSession("Url", User_Name" , api_token="XXXX",
                     api_secret="XXXX") as session:
    
  2. Importing the file to project folder:

             t = Transport.import_transport("Python Testing","C:\\Users\\Parimala\\Desktop","Test123")
             t._commit_import()
    

Throwing below error after running the code:

Traceback (most recent call last):

File “”, line 9, in
t = Transport.import_transport(“Python Testing”,“C:\Users\Parimala\Desktop”,“Test123”)

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\model\folder.py”, line 464, in import_transport
ret = cls.api.post(“queue”, password=password, filename=filename)

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\api.py”, line 105, in post
with open(filename, “rb”) as f:

PermissionError: [Errno 13] Permission denied: ‘C:\Users\Parimala\Desktop’

Issue is causing while importing transport,I have opened Python editor with administrative rights but still the same issue exists.

Please suggest if anything I am missing to test the use case I have picked.

Many thanks in advance.

Thanks,
Parimala N

#2

Hey Parimala,

I’d suggest:

  1. placing your file in another folder, e.g. Downloads, and even better, in a ./data folder in your project directory
  2. specifying the full file path, e.g. r"C:\Users\d.holovatyi\Documents\work\code\TRANSPORT_NAME.CTP". Also note the letter r before the string - this means raw string in Python and lets you use single backslashes \ instead of double \.

Hope this helps!
Denys

1 Like
#3

Hey Denys,

I have tried with all possibilities but it was problem with import of Transport package.
May i know if i am doing correctly.
Transport_Code.txt (473 Bytes)

Error :

t._commit_import()

Traceback (most recent call last):

File “”, line 12, in
t = Transport.import_transport(Project(“89071eaa-ec32-4b5c-bdfd-afa3fdc855b2”),r"C:\Users\Parimala\Desktop\CE_TRANSPORT_testtransport.CTP",“Celonis1234”)

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\model\resource.py”, line 145, in init
self.load()

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\model\resource.py”, line 197, in load
ret = self.api.get(self.data[“id”], *args, **kw)

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\api.py”, line 70, in get
ret = self.session.get(url, params=kw or None)

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\sessions.py”, line 521, in get
return self.request(‘GET’, url, **kwargs)

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\sessions.py”, line 508, in request
resp = self.send(prep, **send_kwargs)

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\sessions.py”, line 618, in send
r = adapter.send(request, **kwargs)

File “C:\Users\Parimala\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\adapters.py”, line 506, in send
raise SSLError(e, request=request)

SSLError: HTTPSConnectionPool(host=‘host.com’, port=1234): Max retries exceeded with url: /api/projects/nb2v312gh3g-v312v3v123-bnbn3b12/ (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘ssl3_get_record’, ‘wrong version number’)],)”,),))

Is my argument passing for project id in import_transport is correct?

Thanks,
Parimala

#4

Hi Parimala,

depending on your server and network setup it might be not possible to check SSL certificates - you could try specifying

with CelonisSession("Url", User_Name" , api_token="XXXX", api_secret="XXXX", verify=False) as session:

Cheers,
Denys

#5

Hi Denys,

I am using with verify = False also, its throwing SSL error.

SSLError: HTTPSConnectionPool(host=‘dssfsdjfsdjfjdshfj’, port=9000): Max retries exceeded with url: /api/projects/89071eaa-ec32-4b5c-bdfd-afa3fdc855b2/ (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘ssl3_get_record’, ‘wrong version number’)],)”,),))

And my another doubt is in my code is that how we have to pass for project id?

Thanks,
Parimala

#6

Hi Parimala,

to speficy your project you could either do

p = Project(“YOUR_PROJECT_ID”) # this one is more robust or
p = Project.find(“name”, “YOUR_PROJECT_NAME”).first() # this one is more flexible if you delete/ re-create a dev project with the same name

Hope it helps!

Cheers,
Denys