Changeset 649 for trunk


Ignore:
Timestamp:
11/13/09 15:13:29 (14 years ago)
Author:
ramonb
Message:

job_monarch/libtoga.php,
job_monarch/clusterconf/gina-example.php:

  • changed hostname x/y coord parsing to support regexp's
Location:
trunk/web/addons/job_monarch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/job_monarch/clusterconf/gina-example.php

    r648 r649  
    22//
    33//$SORTBY_HOSTNAME = "v{x}-{y}.gina.sara.nl";
    4 $SORTBY_HOSTNAME = "{x}-{y}.gina.sara.nl";
     4$SORTBY_HOSTNAME = "[a-z,A-Z]+{x}-{y}.gina.sara.nl";
    55$SORT_ORDER = "asc";
    66
  • trunk/web/addons/job_monarch/libtoga.php

    r648 r649  
    17391739                        }
    17401740
     1741                        // Turn it into a regexp /something/ search pattern
     1742                        //
     1743                        $skan_str       = '/' . $skan_str . '/';
     1744
    17411745                        // Now replace our {x} and {y} with %d for sscanf parsing
    17421746                        //
    17431747                        if(( $x_first ) && ( $x_present && $y_present ) )
    17441748                        {
    1745                                 $skan_str       = str_replace( $x_str, "%d", $skan_str );
    1746                                 $skan_str       = str_replace( $y_str, "%d", $skan_str );
     1749                                $skan_str       = str_replace( $x_str, "(?<x>\d+)", $skan_str );
     1750                                $skan_str       = str_replace( $y_str, "(?<y>\d+)", $skan_str );
    17471751                        }
    17481752                        else if( $x_present)
    17491753                        {
    1750                                 $skan_str       = str_replace( $x_str, "%d", $skan_str );
     1754                                $skan_str       = str_replace( $x_str, "(?<x>\d+)", $skan_str );
    17511755                        }
    17521756                        else if( $y_present)
    17531757                        {
    1754                                 $skan_str       = str_replace( $y_str, "%d", $skan_str );
     1758                                $skan_str       = str_replace( $y_str, "(?<y>\d+)", $skan_str );
    17551759                        }
    17561760
     
    17721776                                if( $x_present && $y_present )
    17731777                                {
    1774                                         if( $x_first )
    1775                                         {
    1776                                                 $n = sscanf( $hostname, $skan_str, $x, $y );
    1777                                         }
    1778                                         else if( $y_first )
    1779                                         {
    1780                                                 $n = sscanf( $hostname, $skan_str, $y, $x );
    1781                                         }
     1778                                        preg_match( $skan_str, $hostname, $matches );
    17821779
    17831780                                        // Remove nodes that don't match
    17841781                                        //
    1785                                         if( $n < 2 )
     1782                                        if( !array_key_exists( 'x', $matches ) && !array_key_exists( 'y', $matches ) )
    17861783                                        {
    17871784                                                // This node hostname has no match for: {x} and {y}
     
    17891786                                                unset( $nodes[$hostname] );
    17901787                                        }
     1788                                        else
     1789                                        {
     1790                                                $x      = $matches['x'];
     1791                                                $y      = $matches['y'];
     1792                                        }
    17911793                                }
    17921794                                else if( $x_present && !$y_present )
    17931795                                {
    1794                                         $n = sscanf( $hostname, $skan_str, $x );
     1796                                        preg_match( $skan_str, $hostname, $matches );
    17951797
    17961798                                        // Remove nodes that don't match
    17971799                                        //
    1798                                         if( $n < 1 )
     1800                                        if( !array_key_exists( 'x', $matches ) )
    17991801                                        {
    18001802                                                // This node hostname has no match for: {x}
     
    18021804                                                unset( $nodes[$hostname] );
    18031805                                        }
    1804                                         $y      = 1;
     1806                                        else
     1807                                        {
     1808                                                $x      = $matches['x'];
     1809                                                $y      = 1;
     1810                                        }
    18051811                                }
    18061812                                else if( $y_present && !$x_present )
    18071813                                {
    1808                                         $n = sscanf( $hostname, $skan_str, $y );
     1814                                        preg_match( $skan_str, $hostname, $matches );
    18091815
    18101816                                        // Remove nodes that don't match
    18111817                                        //
    1812                                         if( $n < 1 )
     1818                                        if( !array_key_exists( 'y', $matches ) )
    18131819                                        {
    18141820                                                // This node hostname has no match for: {y}
     
    18161822                                                unset( $nodes[$hostname] );
    18171823                                        }
    1818                                         $x      = 1;
     1824                                        else
     1825                                        {
     1826                                                $y      = $matches['y'];
     1827                                                $x      = 1;
     1828                                        }
    18191829                                }
    18201830
     
    19021912                        }
    19031913
    1904                         $image_width    = $x_offset + ($node_width * ($x_max-$x_min+2));
     1914                        //$image_width  = $x_offset + ($node_width * ($x_max-$x_min+2));
     1915                        $image_width    = $x_offset + ($node_width * (count($x_columns)));
    19051916
    19061917                        if( $this->isSmall() )
     
    20332044                                                if( $x_present && $y_present )
    20342045                                                {
    2035                                                         if( $x_first )
    2036                                                         {
    2037                                                                 $nn = sscanf( $host, $skan_str, $rx, $ry );
    2038                                                         }
    2039                                                         else if( $y_first )
    2040                                                         {
    2041                                                                 $nn = sscanf( $host, $skan_str, $ry, $rx );
    2042                                                         }
    2043                                                         if ( $nn < 2 )
     2046                                                        //if( $x_first )
     2047                                                        //{
     2048                                                        //      $nn = sscanf( $host, $skan_str, $rx, $ry );
     2049                                                        //}
     2050                                                        //else if( $y_first )
     2051                                                        //{
     2052                                                        //      $nn = sscanf( $host, $skan_str, $ry, $rx );
     2053                                                        //}
     2054                                                        //if ( $nn < 2 )
     2055                                                        //{
     2056                                                        //      //printf( "skipping node %s - y present & x present + <2 x,y matchs\n", $host);
     2057                                                        //      continue;
     2058                                                        //}
     2059
     2060                                                        preg_match( $skan_str, $host, $matches );
     2061                                                        $rx = $matches['x'];
     2062                                                        $ry = $matches['y'];
     2063
     2064                                                        if( !array_key_exists( 'x', $matches ) && !array_key_exists( 'y', $matches ) )
    20442065                                                        {
    20452066                                                                //printf( "skipping node %s - y present & x present + <2 x,y matchs\n", $host);
    20462067                                                                continue;
    20472068                                                        }
     2069
    20482070                                                        if( intval( $rx ) > $n )
    20492071                                                        {
     
    20632085                                                else if( $x_present )
    20642086                                                {
    2065                                                         $nn = sscanf( $host, $skan_str, $rx );
     2087                                                        //$nn = sscanf( $host, $skan_str, $rx );
     2088                                                        preg_match( $skan_str, $host, $matches );
     2089                                                        $rx = $matches['x'];
    20662090                                                }
    20672091                                                else if( $y_present )
    20682092                                                {
    2069                                                         $nn = sscanf( $host, $skan_str, $ry );
     2093                                                        //$nn = sscanf( $host, $skan_str, $ry );
     2094                                                        preg_match( $skan_str, $host, $matches );
     2095                                                        $ry = $matches['y'];
    20702096                                                }
    20712097
     
    24542480        if( $x_present && $y_present )
    24552481        {
    2456                 if( $x_first )
    2457                 {
    2458                         $n = sscanf( $a, $skan_str, $a_x, $a_y );
    2459                         $n = sscanf( $b, $skan_str, $b_x, $b_y );
    2460                 }
    2461                 else if( $y_first )
    2462                 {
    2463                         $n = sscanf( $a, $skan_str, $a_y, $a_x );
    2464                         $n = sscanf( $b, $skan_str, $b_y, $b_x );
    2465                 }
     2482                //if( $x_first )
     2483                //{
     2484                //      $n = sscanf( $a, $skan_str, $a_x, $a_y );
     2485                //      $n = sscanf( $b, $skan_str, $b_x, $b_y );
     2486                //}
     2487                //else if( $y_first )
     2488                //{
     2489                //      $n = sscanf( $a, $skan_str, $a_y, $a_x );
     2490                //      $n = sscanf( $b, $skan_str, $b_y, $b_x );
     2491                //}
     2492
     2493                preg_match( $skan_str, $a, $matches );
     2494                $a_x = $matches['x'];
     2495                $a_y = $matches['y'];
     2496                preg_match( $skan_str, $b, $matches );
     2497                $b_x = $matches['x'];
     2498                $b_y = $matches['y'];
    24662499        }
    24672500        else if( $x_present && !$y_present )
    24682501        {
    2469                 $n = sscanf( $a, $skan_str, $a_x );
    2470                 $n = sscanf( $b, $skan_str, $b_x );
     2502                //$n = sscanf( $a, $skan_str, $a_x );
     2503                //$n = sscanf( $b, $skan_str, $b_x );
     2504
     2505                preg_match( $skan_str, $a, $matches );
     2506                $a_x = $matches['x'];
     2507                preg_match( $skan_str, $b, $matches );
     2508                $b_x = $matches['x'];
    24712509        }
    24722510        else if( $y_present && !$x_present )
    24732511        {
    2474                 $n = sscanf( $a, $skan_str, $a_y );
    2475                 $n = sscanf( $b, $skan_str, $b_y );
     2512                //$n = sscanf( $a, $skan_str, $a_y );
     2513                //$n = sscanf( $b, $skan_str, $b_y );
     2514
     2515                preg_match( $skan_str, $a, $matches );
     2516                $a_y = $matches['y'];
     2517                preg_match( $skan_str, $b, $matches );
     2518                $b_y = $matches['y'];
    24762519        }
    24772520
     
    25262569                        }
    25272570                }
     2571                else if( !$y_present && !$x_present )
     2572                {
     2573                        if ($a < $b)
     2574                        {
     2575                                return 1;
     2576                        }
     2577                        else if ($a > $b)
     2578                        {
     2579                                return -1;
     2580                        }
     2581                }
    25282582        }
    25292583        else if ( $SORT_ORDER == "asc" )
     
    25732627                        }
    25742628                        else if ($a_y < $b_y)
     2629                        {
     2630                                return -1;
     2631                        }
     2632                }
     2633                else if( !$y_present && !$x_present )
     2634                {
     2635                        if ($a > $b)
     2636                        {
     2637                                return 1;
     2638                        }
     2639                        else if ($a < $b)
    25752640                        {
    25762641                                return -1;
Note: See TracChangeset for help on using the changeset viewer.