I'm pretty novice in Python scripting and was trying to run an API call with some dynamic values passed.
A simple idea about the code is, it gets two datetimes in epoch(10 second interval)and calls an API to do a function.
import commands
end = str(datetime.datetime.now().strftime("%s"))
start = str((datetime.datetime.now() - datetime.timedelta(seconds=10)).strftime("%s"))
output = commands.getstatusoutput("curl 'http://my-api-url/object?param1=1&start=$start&end=$end&function=average'")
It doesn't work as the variables start
and end
are not getting expanded/substituted.
As you see, I come from bash scripting and tried looking on several variable substitution commands from web, but nothing specific found to my case here.