cvs: php4 /pear/Schedule At.php

From: Date: Tue, 09 Jan 2001 21:12:34 +0000
Subject: cvs: php4 /pear/Schedule At.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3525@lists.php.net to get a copy of this message
cmv Tue Jan 9 13:12:34 2001 EDT Modified files: /php4/pear/Schedule At.php Log: Attempt to use PEAR error class ... someone please check this over Index: php4/pear/Schedule/At.php diff -u php4/pear/Schedule/At.php:1.2 php4/pear/Schedule/At.php:1.3 --- php4/pear/Schedule/At.php:1.2 Tue Jan 9 12:53:10 2001 +++ php4/pear/Schedule/At.php Tue Jan 9 13:12:34 2001 @@ -16,7 +16,7 @@ // | Authors: Colin Viebrock <colin@easydns.com> | // +----------------------------------------------------------------------+ // -// $Id: At.php,v 1.2 2001/01/09 20:53:10 cmv Exp $ +// $Id: At.php,v 1.3 2001/01/09 21:12:34 cmv Exp $ // // Interface to the UNIX "at" program @@ -26,8 +26,9 @@ * @author Colin Viebrock <colin@easydns.com> */ +require_once 'PEAR.php'; -class Schedule_At { +class Schedule_At extends PEAR { var $AT_PROG = '/usr/bin/at'; @@ -46,6 +47,7 @@ */ function Schedule_At() { + $this->PEAR(); $this->_reset(); } @@ -83,8 +85,8 @@ $this->_reset(); if ($queue && !preg_match('/^[a-zA-Z]{1,1}$/', $queue) ) { - $this->error = "Invalid queue specification"; - return false; + $this->error = new Schedule_At_Error('Invalid queue specification'); + return $this->error; } $cmd = escapeShellCmd($cmd); @@ -100,8 +102,8 @@ $result = $this->_doexec($exec); if (preg_match('/garbled time/i', $result) ) { - $this->error = "Garbled time"; - return false; + $this->error = new Schedule_At_Error('Garbled time'); + return $this->error; } if (preg_match('/job (\d+) at (.*)/i', $result, $m) ) { @@ -109,8 +111,8 @@ $this->job = $m[1]; return $this->job; } else { - $this->error = $result; - return false; + $this->error = new Schedule_At_Error('Exec Error: '.$result); + return $this->error; } } @@ -137,8 +139,8 @@ $this->_reset(); if ($queue && !preg_match('/^[a-zA-Z]{1,1}$/', $queue) ) { - $this->error = "Invalid queue specification"; - return false; + $this->error = new Schedule_At_Error('Invalid queue specification'); + return $this->error; } $exec = sprintf("%s -l %s", @@ -182,15 +184,15 @@ $this->_reset(); if (!$job) { - $this->error = "No job specified"; - return false; + $this->error = new Schedule_At_Error('No job specified'); + return $this->error; } $queue = $this->show(); if (!isset($queue[$job]) ) { - $this->error = "Job " . $job . " doesn't exist"; - return false; + $this->error = new Schedule_At_Error('Job ' . $job . ' does not exist'); + return $this->error; } $exec = sprintf("%s -d %s", @@ -217,10 +219,10 @@ */ function _reset() { - $this->error = false; + $this->error = false; $this->runtime = false; $this->job = false; - $this->lastexec = ''; + $this->lastexec = ''; } @@ -256,7 +258,22 @@ return $cmd; } - } + + +class Schedule_At_Error extends PEAR_Error +{ + var $classname = 'Schedule_At_Error'; + var $error_message_prepend = 'Error in Schedule_At'; + + function Schedule_At_Error ($message, $code = 0, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE) + { + $this->PEAR_Error ($message, $code, $mode, $level); + } + +} + + ?> +

« previous php.cvs (#3525) next »