当前位置: 首页>>代码示例>>PHP>>正文


PHP PEAR::staticPopErrorHandling方法代码示例

本文整理汇总了PHP中PEAR::staticPopErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::staticPopErrorHandling方法的具体用法?PHP PEAR::staticPopErrorHandling怎么用?PHP PEAR::staticPopErrorHandling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PEAR的用法示例。


在下文中一共展示了PEAR::staticPopErrorHandling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _checkChannelForStatus

 function _checkChannelForStatus($channel, $chan)
 {
     $rest = new PEAR_REST($this->config);
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $a = $rest->downloadHttp('http://' . $channel . '/channel.xml', $chan->lastModified());
     PEAR::staticPopErrorHandling();
     if (!PEAR::isError($a) && $a) {
         $this->ui->outputData('WARNING: channel "' . $channel . '" has ' . 'updated its protocols, use "channel-update ' . $channel . '" to update');
     }
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:10,代码来源:Remote.php

示例2: testFactoryDAL

 /**
  * Test that method returns correct object when DataObject exists and false otherwise.
  *
  * @TODO Add PEAR_Error expectations to simpletest in order to catch them
  */
 function testFactoryDAL()
 {
     // Test when object exists
     $dalBanners = OA_Dal::factoryDAL('banners');
     $this->assertIsA($dalBanners, 'MAX_Dal_Admin_Banners');
     // Test when object doesn't exist
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $dalBanners = OA_Dal::factoryDAL('foo' . rand());
     PEAR::staticPopErrorHandling();
     $this->assertFalse($dalBanners);
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:16,代码来源:Dal.dal.test.php

示例3: processBucket

 /**
  * Process an aggregate-type bucket.  This is MySQL specific.
  *
  * @param Plugins_DeliveryLog $oBucket a reference to the using (context) object.
  * @param Date $oEnd A PEAR_Date instance, interval_start to process up to (inclusive).
  */
 public function processBucket($oBucket, $oEnd)
 {
     $sTableName = $oBucket->getBucketTableName();
     $oMainDbh =& OA_DB_Distributed::singleton();
     if (PEAR::isError($oMainDbh)) {
         MAX::raiseError($oMainDbh, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
     }
     OA::debug('  - Processing the ' . $sTableName . ' table for data with operation interval start equal to or before ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_INFO);
     // Select all rows with interval_start <= previous OI start.
     $rsData =& $this->getBucketTableContent($sTableName, $oEnd);
     $rowCount = $rsData->getRowCount();
     OA::debug('  - ' . $rsData->getRowCount() . ' records found', PEAR_LOG_DEBUG);
     if ($rowCount) {
         // We can't do bulk inserts with ON DUPLICATE.
         $aExecQueries = array();
         if ($rsData->fetch()) {
             // Get first row
             $aRow = $rsData->toArray();
             // Prepare INSERT
             $sInsert = "INSERT INTO {$sTableName} (" . join(',', array_keys($aRow)) . ") VALUES ";
             // Add first row data
             $sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
             $sOnDuplicate = ' ON DUPLICATE KEY UPDATE count = count + ' . $aRow['count'];
             // Add first insert
             $aExecQueries[] = $sInsert . $sRow . $sOnDuplicate;
             // Deal with the other rows
             while ($rsData->fetch()) {
                 $aRow = $rsData->toArray();
                 $sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
                 $sOnDuplicate = ' ON DUPLICATE KEY UPDATE count = count + ' . $aRow['count'];
                 $aExecQueries[] = $sInsert . $sRow . $sOnDuplicate;
             }
         }
         if (count($aExecQueries)) {
             // Try to disable the binlog for the inserts so we don't
             // replicate back out over our logged data.
             PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
             $result = $oMainDbh->exec('SET SQL_LOG_BIN = 0');
             if (PEAR::isError($result)) {
                 OA::debug('Unable to disable the bin log, proceeding anyway.', PEAR_LOG_WARNING);
             }
             PEAR::staticPopErrorHandling();
             foreach ($aExecQueries as $execQuery) {
                 $result = $oMainDbh->exec($execQuery);
                 if (PEAR::isError($result)) {
                     MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                 }
             }
         }
     }
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:57,代码来源:AggregateBucketProcessingStrategyMysql.php

示例4: resetPassword

    /**
     * Mark a user for password resetting
     *
     * @param string $user
     * @param string $pass1
     * @param string $pass2
     * @return array
     */
    function resetPassword($user, $pass1, $pass2)
    {
        require_once 'Damblan/Mailer.php';
        $errors = array();
        $salt = md5(mt_rand(4, 13) . $user . time() . $pass1);
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
        $this->_dbh->query('DELETE FROM lostpassword WHERE handle=?', array($user));
        $e = $this->_dbh->query('INSERT INTO lostpassword
            (handle, newpassword, salt, requested)
            VALUES(?,?,?,NOW())', array($user, md5($pass1), $salt));
        PEAR::staticPopErrorHandling();
        if (PEAR::isError($e)) {
            $errors[] = 'Could not change password: ' . $e->getMessage();
        } else {
            include_once 'pear-database-user.php';
            $info = user::info($user);
            $this->_mailer = Damblan_mailer::create(array('To' => array($info['name'] . ' <' . $info['email'] . '>'), 'Reply-To' => array('PEAR QA <' . PEAR_QA_EMAIL . '>'), 'Subject' => '[PEAR-ACCOUNT-PASSWORD] Your password reset request : %username%', 'Body' => 'A request has been made to reset your password for %username%
at pear.php.net.

If you intended to reset the password, please navigate to this page:
  https://' . PEAR_CHANNELNAME . '/account/password-confirm-change.php
and follow the instructions.  Your password reset code is:

%salt%

If you have received this email by mistake or did not request a
password change, no further action is necessary.  Your password
will NOT change until you confirm the change, and it cannot be changed
without the password reset code.  Password change requests are automatically
purged after 24 hours.

PEAR Quality Assurance.'), array('username' => $user, 'salt' => $salt));
            $this->_mailer->send();
        }
        return $errors;
    }
开发者ID:stof,项目名称:pearweb,代码行数:44,代码来源:passwordmanage.php

示例5: _getDepPackageDownloadUrl

 /**
  * @param array dependency array
  * @access private
  */
 function _getDepPackageDownloadUrl($dep, $parr)
 {
     $xsdversion = isset($dep['rel']) ? '1.0' : '2.0';
     $curchannel = $this->config->get('default_channel');
     if (isset($dep['uri'])) {
         $xsdversion = '2.0';
         $chan =& $this->_registry->getChannel('__uri');
         if (PEAR::isError($chan)) {
             return $chan;
         }
         $version = $this->_registry->packageInfo($dep['name'], 'version', '__uri');
         $this->configSet('default_channel', '__uri');
     } else {
         if (isset($dep['channel'])) {
             $remotechannel = $dep['channel'];
         } else {
             $remotechannel = 'pear.php.net';
         }
         if (!$this->_registry->channelExists($remotechannel)) {
             do {
                 if ($this->config->get('auto_discover')) {
                     if ($this->discover($remotechannel)) {
                         break;
                     }
                 }
                 return PEAR::raiseError('Unknown remote channel: ' . $remotechannel);
             } while (false);
         }
         $chan =& $this->_registry->getChannel($remotechannel);
         if (PEAR::isError($chan)) {
             return $chan;
         }
         $version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
         $this->configSet('default_channel', $remotechannel);
     }
     $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state');
     if (isset($parr['state']) && isset($parr['version'])) {
         unset($parr['state']);
     }
     if (isset($dep['uri'])) {
         $info =& $this->newDownloaderPackage($this);
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $err = $info->initialize($dep);
         PEAR::staticPopErrorHandling();
         if (!$err) {
             // skip parameters that were missed by preferred_state
             return PEAR::raiseError('Cannot initialize dependency');
         }
         if (PEAR::isError($err)) {
             if (!isset($this->_options['soft'])) {
                 $this->log(0, $err->getMessage());
             }
             if (is_object($info)) {
                 $param = $info->getChannel() . '/' . $info->getPackage();
             }
             return PEAR::raiseError('Package "' . $param . '" is not valid');
         }
         return $info;
     } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && (($base2 = $chan->getBaseURL('REST1.3', $this->config->get('preferred_mirror'))) || ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))))) {
         if ($base2) {
             $base = $base2;
             $rest =& $this->config->getREST('1.3', $this->_options);
         } else {
             $rest =& $this->config->getREST('1.0', $this->_options);
         }
         $url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version, $chan->getName());
         if (PEAR::isError($url)) {
             return $url;
         }
         if ($parr['channel'] != $curchannel) {
             $this->configSet('default_channel', $curchannel);
         }
         if (!is_array($url)) {
             return $url;
         }
         $url['raw'] = false;
         // no checking is necessary for REST
         if (!is_array($url['info'])) {
             return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen');
         }
         if (isset($url['info']['required'])) {
             if (!class_exists('PEAR_PackageFile_v2')) {
                 require_once 'PEAR/PackageFile/v2.php';
             }
             $pf = new PEAR_PackageFile_v2();
             $pf->setRawChannel($remotechannel);
         } else {
             if (!class_exists('PEAR_PackageFile_v1')) {
                 require_once 'PEAR/PackageFile/v1.php';
             }
             $pf = new PEAR_PackageFile_v1();
         }
         $pf->setRawPackage($url['package']);
         $pf->setDeps($url['info']);
         if ($url['compatible']) {
             $pf->setCompatible($url['compatible']);
//.........这里部分代码省略.........
开发者ID:shen0834,项目名称:util,代码行数:101,代码来源:Downloader.php

示例6: doDownloadAll

 /**
  * retrieves a list of avaible Packages from master server
  * and downloads them
  *
  * @access public
  * @param string $command the command
  * @param array $options the command options before the command
  * @param array $params the stuff after the command name
  * @return bool true if succesful
  * @throw PEAR_Error
  */
 function doDownloadAll($command, $options, $params)
 {
     $savechannel = $this->config->get('default_channel');
     $reg =& $this->config->getRegistry();
     $channel = isset($options['channel']) ? $options['channel'] : $this->config->get('default_channel');
     if (!$reg->channelExists($channel)) {
         $this->config->set('default_channel', $savechannel);
         return $this->raiseError('Channel "' . $channel . '" does not exist');
     }
     $this->config->set('default_channel', $channel);
     $this->ui->outputData('Using Channel ' . $this->config->get('default_channel'));
     $chan = $reg->getChannel($channel);
     if (PEAR::isError($chan)) {
         return $this->raiseError($chan);
     }
     if ($chan->supportsREST($this->config->get('preferred_mirror')) && ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror')))) {
         $rest =& $this->config->getREST('1.0', array());
         $remoteInfo = array_flip($rest->listPackages($base, $channel));
     }
     if (PEAR::isError($remoteInfo)) {
         return $remoteInfo;
     }
     $cmd =& $this->factory("download");
     if (PEAR::isError($cmd)) {
         return $cmd;
     }
     $this->ui->outputData('Using Preferred State of ' . $this->config->get('preferred_state'));
     $this->ui->outputData('Gathering release information, please wait...');
     /**
      * Error handling not necessary, because already done by
      * the download command
      */
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $err = $cmd->run('download', array('downloadonly' => true), array_keys($remoteInfo));
     PEAR::staticPopErrorHandling();
     $this->config->set('default_channel', $savechannel);
     if (PEAR::isError($err)) {
         $this->ui->outputData($err->getMessage());
     }
     return true;
 }
开发者ID:shen0834,项目名称:util,代码行数:52,代码来源:Mirror.php

示例7: Archive_Tar

 /**
  * Create a PEAR_PackageFile_v* from a compresed Tar or Tgz file.
  * @access  public
  * @param string contents of package.xml file
  * @param int package state (one of PEAR_VALIDATE_* constants)
  * @return  PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @using   Archive_Tar to extract the files
  * @using   fromPackageFile() to load the package after the package.xml
  *          file is extracted.
  */
 function &fromTgzFile($file, $state)
 {
     if (!class_exists('Archive_Tar')) {
         require_once 'Archive/Tar.php';
     }
     $tar = new Archive_Tar($file);
     if ($this->_debug <= 1) {
         $tar->pushErrorHandling(PEAR_ERROR_RETURN);
     }
     $content = $tar->listContent();
     if ($this->_debug <= 1) {
         $tar->popErrorHandling();
     }
     if (!is_array($content)) {
         if (is_string($file) && strlen($file < 255) && (!file_exists($file) || !@is_file($file))) {
             $ret = PEAR::raiseError("could not open file \"{$file}\"");
             return $ret;
         }
         $file = realpath($file);
         $ret = PEAR::raiseError("Could not get contents of package \"{$file}\"" . '. Invalid tgz file.');
         return $ret;
     } else {
         if (!count($content) && !@is_file($file)) {
             $ret = PEAR::raiseError("could not open file \"{$file}\"");
             return $ret;
         }
     }
     $xml = null;
     $origfile = $file;
     foreach ($content as $file) {
         $name = $file['filename'];
         if ($name == 'package2.xml') {
             // allow a .tgz to distribute both versions
             $xml = $name;
             break;
         }
         if ($name == 'package.xml') {
             $xml = $name;
             break;
         } elseif (ereg('package.xml$', $name, $match)) {
             $xml = $name;
             break;
         }
     }
     if ($this->_tmpdir) {
         $tmpdir = $this->_tmpdir;
     } else {
         $tmpdir = System::mkTemp(array('-d', 'pear'));
         PEAR_PackageFile::addTempFile($tmpdir);
     }
     $this->_extractErrors();
     PEAR::staticPushErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_extractErrors'));
     if (!$xml || !$tar->extractList(array($xml), $tmpdir)) {
         $extra = implode("\n", $this->_extractErrors());
         if ($extra) {
             $extra = ' ' . $extra;
         }
         PEAR::staticPopErrorHandling();
         $ret = PEAR::raiseError('could not extract the package.xml file from "' . $origfile . '"' . $extra);
         return $ret;
     }
     PEAR::staticPopErrorHandling();
     $ret =& PEAR_PackageFile::fromPackageFile("{$tmpdir}/{$xml}", $state, $origfile);
     return $ret;
 }
开发者ID:jamesiarmes,项目名称:php-ups-api,代码行数:75,代码来源:PackageFile.php

示例8: uninstall

 /**
  * Uninstall a package
  *
  * This method removes all files installed by the application, and then
  * removes any empty directories.
  * @param string package name
  * @param array Command-line options.  Possibilities include:
  *
  *              - installroot: base installation dir, if not the default
  *              - nodeps: do not process dependencies of other packages to ensure
  *                        uninstallation does not break things
  */
 function uninstall($package, $options = array())
 {
     if (isset($options['installroot'])) {
         $this->config->setInstallRoot($options['installroot']);
         $this->installroot = '';
     } else {
         $this->config->setInstallRoot('');
         $this->installroot = '';
     }
     $this->_registry =& $this->config->getRegistry();
     if (is_object($package)) {
         $channel = $package->getChannel();
         $pkg = $package;
         $package = $pkg->getPackage();
     } else {
         $pkg = false;
         $info = $this->_registry->parsePackageName($package, $this->config->get('default_channel'));
         $channel = $info['channel'];
         $package = $info['package'];
     }
     $savechannel = $this->config->get('default_channel');
     $this->configSet('default_channel', $channel);
     if (!is_object($pkg)) {
         $pkg = $this->_registry->getPackage($package, $channel);
     }
     if (!$pkg) {
         $this->configSet('default_channel', $savechannel);
         return $this->raiseError($this->_registry->parsedPackageNameToString(array('channel' => $channel, 'package' => $package), true) . ' not installed');
     }
     if ($pkg->getInstalledBinary()) {
         // this is just an alias for a binary package
         return $this->_registry->deletePackage($package, $channel);
     }
     $filelist = $pkg->getFilelist();
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     if (!class_exists('PEAR_Dependency2')) {
         require_once 'PEAR/Dependency2.php';
     }
     $depchecker =& new PEAR_Dependency2($this->config, $options, array('channel' => $channel, 'package' => $package), PEAR_VALIDATE_UNINSTALLING);
     $e = $depchecker->validatePackageUninstall($this);
     PEAR::staticPopErrorHandling();
     if (PEAR::isError($e)) {
         if (!isset($options['ignore-errors'])) {
             return $this->raiseError($e);
         } else {
             if (!isset($options['soft'])) {
                 $this->log(0, 'WARNING: ' . $e->getMessage());
             }
         }
     } elseif (is_array($e)) {
         if (!isset($options['soft'])) {
             $this->log(0, $e[0]);
         }
     }
     // {{{ Delete the files
     $this->startFileTransaction();
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     if (PEAR::isError($err = $this->_deletePackageFiles($package, $channel))) {
         PEAR::popErrorHandling();
         $this->rollbackFileTransaction();
         $this->configSet('default_channel', $savechannel);
         if (!isset($options['ignore-errors'])) {
             return $this->raiseError($err);
         } else {
             if (!isset($options['soft'])) {
                 $this->log(0, 'WARNING: ' . $err->getMessage());
             }
         }
     } else {
         PEAR::popErrorHandling();
     }
     if (!$this->commitFileTransaction()) {
         $this->rollbackFileTransaction();
         if (!isset($options['ignore-errors'])) {
             return $this->raiseError("uninstall failed");
         } elseif (!isset($options['soft'])) {
             $this->log(0, 'WARNING: uninstall failed');
         }
     } else {
         $this->startFileTransaction();
         if ($dirtree = $pkg->getDirTree()) {
             // attempt to delete empty directories
             uksort($dirtree, array($this, '_sortDirs'));
             foreach ($dirtree as $dir => $notused) {
                 $this->addFileOperation('rmdir', array($dir));
             }
         } else {
             $this->configSet('default_channel', $savechannel);
//.........这里部分代码省略.........
开发者ID:zseand,项目名称:kloxo,代码行数:101,代码来源:Installer.php

示例9: package

 function package($pkgfile = null, $compress = true, $pkg2 = null)
 {
     // {{{ validate supplied package.xml file
     if (empty($pkgfile)) {
         $pkgfile = 'package.xml';
     }
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $pkg = new PEAR_PackageFile($this->config, $this->debug);
     $pf =& $pkg->fromPackageFile($pkgfile, PEAR_VALIDATE_NORMAL);
     $main =& $pf;
     PEAR::staticPopErrorHandling();
     if (PEAR::isError($pf)) {
         if (is_array($pf->getUserInfo())) {
             foreach ($pf->getUserInfo() as $error) {
                 $this->log(0, 'Error: ' . $error['message']);
             }
         }
         $this->log(0, $pf->getMessage());
         return $this->raiseError("Cannot package, errors in package file");
     }
     foreach ($pf->getValidationWarnings() as $warning) {
         $this->log(1, 'Warning: ' . $warning['message']);
     }
     // }}}
     if ($pkg2) {
         $this->log(0, 'Attempting to process the second package file');
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $pf2 =& $pkg->fromPackageFile($pkg2, PEAR_VALIDATE_NORMAL);
         PEAR::staticPopErrorHandling();
         if (PEAR::isError($pf2)) {
             if (is_array($pf2->getUserInfo())) {
                 foreach ($pf2->getUserInfo() as $error) {
                     $this->log(0, 'Error: ' . $error['message']);
                 }
             }
             $this->log(0, $pf2->getMessage());
             return $this->raiseError("Cannot package, errors in second package file");
         }
         foreach ($pf2->getValidationWarnings() as $warning) {
             $this->log(1, 'Warning: ' . $warning['message']);
         }
         if ($pf2->getPackagexmlVersion() == '2.0' || $pf2->getPackagexmlVersion() == '2.1') {
             $main =& $pf2;
             $other =& $pf;
         } else {
             $main =& $pf;
             $other =& $pf2;
         }
         if ($main->getPackagexmlVersion() != '2.0' && $main->getPackagexmlVersion() != '2.1') {
             return PEAR::raiseError('Error: cannot package two package.xml version 1.0, can ' . 'only package together a package.xml 1.0 and package.xml 2.0');
         }
         if ($other->getPackagexmlVersion() != '1.0') {
             return PEAR::raiseError('Error: cannot package two package.xml version 2.0, can ' . 'only package together a package.xml 1.0 and package.xml 2.0');
         }
     }
     $main->setLogger($this);
     if (!$main->validate(PEAR_VALIDATE_PACKAGING)) {
         foreach ($main->getValidationWarnings() as $warning) {
             $this->log(0, 'Error: ' . $warning['message']);
         }
         return $this->raiseError("Cannot package, errors in package");
     }
     foreach ($main->getValidationWarnings() as $warning) {
         $this->log(1, 'Warning: ' . $warning['message']);
     }
     if ($pkg2) {
         $other->setLogger($this);
         $a = false;
         if (!$other->validate(PEAR_VALIDATE_NORMAL) || ($a = !$main->isEquivalent($other))) {
             foreach ($other->getValidationWarnings() as $warning) {
                 $this->log(0, 'Error: ' . $warning['message']);
             }
             foreach ($main->getValidationWarnings() as $warning) {
                 $this->log(0, 'Error: ' . $warning['message']);
             }
             if ($a) {
                 return $this->raiseError('The two package.xml files are not equivalent!');
             }
             return $this->raiseError("Cannot package, errors in package");
         }
         foreach ($other->getValidationWarnings() as $warning) {
             $this->log(1, 'Warning: ' . $warning['message']);
         }
         $gen =& $main->getDefaultGenerator();
         $tgzfile = $gen->toTgz2($this, $other, $compress);
         if (PEAR::isError($tgzfile)) {
             return $tgzfile;
         }
         $dest_package = basename($tgzfile);
         $pkgdir = dirname($pkgfile);
         // TAR the Package -------------------------------------------
         $this->log(1, "Package {$dest_package} done");
         if (file_exists("{$pkgdir}/CVS/Root")) {
             $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pf->getVersion());
             $cvstag = "RELEASE_{$cvsversion}";
             $this->log(1, 'Tag the released code with "pear cvstag ' . $main->getPackageFile() . '"');
             $this->log(1, "(or set the CVS tag {$cvstag} by hand)");
         } elseif (file_exists("{$pkgdir}/.svn")) {
             $svnversion = preg_replace('/[^a-z0-9]/i', '.', $pf->getVersion());
             $svntag = $pf->getName() . "-{$svnversion}";
//.........这里部分代码省略.........
开发者ID:orcoliver,项目名称:oneye,代码行数:101,代码来源:Packager.php

示例10: doRunTests


//.........这里部分代码省略.........
     }
     $skipped = $passed = $failed = array();
     $tests_count = count($tests);
     $this->ui->outputData('Running ' . $tests_count . ' tests', $command);
     $start = time();
     if (isset($options['realtimelog']) && file_exists('run-tests.log')) {
         unlink('run-tests.log');
     }
     if (isset($options['tapoutput'])) {
         $tap = '1..' . $tests_count . "\n";
     }
     require_once 'PEAR/RunTest.php';
     $run = new PEAR_RunTest($log, $options);
     $run->tests_count = $tests_count;
     if (isset($options['coverage']) && extension_loaded('xdebug')) {
         $run->xdebug_loaded = true;
     } else {
         $run->xdebug_loaded = false;
     }
     $j = $i = 1;
     foreach ($tests as $t) {
         if (isset($options['realtimelog'])) {
             $fp = @fopen('run-tests.log', 'a');
             if ($fp) {
                 fwrite($fp, "Running test [{$i} / {$tests_count}] {$t}...");
                 fclose($fp);
             }
         }
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         if (isset($options['phpunit'])) {
             $result = $run->runPHPUnit($t, $ini_settings);
         } else {
             $result = $run->run($t, $ini_settings, $j);
         }
         PEAR::staticPopErrorHandling();
         if (PEAR::isError($result)) {
             $this->ui->log($result->getMessage());
             continue;
         }
         if (isset($options['tapoutput'])) {
             $tap .= $result[0] . ' ' . $i . $result[1] . "\n";
             continue;
         }
         if (isset($options['realtimelog'])) {
             $fp = @fopen('run-tests.log', 'a');
             if ($fp) {
                 fwrite($fp, "{$result}\n");
                 fclose($fp);
             }
         }
         if ($result == 'FAILED') {
             $failed[] = $t;
         }
         if ($result == 'PASSED') {
             $passed[] = $t;
         }
         if ($result == 'SKIPPED') {
             $skipped[] = $t;
         }
         $j++;
     }
     $total = date('i:s', time() - $start);
     if (isset($options['tapoutput'])) {
         $fp = @fopen('run-tests.log', 'w');
         if ($fp) {
             fwrite($fp, $tap, strlen($tap));
             fclose($fp);
             $this->ui->outputData('wrote TAP-format log to "' . realpath('run-tests.log') . '"', $command);
         }
     } else {
         if (count($failed)) {
             $output = "TOTAL TIME: {$total}\n";
             $output .= count($passed) . " PASSED TESTS\n";
             $output .= count($skipped) . " SKIPPED TESTS\n";
             $output .= count($failed) . " FAILED TESTS:\n";
             foreach ($failed as $failure) {
                 $output .= $failure . "\n";
             }
             $mode = isset($options['realtimelog']) ? 'a' : 'w';
             $fp = @fopen('run-tests.log', $mode);
             if ($fp) {
                 fwrite($fp, $output, strlen($output));
                 fclose($fp);
                 $this->ui->outputData('wrote log to "' . realpath('run-tests.log') . '"', $command);
             }
         } elseif (file_exists('run-tests.log') && !is_dir('run-tests.log')) {
             @unlink('run-tests.log');
         }
     }
     $this->ui->outputData('TOTAL TIME: ' . $total);
     $this->ui->outputData(count($passed) . ' PASSED TESTS', $command);
     $this->ui->outputData(count($skipped) . ' SKIPPED TESTS', $command);
     if (count($failed)) {
         $this->ui->outputData(count($failed) . ' FAILED TESTS:', $command);
         foreach ($failed as $failure) {
             $this->ui->outputData($failure, $command);
         }
     }
     return true;
 }
开发者ID:kaz6120,项目名称:Loggix,代码行数:101,代码来源:Test.php

示例11: doRunTests

 function doRunTests($command, $options, $params)
 {
     require_once 'PEAR/Common.php';
     require_once 'PEAR/RunTest.php';
     require_once 'System.php';
     $log = new PEAR_Common();
     $log->ui =& $this->ui;
     // slightly hacky, but it will work
     $run = new PEAR_RunTest($log, $options);
     $tests = array();
     if (isset($options['recur'])) {
         $depth = 4;
     } else {
         $depth = 1;
     }
     if (!count($params)) {
         $params[] = '.';
     }
     if (isset($options['package'])) {
         $oldparams = $params;
         $params = array();
         $reg =& $this->config->getRegistry();
         foreach ($oldparams as $param) {
             $pname = $reg->parsePackageName($param, $this->config->get('default_channel'));
             if (PEAR::isError($pname)) {
                 return $this->raiseError($pname);
             }
             $package =& $reg->getPackage($pname['package'], $pname['channel']);
             if (!$package) {
                 return PEAR::raiseError('Unknown package "' . $reg->parsedPackageNameToString($pname) . '"');
             }
             $filelist = $package->getFilelist();
             foreach ($filelist as $name => $atts) {
                 if (isset($atts['role']) && $atts['role'] != 'test') {
                     continue;
                 }
                 if (!preg_match('/\\.phpt$/', $name)) {
                     continue;
                 }
                 $params[] = $atts['installed_as'];
             }
         }
     }
     foreach ($params as $p) {
         if (is_dir($p)) {
             $dir = System::find(array($p, '-type', 'f', '-maxdepth', $depth, '-name', '*.phpt'));
             $tests = array_merge($tests, $dir);
         } else {
             if (!@file_exists($p)) {
                 if (!preg_match('/\\.phpt$/', $p)) {
                     $p .= '.phpt';
                 }
                 $dir = System::find(array(dirname($p), '-type', 'f', '-maxdepth', $depth, '-name', $p));
                 $tests = array_merge($tests, $dir);
             } else {
                 $tests[] = $p;
             }
         }
     }
     $ini_settings = '';
     if (isset($options['ini'])) {
         $ini_settings .= $options['ini'];
     }
     if (isset($_ENV['TEST_PHP_INCLUDE_PATH'])) {
         $ini_settings .= " -d include_path={$_ENV['TEST_PHP_INCLUDE_PATH']}";
     }
     if ($ini_settings) {
         $this->ui->outputData('Using INI settings: "' . $ini_settings . '"');
     }
     $skipped = $passed = $failed = array();
     $this->ui->outputData('Running ' . count($tests) . ' tests', $command);
     $start = time();
     if (isset($options['realtimelog'])) {
         @unlink('run-tests.log');
     }
     foreach ($tests as $t) {
         if (isset($options['realtimelog'])) {
             $fp = @fopen('run-tests.log', 'a');
             if ($fp) {
                 fwrite($fp, "Running test {$t}...");
                 fclose($fp);
             }
         }
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $result = $run->run($t, $ini_settings);
         PEAR::staticPopErrorHandling();
         if (PEAR::isError($result)) {
             $this->ui->log(0, $result->getMessage());
             continue;
         }
         if (OS_WINDOWS) {
             for ($i = 0; $i < 2000; $i++) {
                 $i = $i;
                 // delay - race conditions on windows
             }
         }
         if (isset($options['realtimelog'])) {
             $fp = @fopen('run-tests.log', 'a');
             if ($fp) {
                 fwrite($fp, "{$result}\n");
//.........这里部分代码省略.........
开发者ID:OTiZ,项目名称:osx,代码行数:101,代码来源:Test.php

示例12: _initTemplate

 /**
  * Initialize a TemplateObject
  *
  * @param string  $file     filename of the template file
  *
  * @return object Object of HTML/IT - Template - Class
  */
 function _initTemplate($file)
 {
     // Errors here can not be displayed using the UI
     PEAR::staticPushErrorHandling(PEAR_ERROR_DIE);
     $tpl_dir = $this->config->get('data_dir') . DIRECTORY_SEPARATOR . 'PEAR_Frontend_Web' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'templates';
     if (!file_exists($tpl_dir) || !is_readable($tpl_dir)) {
         PEAR::raiseError('<b>Error:</b> the template directory <i>(' . $tpl_dir . ')</i> is not a directory, or not readable. Make sure the \'data_dir\' of your config file <i>(' . $this->config->get('data_dir') . ')</i> points to the correct location !');
     }
     $tpl = new HTML_Template_IT($tpl_dir);
     $tpl->loadTemplateFile($file);
     $tpl->setVariable("InstallerURL", $_SERVER["PHP_SELF"]);
     PEAR::staticPopErrorHandling();
     // reset error handling
     return $tpl;
 }
开发者ID:Bobsel,项目名称:gn-tic,代码行数:22,代码来源:Web.php

示例13: disableConversion

 /**
  */
 public static function disableConversion()
 {
     $oldErrorReportingLevel = error_reporting(error_reporting() & ~E_STRICT);
     PEAR::staticPopErrorHandling();
     error_reporting($oldErrorReportingLevel);
 }
开发者ID:rsky,项目名称:makegood,代码行数:8,代码来源:PEARError.php

示例14: _query

 /**
  * Added handling any errors caused by queries send from DataObjects to database
  *
  * @param string $string  Query
  * @return PEAR_Error or mixed none
  */
 function _query($string)
 {
     $production = empty($GLOBALS['_MAX']['CONF']['debug']['production']) ? false : true;
     if ($production) {
         // supress any PEAR errors if in production
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     }
     // execute query
     $ret = parent::_query($string);
     if ($production) {
         PEAR::staticPopErrorHandling();
     }
     if (PEAR::isError($ret)) {
         if (!$production) {
             $GLOBALS['_MAX']['ERRORS'][] = $ret;
         }
         if ($this->triggerSqlDie && function_exists('phpAds_sqlDie')) {
             $GLOBALS['phpAds_last_query'] = $string;
             if (empty($GLOBALS['_MAX']['PAN']['DB'])) {
                 $GLOBALS['_MAX']['PAN']['DB'] = $GLOBALS['_DB_DATAOBJECT']['CONNECTIONS'][$this->_database_dsn_md5];
             }
             phpAds_sqlDie();
         }
     }
     return $ret;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:32,代码来源:DB_DataObjectCommon.php

示例15: elseif

 /**
  * create a new {@link Net_UserAgent_Mobile_Common} subclass instance
  *
  * parses HTTP headers and constructs {@link Net_UserAgent_Mobile_Common}
  * subclass instance.
  * If no argument is supplied, $_SERVER{'HTTP_*'} is used.
  *
  * @param string $userAgent User-Agent string
  * @return Net_UserAgent_Mobile_Common a newly created or an existing
  *     Net_UserAgent_Mobile_Common object
  * @throws Net_UserAgent_Mobile_Error
  */
 function &factory($userAgent = null)
 {
     if (is_null($userAgent)) {
         $userAgent = @$_SERVER['HTTP_USER_AGENT'];
     }
     // parse User-Agent string
     if (Net_UserAgent_Mobile::isDoCoMo($userAgent)) {
         $driver = 'DoCoMo';
     } elseif (Net_UserAgent_Mobile::isEZweb($userAgent)) {
         $driver = 'EZweb';
     } elseif (Net_UserAgent_Mobile::isSoftBank($userAgent)) {
         $driver = 'SoftBank';
     } elseif (Net_UserAgent_Mobile::isWillcom($userAgent)) {
         $driver = 'Willcom';
     } else {
         $driver = 'NonMobile';
     }
     $class = "Net_UserAgent_Mobile_{$driver}";
     if (!class_exists($class)) {
         $file = dirname(__FILE__) . "/Mobile/{$driver}.php";
         if (!(include_once $file)) {
             return PEAR::raiseError(null, NET_USERAGENT_MOBILE_ERROR_NOT_FOUND, null, null, "Unable to include the {$file} file", 'Net_UserAgent_Mobile_Error', true);
         }
     }
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $instance = new $class($userAgent);
     PEAR::staticPopErrorHandling();
     $error =& $instance->getError();
     if (Net_UserAgent_Mobile::isError($error)) {
         if ($GLOBALS['NET_USERAGENT_MOBILE_FallbackOnNomatch'] && $error->getCode() == NET_USERAGENT_MOBILE_ERROR_NOMATCH) {
             $instance =& Net_UserAgent_Mobile::factory('Net_UserAgent_Mobile_Fallback_On_NoMatch');
             return $instance;
         }
         return PEAR::raiseError($error);
     }
     return $instance;
 }
开发者ID:casan,项目名称:eccube-2_13,代码行数:49,代码来源:Mobile.php


注:本文中的PEAR::staticPopErrorHandling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。