Python Scripting Guide
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
02-06-2015 05:06 AM
Hi everybody!
I've recently update EXOS to 15.6. and I really would love to write some python scripts. Honestly, I'm not into programming actually. I just write python scripts sometimes.
So, I've read EXOS 15.6 User Guide, but there are few information about python scripting. Аt least for me) Does anybody give me some examples or maybe guides, articles, posts or something about it?
Thanks for help!
I've recently update EXOS to 15.6. and I really would love to write some python scripts. Honestly, I'm not into programming actually. I just write python scripts sometimes.
So, I've read EXOS 15.6 User Guide, but there are few information about python scripting. Аt least for me) Does anybody give me some examples or maybe guides, articles, posts or something about it?
Thanks for help!
26 REPLIES 26
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
02-06-2015 10:42 AM
Hi eyeV,
One of my findings which you might come and nice to know:
If you want to combine python scripting with Universal Port triggers you can do the following trick which worked for me. Example creating a python script which will run every minute.
1) Create the python script HelloWorld.py
Switch # vi HelloWorld.py
2) Because profile can trigger only CLI, you need to create a profile and just insert the following command (assuming you saved the python file to HelloWorld.py)
Switch # create upm profile HelloWorld
Start typing the profile and end with a . as the first and the only character on a line.
Use - edit upm profile - for block mode capability
run script HelloWorld.py
.
( Note the dot in the end)
3) Add the trigger to run the profile every minute starting from the next minute
create upm timer HelloTimer
configure upm timer "HelloTimer" after 60 every 60
configure upm timer "HelloTimer" profile "HelloWorld"
4) You can delete the timer
delete upm timer "HelloTimer"
Hope it helps
Sotiris
One of my findings which you might come and nice to know:
If you want to combine python scripting with Universal Port triggers you can do the following trick which worked for me. Example creating a python script which will run every minute.
1) Create the python script HelloWorld.py
Switch # vi HelloWorld.py
2) Because profile can trigger only CLI, you need to create a profile and just insert the following command (assuming you saved the python file to HelloWorld.py)
Switch # create upm profile HelloWorld
Start typing the profile and end with a . as the first and the only character on a line.
Use - edit upm profile
run script HelloWorld.py
.
( Note the dot in the end)
3) Add the trigger to run the profile every minute starting from the next minute
create upm timer HelloTimer
configure upm timer "HelloTimer" after 60 every 60
configure upm timer "HelloTimer" profile "HelloWorld"
4) You can delete the timer
delete upm timer "HelloTimer"
Hope it helps
Sotiris
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
02-06-2015 06:44 AM
Hi,
A guide will be posted soon here. It'll give a brief introduction to python, how you can use the scripting capability with EXOS, and some other features we are introducing in 15.7 (you sense the teasing here ;)).
In the meantime, I'd encourage you to start learning Python 2.7 and the standard library. That's very easy and powerful. There're so many books, article, it's difficult to point to one specific.
With EXOS 15.6, you can use exsh library to interact with EXOS.
import exsh
exsh.clicmd(cmd, capture=False, xml=False, args=None)
cmd is a valid EXOS CLI cmd.
optional:
capture can be True or False, if True it will return the command output in text.
xml can be True or False. if True it will return the command output in xml.
args are whatever parameter needed for the command
I'll see how we can manage to share on a specific space some little scripts for learning purposes.
So stay tuned for the Guide, it's coming.
A guide will be posted soon here. It'll give a brief introduction to python, how you can use the scripting capability with EXOS, and some other features we are introducing in 15.7 (you sense the teasing here ;)).
In the meantime, I'd encourage you to start learning Python 2.7 and the standard library. That's very easy and powerful. There're so many books, article, it's difficult to point to one specific.
With EXOS 15.6, you can use exsh library to interact with EXOS.
import exsh
exsh.clicmd(cmd, capture=False, xml=False, args=None)
cmd is a valid EXOS CLI cmd.
optional:
capture can be True or False, if True it will return the command output in text.
xml can be True or False. if True it will return the command output in xml.
args are whatever parameter needed for the command
I'll see how we can manage to share on a specific space some little scripts for learning purposes.
So stay tuned for the Guide, it's coming.
