Difference between revisions of "Mas var"

From MCEWiki
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{hierarchy header}}
+
{{Related|MAS Applications}}
 
'''mas_var''' is a program for determining [[MAS]] configuration information (especially paths to scripts, data directories, and other configuration files).  It was developed to replace the environment-based approach that existed previously, especially for systems using [[Multicard MAS]] where more than one fibre card is in use.  mas_var queries the [[mas.cfg]] configuration file to get the system configuration.
 
'''mas_var''' is a program for determining [[MAS]] configuration information (especially paths to scripts, data directories, and other configuration files).  It was developed to replace the environment-based approach that existed previously, especially for systems using [[Multicard MAS]] where more than one fibre card is in use.  mas_var queries the [[mas.cfg]] configuration file to get the system configuration.
  
Line 34: Line 34:
 
                       specified, the commands output will remove all other MAS
 
                       specified, the commands output will remove all other MAS
 
                       variables from the environment.  Ignored if not used
 
                       variables from the environment.  Ignored if not used
                       with -c or -s, and when not running [[Multicard MAS]].
+
                       with -c or -s.
  
 
The parameters are:
 
The parameters are:
Line 44: Line 44:
 
   --config-dir      the location of the MCE config files (MAS_CONFIG in the
 
   --config-dir      the location of the MCE config files (MAS_CONFIG in the
 
                       environment)
 
                       environment)
   --config-file    the full path of the MAS configuration file
+
   --config-file    the full path of the default MAS configuration file
 
   --data-dir        the current data directory (MAS_DATA in theenvironment)
 
   --data-dir        the current data directory (MAS_DATA in theenvironment)
 
   --data-root      the root data directory (MAS_DATA_ROOT in the environment)
 
   --data-root      the root data directory (MAS_DATA_ROOT in the environment)
Line 55: Line 55:
 
   --hardware-file  the full path of the hardware configuration file
 
   --hardware-file  the full path of the hardware configuration file
 
   --idl-dir        the MCE script IDL directory (MAS_IDL in the environment)
 
   --idl-dir        the MCE script IDL directory (MAS_IDL in the environment)
 +
  --int-version    an integer SVN revsion number
 
   --jam-dir        the location of the JAM firmware files (MAS_JAM_DIR in the
 
   --jam-dir        the location of the JAM firmware files (MAS_JAM_DIR in the
 
                       environment)
 
                       environment)
Line 126: Line 127:
 
   /etc/mce/mas.cfg
 
   /etc/mce/mas.cfg
  
:(this is because the default mas.cfg path is hard-coded into the MAS library at build time to resolve the chicken-and-egg problem of having to read mas.cfg to determine the location of mas.cfg).
+
:(this is because a default mas.cfg path is hard-coded into the MAS library at build time to resolve the chicken-and-egg problem of having to read mas.cfg to determine the location of mas.cfg).  See also the [[MAS_MAS_CFG]] environmental variable.
  
 
* If -s is given, Bourne-compatible shell commands are printed for "regularising" the environment:
 
* If -s is given, Bourne-compatible shell commands are printed for "regularising" the environment:
Line 149: Line 150:
 
   export MAS_TEST_SUITE="/usr/mce/mce_script/test_suite";
 
   export MAS_TEST_SUITE="/usr/mce/mce_script/test_suite";
 
    
 
    
   export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/mce/bin:/usr/mce/mce_script/script:/usr/mce/mce_script/test_suite";
+
   export PATH="/usr/local/bin:/usr/bin:/bin:/usr/mce/bin:/usr/mce/mce_script/script:/usr/mce/mce_script/test_suite";
 
   export PYTHONPATH="/usr/mce/mce_script/python:/usr/mce/python";
 
   export PYTHONPATH="/usr/mce/mce_script/python:/usr/mce/python";
  
 
:Similarly, in the C Shell, -c can be used.  If MAS_... environmental variables are already defined, they will be left unchanged, simply repeated in the output, unless -e is also specified, telling mas_var to ignore the current environment.  In [[Multicard MAS]], if -x is specified along with -s or -c, only a minimal set of environmental variables will be set.  This can be advantageous in certain situations; see the discussion in [[Multicard MAS#Using Multicard MAS|Multicard MAS]] for details.
 
:Similarly, in the C Shell, -c can be used.  If MAS_... environmental variables are already defined, they will be left unchanged, simply repeated in the output, unless -e is also specified, telling mas_var to ignore the current environment.  In [[Multicard MAS]], if -x is specified along with -s or -c, only a minimal set of environmental variables will be set.  This can be advantageous in certain situations; see the discussion in [[Multicard MAS#Using Multicard MAS|Multicard MAS]] for details.
 +
 +
:Other points of interest:
 +
:* This output includes a definition of MAS_PREFIX in it's output, even though neither MAS nor the MCE scripts ever make use of it
 +
:* This output does ''not'' include a definition for [[MAS_MAS_CFG]], even though mas_var will consult it, if it is defined.
  
 
:These options (-s and -c) are most useful when mas_var is run inside back-ticks (`) and the output sent through eval to update the currently executing shell's environment; see below.
 
:These options (-s and -c) are most useful when mas_var is run inside back-ticks (`) and the output sent through eval to update the currently executing shell's environment; see below.
Line 170: Line 175:
 
=== Environment variables override the settings in mas.cfg ===
 
=== Environment variables override the settings in mas.cfg ===
  
Note that environment variables can be used to override the settings in mas.cfg -- this can be useful in cases where one would like to temporarily switch script trees or data directories:
+
Note that environment variables can be used to override the settings in mas.cfg -- this can be useful in cases where one would like to temporarily switch parts of an installation or the data directory:
  
 
  user@ubuntu:~$ mas_var --script-dir
 
  user@ubuntu:~$ mas_var --script-dir
Line 187: Line 192:
 
  user@ubuntu:~$ mas_var -e --script-dir
 
  user@ubuntu:~$ mas_var -e --script-dir
 
  /usr/mce/mce_script/script
 
  /usr/mce/mce_script/script
 +
 +
[[Category:MAS Applications]]

Latest revision as of 14:09, 12 September 2017

Related topics:
MAS

mas_var is a program for determining MAS configuration information (especially paths to scripts, data directories, and other configuration files). It was developed to replace the environment-based approach that existed previously, especially for systems using Multicard MAS where more than one fibre card is in use. mas_var queries the mas.cfg configuration file to get the system configuration.

Legacy, single fibre card installations may ignore the availability of mas_var, and simply use MAS_* environmental variables as before without issue. Multicard MAS users will find such an approach difficult.

For a more detailed discussion of environmental variables themselves, see the Environmental variables page.

Usage

Running mas_var without any options will produce a usage summary. In general, mas_var is invoked as:

mas_var [OPTION]... [PARAMETER]...

The options are:

  -c                print C shell commands for regularising the environment for
                      the specified (or default) MCE device. (See below for an
                      example of use.)
  -e                ignore any MAS_... environment variables.
  -m <file>         read MAS configuration from the specified file instead of
                      the default mas.cfg (the one reported by --config-file)
  -n <card>         report values for the specified fibre card.  Ignored if not
                      running Multicard MAS.
  -Q                quiet: don't write warnings.
  -q                instead of reporting the value on standard output, exit with
                      non-zero status if the first parameter is false, otherwise
                      exit with zero status.  Only makes sense with a boolean
                      parameter: all other parameters are implicitly true.
  -s                print Bourne-compatible shell commands for regularising the 
                      environment for the specified (or default) MCE device.
                      (See below for an example of use.)
  -x                when used with -c or -s, only define required environmental
                      variables, specifically: MAS_MCE_DEV, MAS_PREFIX, and
                      MAS_VAR, plus modified PATH and PYTHONPATH.  If -e is also
                      specified, the commands output will remove all other MAS
                      variables from the environment.  Ignored if not used
                      with -c or -s.

The parameters are:

  --bigphys         boolean; true if the driver supports bigphysarea
  --bin-dir         the location of the MAS binaries (MAS_BIN in the
                      environment)
  --cflags          cc(1) options needed to complile against the MAS libraries
  --config-dir      the location of the MCE config files (MAS_CONFIG in the
                      environment)
  --config-file     the full path of the default MAS configuration file
  --data-dir        the current data directory (MAS_DATA in theenvironment)
  --data-root       the root data directory (MAS_DATA_ROOT in the environment)
  --etc-dir         the directory containing the hardware description files
                      (MAS_ETC in the environment.)
  --experiment-file the full path of the experiment configuration file
  --fakemce         boolean; true if the driver contains the facemce device
  --fibre-card      the number of the current fibre card
  --group           the MAS group
  --hardware-file   the full path of the hardware configuration file
  --idl-dir         the MCE script IDL directory (MAS_IDL in the environment)
  --int-version     an integer SVN revsion number
  --jam-dir         the location of the JAM firmware files (MAS_JAM_DIR in the
                      environment)
  --libs            ld(1) options needed to link to the MAS libraries
  --mas-root        the base directory for the MCE script tree (MAS_ROOT
                      in the environment)
  --max-fibre-card  the maximum number of fibre cards supported
  --multicard       booelan; true if MAS supports multiple fibre cards
  --path[=PATHBASE] a shell PATH variable for MAS.  If given, MAS specific
                      directories will be appended to PATHBASE, otherwise they
                      will be appended to the current PATH.  (See also
                      --path-base below.)
  --path-base       the current PATH variable stripped of any directories which
                      start with the MAS prefix (see --prefix) or the MAS_ROOT
                      environment variable, if it is defined.  The value is
                      suitable for providing to --path.
  --prefix          the MAS prefix
  --pythonpath[=PATHBASE]
                    a PYTHONPATH variable for MAS.  If given, MAS specific
                      directories will be appended to PATHBASE, otherwise they
                      will be appended to the current PYTHONPATH.  (See also
                      --pythonpath-base below.)
  --pythonpath-base the current PYTHONPATH variable stripped of any directories
                      which start with the MAS prefix (see --prefix) or the
                      MAS_ROOT environment variable, if it is defined.  The
                      value is suitable for providing to --pythonpath.
  --python-dir      the MCE script python directory (MAS_PYTHON in the
                      environment)
  --script-dir      the MCE script directory (MAS_SCRIPT in the environment)
  --temp-dir        the MAS temporary directory (MAS_TEMP in the environment)
  --template-dir    the MAS template directory (MAS_TEMPLATE in the environment)
  --test-suite      the MAS test suite directory (MAS_TEST_SUITE in the
                      environment)
  --user            the MAS username
  --version         the mas_var version

Examples

  • Unless -q, -c, or -s is specified, mas_var will print the value of each parameter listed, one per line, in the order given on the command line:
 user@ubuntu:~$ mas_var --version --user --prefix --mas-root --data-dir
 MAS/trunk/739
 mce
 /usr/mce
 /usr/mce/mce_script
 /data/cryo/current_data
  • If -q is specified, mas_var prints nothing but exits with non-zero status if the first parameter is false. This only makes sense with boolean parameters (--bigphys or --fakemce):
 user@ubuntu:~$ mas_var --fakemce --bigphys
 False
 True
 user@ubuntu:-$ if mas_var -q --bigphys; then echo "Bigphys enabled"; else echo "Bigphys disabled"; fi
 Bigphys enabled
 user@ubuntu:-$ if mas_var -q --fakemce; then echo "FakeMCE present"; else echo "FakeMCE absent"; fi
 FakeMCE absent
  • If -m is used to specify a different mas.cfg file, results will change to reflect the different MAS configuration:
 user@ubuntu:~$ mas_var --etc-dir
 /etc/mce
 user@ubuntu:~$ grep etcdir ~/mas.cfg
 etcdir = "/usr/local/etc/mce";
 user@ubuntu:~$ mas_var -m ~/mas.cfg --etc-dir
 /usr/local/etc/mce
Perhaps surprisingly, the exception to this is the --config-file parameter (which reports the location of mas.cfg). It ignores -m completely and always reports the default mas.cfg location:
 user@ubuntu:~$ mas_var --config-file
 /etc/mce/mas.cfg
 user@ubuntu:~$ mas_var -m ~/mas.cfg --config-file
 /etc/mce/mas.cfg
(this is because a default mas.cfg path is hard-coded into the MAS library at build time to resolve the chicken-and-egg problem of having to read mas.cfg to determine the location of mas.cfg). See also the MAS_MAS_CFG environmental variable.
  • If -s is given, Bourne-compatible shell commands are printed for "regularising" the environment:
 user@ubuntu:~$ mas_var -s
 export MAS_VAR="/usr/mce/bin/mas_var";
 export MAS_MCE_DEV="0";
 export MAS_PREFIX="/usr/mce";
 export MAS_ROOT="/usr/mce/mce_script";
 
 export MAS_BIN="/usr/mce/bin";
 export MAS_CONFIG="/usr/mce/config";
 export MAS_JAM_DIR="/usr/mce/firmware";
 export MAS_TEMP="/tmp";
 export MAS_DATA_ROOT="/data/cryo";
 export MAS_DATA="/data/cryo/current_data";
 
 export MAS_IDL="/usr/mce/mce_script/idl_pro";
 export MAS_PYTHON="/usr/mce/mce_script/python";
 export MAS_SCRIPT="/usr/mce/mce_script/script";
 export MAS_TEMPLATE="/usr/mce/mce_script/template";
 export MAS_TEST_SUITE="/usr/mce/mce_script/test_suite";
 
 export PATH="/usr/local/bin:/usr/bin:/bin:/usr/mce/bin:/usr/mce/mce_script/script:/usr/mce/mce_script/test_suite";
 export PYTHONPATH="/usr/mce/mce_script/python:/usr/mce/python";
Similarly, in the C Shell, -c can be used. If MAS_... environmental variables are already defined, they will be left unchanged, simply repeated in the output, unless -e is also specified, telling mas_var to ignore the current environment. In Multicard MAS, if -x is specified along with -s or -c, only a minimal set of environmental variables will be set. This can be advantageous in certain situations; see the discussion in Multicard MAS for details.
Other points of interest:
  • This output includes a definition of MAS_PREFIX in it's output, even though neither MAS nor the MCE scripts ever make use of it
  • This output does not include a definition for MAS_MAS_CFG, even though mas_var will consult it, if it is defined.
These options (-s and -c) are most useful when mas_var is run inside back-ticks (`) and the output sent through eval to update the currently executing shell's environment; see below.

mas_var as a replacement for the MAS environment variables

The scripts and tuning programs no longer require that the $MAS_* environment variables be defined. Instead, they will run mas_var to determine the necessary paths, based on information in mas.cfg. If $MAS_VAR is defined, that is assumed to be the path to mas_var, otherwise /usr/mce/bin/mas_var is used.

The standard MAS environment variables can be set using mas_var

When running from the command line it is sometimes convenient to have the $MAS_* variables defined, and to update $PATH and $PYTHONPATH for the MAS software. To achieve this in bash, run:

eval `mas_var -e -s`

(note the back ticks). This line can be put in a user's .bashrc, to be run at login as a replacement for the older "source $MAS_ROOT/template/mas_env.bash".

Environment variables override the settings in mas.cfg

Note that environment variables can be used to override the settings in mas.cfg -- this can be useful in cases where one would like to temporarily switch parts of an installation or the data directory:

user@ubuntu:~$ mas_var --script-dir
/usr/mce/mce_script/script
user@ubuntu:~$ export MAS_SCRIPT=/home/user/code/mce_script/script
user@ubuntu:~$ mas_var --script-dir
/home/user/code/mce_script/script

Because the MCE scripts obtain paths through mas_var, the environmental override with be propagated to them as well.

The -e option disables this behaviour, making mas_var ignore the environment:

user@ubuntu:~$ export MAS_SCRIPT=/home/user/code/mce_script/script
user@ubuntu:~$ mas_var --script-dir
/home/user/code/mce_script/script
user@ubuntu:~$ mas_var -e --script-dir
/usr/mce/mce_script/script