Name
ZoomUtils – Utilities assisting zoom commands
Dependencies
Ensure the Perl SDK is setup
Synopsis
use ZoomUtils; my $relPath = ZoomUtils::subpath($prefix,$fullPath);
Methods
tmpDir
Usage: tmpDir()
Creates a temporary directory in path specified by tmpDir field under ENVIRONMENT section in config.ini.
If the flag cleanupTmpDir under ENVIRONMENT is set to 1, the temp dir will be removed on program exit.
subpath
Usage: subpath($fullPath,$base)
Given an absolute path and base path as input, returns a relative path from the base path
my $relPath = ZoomUtils::subpath('/home/evolphin/test/images/evol.jpg','/home/evolphin/test');
$relPath will be set to ‘images/evol.jpg’
sys
Usage: sys($zmCommand)
Executes the input zoom command and returns 1 on success and 0 on failure
my $imCmd = $zm_creds." im -m \"test import\" -d \"/defproj/\" \"/home/evolphin/test/images/\""; my $status = ZoomUtils::sys($imCmd);
trim
Usage: trim($stringToTrim)
Given an input string, strips the leading & trailing white spaces and returns the resultant string
indexOf
Usage: indexOf($searchElement,$arrayRef)
Looks up input array for search element and returns the index of element if found. Returns undef otherwise.
my @channels = ("Entertainment","News","Kids","Knowledge"); my $index = ZoomUtils::indexOf("News",\@channels);
$index will be set to 1
isDateField
Usage: isDateField($datePattern)
Matches the input date pattern against a list of predefined date patterns under DATE section in config.ini. If the input is a valid date pattern returns 1, if not 0.
my $isValid = ZoomUtils::isDateField("DD/MM/YY");
epoch2date
Usage: epoch2date($msSinceEpoch)
Converts input milliseconds since epoch to DateTime object in the format specified by ‘Time Zone’ field under DATE section in config.ini
my $dateTime = ZoomUtils::epoch2date("1467824032352");
$dateTime will be set to Wed, 06 Jul 2016 16:53:52.352 GMT
formatDate
Usage: formatDate($dateTime)
Converts input DateTime object to format specified by ‘Date Format’ field under DATE section in config.ini.
str2date
Usage: str2date($dateStr)
Converts input date string to DateTime object. The output will be in format specified by ‘Date Format’ and ‘Time Zone’ fields under DATE section in config.ini
my $dateTimeObj = ZoomUtils::str2date('23:15:24');
timecode2millis
Usage: timecode2millis($time)
Converts the input time code to milli seconds. The default time code is HH:MM:SS.MMM
my $milliSec = ZoomUtils::timecode2millis('01:12:22.53');
hhmm2date
Usage: hhmm2date($time)
Given an input time in HH:MM format, returns Today’s DateTime object with HH:MM set to input
my $dateTimeObj = ZoomUtils::hhmm2date('12:30 PM');
waitForStartTime
Usage: waitForStartTime($delayByDays,$startTime)
Blocks the perl script till the scheduled start time.
my($start,$end) = ZoomUtils::waitForStartTime(5,$startTime);
runDurationDone
Usage: runDurationDone($startDateTime,$endDateTime)
Checks if we have run past the input duration. Returns true when the input duration is over. Used when the script should stop based on a timeout configured
my ($startDateTime,$endDateTime) = ZoomUtils::waitForStartTime(); my $timeOver = runDurationDone($startDateTime,$endDateTime); if($timeOver){ ($startDateTime,$endDateTime) = ZoomUtils::waitForStartTime(5, $startDateTime); }
The ‘Start Time’ and ‘Run Duration’ should be configured under DATE section in config.ini