PHP · SIP · Uncategorized · VOIP

Palladion – Scripting and time stamps.

/

I like to have Palladion execute scripts overnight and email the results in a CSV. The issue that I faced was that scripts require you to enter a start and end time. Logging in at 10pm to execute a post dial delay script was not an efficient use of my personal time.

I built the following functions to obtain the current time and then obtain the time from 24 hours ago. Then return these into the format that Palladion expects.  You can easily modify the “then()” function to look at a different time range.

import time
import datetime
from time import strptime

def now():
        # This fuction obtains the current time and returns it as a "datetime.datetime" object.
        now = time.gmtime()
        now2 = datetime.datetime(*now[:6])
        return now2

def then():
        # This function obtains the time from 24 hours ago and returns it as a "datetime.datetime" object.
        then1 = time.time()-86000
        then2 = time.gmtime(then1)
        then3 = datetime.datetime(*then2[:6])
        return then3

def run(facade,params): 
        #Script entry point. 
	start_ts = then()
	end_ts = now()