Changeset 167


Ignore:
Timestamp:
19/06/14 14:03:03 (6 years ago)
Author:
spascoe
Message:

Added an option to copy the configuration directory to a user-defined place where customisations can be applied.

Location:
CCCC/branches/branch-sp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CCCC/branches/branch-sp/README.txt

    r166 r167  
    1010python ceda_cc/c4.py -p <project> -d <directory>  ## check all files in directory 
    1111python ceda_cc/c4.py -p <project> -f <file>       ## check a single file. 
     12python ceda_cc/c4.py --copy-config <dest-dir>     ## copy the default configuration directory to <dest-dir> to enable customisation. 
    1213 
    1314Optional arguments: 
     
    2223  --flfmode <mode>      # set mode for file-level log file -- see log file modes 
    2324  --aMap                # Read in some attribute mappings and run tests with virtual substitutions, see also map2nco.py 
     25 
     26Environment variables: 
     27 
     28  CC_CONFIG_DIR  ## Set to the location of a custom configuration directory.  If unset the default configuration will be used. 
    2429 
    2530After running: 
     
    4449 2. If you have the setuptools package you can execute the following from the distribution directory: 
    4550    $ python setup.py install 
     51 
     52If you install ceda-cc in this way you can use the --copy-config command to export the default configuration into a directory where you can edit the configuration. 
     53 
    4654 
    4755Called from python: 
  • CCCC/branches/branch-sp/ceda_cc/c4.py

    r164 r167  
    22# Standard library imports 
    33import os, string, time, logging, sys, glob, pkgutil 
     4import shutil 
    45 
    56## pkgutil is used in file_utils 
     
    201202    self.holdExceptions = False 
    202203    forceLogOrg = None 
     204 
     205    # The --copy-config option must be the first argument if it is present. 
     206    if args[0] == '--copy-config': 
     207       args.pop(0) 
     208       dest_dir = args.pop(0) 
     209       config.copy_config(dest_dir) 
     210       print 'Configuration directory copied to %s.  Set CC_CONFIG_DIR to use this configuration.' % dest_dir 
     211       print 
     212       raise SystemExit(0) 
    203213 
    204214    while len(args) > 0: 
     
    498508 
    499509 
     510    
     511 
     512 
    500513def main_entry(): 
    501514   """ 
  • CCCC/branches/branch-sp/ceda_cc/config_c4.py

    r163 r167  
    33import os 
    44import os.path as op 
     5import shutil 
    56 
    67############################################################################## 
     
    1213 
    1314HERE = op.dirname(__file__) 
    14 CC_CONFIG_DIR = os.environ.get('CC_CONFIG_DIR', op.join(HERE, 'config')) 
     15CC_CONFIG_DEFAULT_DIR = op.join(HERE, 'config') 
     16CC_CONFIG_DIR = os.environ.get('CC_CONFIG_DIR', CC_CONFIG_DEFAULT_DIR) 
    1517 
    1618############################################################################## 
     
    344346 
    345347    ##assert self.project != 'CCMI', 'Not completely set up for CCMI yet' 
     348 
     349 
     350def copy_config(dest_dir): 
     351   """ 
     352   Copy the current default configuration directory into a separate directory. 
     353 
     354   The directory <ceda_cc-package-dir>/config is copied to `dest_dir`. 
     355   This is useful when ceda-cc is installed as a Python package and the user may 
     356   not know where the config directory is stored. 
     357 
     358   :param dest_dir: should be a path to a directory which does not yet exist.   
     359       The configuration directory will be copied to this path. 
     360 
     361   """ 
     362   shutil.copytree(CC_CONFIG_DEFAULT_DIR, dest_dir) 
Note: See TracChangeset for help on using the changeset viewer.