59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
#!/bin/python3
|
|
'''
|
|
Created on Apr 5, 2016
|
|
author: tpweis
|
|
file name: scat_dsleds.py
|
|
This functions sends initiates a recipe to run a bot
|
|
This function also represent a segment of the SCAT. The SCAT contains
|
|
any required IP or URN identifiers.
|
|
'''
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
sys.path.insert(0,'/sl/lib')
|
|
from sleds_utilities import *
|
|
|
|
|
|
def main():
|
|
"function main"
|
|
|
|
argv = sys.argv[1:]
|
|
|
|
# argument 1 is the IP address to execute the command. It is required
|
|
if(len(argv) < 1):
|
|
slscatlog ('E','IPADDRESS is required: scat_dsleds <ipaddress>')
|
|
sys.exit(2)
|
|
else:
|
|
IPADDR = argv[0]
|
|
|
|
|
|
slscatlog('I',"scat_dsleds on " + IPADDR)
|
|
|
|
# If arguments were passed in, use those to deploy. Otherwise,
|
|
# use the defaults
|
|
if(len(argv) < 2):
|
|
version = "-v 1.0.0"
|
|
branch = "-b release_1_0_0"
|
|
FRversion = "-r 1.0.0"
|
|
FRbranch = "-f develop"
|
|
onelist = version+ " " +branch+ " " +FRversion+ " " +FRbranch
|
|
else:
|
|
# Get the arguments from a list of strings to a string
|
|
arglist = sys.argv[2:len(sys.argv)]
|
|
onelist = ' '.join(arglist)
|
|
|
|
cmd = "sledslocal_release"
|
|
|
|
FULL_CMD = "echo " +cmd+ " " +onelist+ " | nc -n " + IPADDR + " 52525"
|
|
slscatlog('D',"run: " + FULL_CMD)
|
|
rc = subprocess.call([FULL_CMD], shell=True)
|
|
print("scat_dsleds returned: " + str(rc))
|
|
|
|
exit()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# execute only if run as a script
|
|
main()
|
|
|