Module: nagvis
Branch: master
Commit: 1061e012e99767d6a57ae080dec392673ea18f0d
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=1061e012e99767d6a57ae080dec392673ea18f0d

Author: LaMi <[email protected]>
Date:   Wed Apr 28 19:34:40 2010 +0200

#273 Fixed graphviz binary detection when binaries are not in PATH

---

 share/server/core/classes/NagVisAutoMap.php |   29 +++++++++++++--------------
 1 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/share/server/core/classes/NagVisAutoMap.php 
b/share/server/core/classes/NagVisAutoMap.php
index fedb793..fb9a091 100644
--- a/share/server/core/classes/NagVisAutoMap.php
+++ b/share/server/core/classes/NagVisAutoMap.php
@@ -606,28 +606,27 @@ class NagVisAutoMap extends GlobalMap {
        private function checkGraphviz($binary, $printErr) {
                /**
                 * Check if the graphviz binaries can be found in the PATH or 
in the 
-                * configured path
+                * configured path. Prefer the configured path.
                 */
-               // Check if dot can be found in path (If it is there 
$returnCode is 0, if not it is 1)
-               exec('which '.$binary.' 2>&1', $arrReturn, $returnCode1);
-               
-               if(!$returnCode1) {
-                       
$this->CORE->getMainCfg()->setValue('automap','graphvizpath',str_replace($binary,'',$arrReturn[0]));
-               }
-               
-               exec('which 
'.$this->CORE->getMainCfg()->getValue('automap','graphvizpath').$binary. ' 
2>&1', $arrReturn, $returnCode2);
-               
-               if(!$returnCode2) {
-                       
$this->CORE->getMainCfg()->setValue('automap','graphvizpath',str_replace($binary,'',$arrReturn[0]));
+               $bFound = false;
+               
foreach(Array($this->CORE->getMainCfg()->getValue('automap','graphvizpath').$binary,
 $binary) AS $path) {
+                       // Check if dot can be found in path (If it is there 
$returnCode is 0, if not it is 1)
+                       exec('which '.$binary.' 2>/dev/null', $arrReturn, 
$exitCode);
+               
+                       if($exitCode == 0) {
+                               
$this->CORE->getMainCfg()->setValue('automap','graphvizpath', 
str_replace($binary, '', $arrReturn[0]));
+                               $bFound = true;
+                               break;
+                       }
                }
                
-               if($returnCode1 & $returnCode2) {
+               if(!$bFound) {
                        if($printErr) {
                                new GlobalMessage('ERROR', 
$this->CORE->getLang()->getText('graphvizBinaryNotFound','NAME~'.$binary.',PATHS~'.$_SERVER['PATH'].':'.$this->CORE->getMainCfg()->getvalue('automap','graphvizpath')));
                        }
-                       return FALSE;
+                       return false;
                } else {
-                       return TRUE;
+                       return true;
                }
        }
        


------------------------------------------------------------------------------
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to