News:

HOT TIP! Commands and groups can be copied and pasted directly from your command editor to the forum, and vice versa. This makes sharing command XML on the forum much easier!

Main Menu

Call a Python script from VoxCommando

Started by SaScot007, March 16, 2012, 04:23:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SaScot007

Hi, I am trying to run a Python script from voxcommando

This is the command that I am trying to run:

c:\python32\python.exe s:\prog\VC_RunPython.py alpha red

This command works OK from the DOS prompt, but when I set it up from VC I dont think it passes the parameters correctly to Python
  - or I don't understand how to do it !!

These are the parts of the command line:
c:\python32\python.exe          << this is the python executable
s:\prog\VC_RunPython.py        << this is the name of the python script
alpha                                     << this is runtime parameter 1 (using payload list 1)
red                                       << this is runtime parameter 2 (using payload list 2)


This is the Python script:  all it does is write out to a file the values of the parameters it received
----------------------------------------------------------------------------------
#s:\prog\VC_RunPython.py
import sys
import datetime

now = str(datetime.datetime.now())

myfile = open(r's:\prog\test.txt','a')
myfile.write('\nStarting ... '+now+'\n')

print ('ProgramName is: ' + sys.argv[0])
for i in range(len(sys.argv)):
    writeString = 'Parameter ['+str(i)+']:  ' +sys.argv +'\n'
    print(writeString)
    myfile.write(writeString)
myfile.close()
------------------------------------------------------------------------------------------------

When I test in VC it does the OSD fine, but it just flashes a black DOS box for the python call

I have attached the screenshots -

Any help would be much appreciated! I think the ability to call Python would be a great facility for VC as I an using Python for Home Automation.

Thanks!!  SaScot007
Hmm - can't think of anything witty just now

jitterjames

Hi SaScot007,

Welcome to VoxCommando.  I think you should try putting all your parameters together in a single string as the 2nd parameter for the launch.rawpam action.  (first param is the executable path as you have done).

Currently you are passing {2} and {3} as the 3rd and 4th parameters but the launch command is only expecting a single parameter for the executable and a single string for all of the "command line params".

try this:
c:\python32\python.exe                s:\prog\VC_RunPython.py {1} {2}

btw a great way to call python scripts and to combine with other home automation stuff, is to use eventGhost.

If it works correctly it will still just flash a black box, unless your python script is asking for user input or something similar.

SaScot007

Hi - thanks that works fine!

Is there any way to not have the black DOS box pop up?

Thanks again ...
Hmm - can't think of anything witty just now

jitterjames