Exemple #1
0
def nose_main(args, test_config):
    """
    This function provides an alternative to main() that is more friendly for 
    nose tests as it doesn't catch any exceptions.
    
    Required Arguments:
        
        args
            The args to pass to lay_cement
        
        test_config
            A test config to pass to lay_cement
    
    Usage:
    
    .. code-block:: python
    
        from iustools.core.appmain import nose_main
        from iustools.core.config import get_nose_config
        
        args = [__file__, 'nosetests', '--quiet']
        (res_dict, output_text) = nose_main(args, get_nose_config())
        
    """
    
    lay_cement(config=test_config, banner=BANNER, args=args)
    log = get_logger(__name__)
    log.debug("Cement Framework Initialized!")

    if not len(args) > 1:
        args.append('default')

    (res, output_txt) = run_command(args[1])
    return (res, output_txt)
Exemple #2
0
def main():
    try:
        ensure_api_compat(__name__, REQUIRED_CEMENT_API)    
        lay_cement(config=default_config, banner=BANNER)
    
        log = get_logger(__name__)
        log.debug("Cement Framework Initialized!")

        if not len(sys.argv) > 1:
            sys.argv.append('default')

        config = get_config()
        
        # create the lock file
        if os.path.exists(config['lockfile']):
            raise SatCLIRuntimeError, \
                "lock file exists, is satcli already running?"
        else:
            f = open(config['lockfile'], 'w+')
            f.write(get_timestamp())
            f.close()

        run_command(sys.argv[1])
            
    except CementArgumentError, e:
        print("CementArgumentError > %s" % e)
        sys.exit(e.code)
Exemple #3
0
def nose_main(args, test_config):
    """
    This function provides an alternative to main() that is more friendly for 
    nose tests as it doesn't catch any exceptions.
    """

    lay_cement(config=test_config, banner=BANNER, args=args)
    log = get_logger(__name__)
    log.debug("Cement Framework Initialized!")

    if not len(args) > 1:
        args.append('default')

    (res, output_txt) = run_command(args[1])
    return (res, output_txt)
Exemple #4
0
def nose_main(args, test_config):
    """
    This function provides an alternative to main() that is more friendly for 
    nose tests as it doesn't catch any exceptions.
    """

    lay_cement(config=test_config, banner=BANNER, args=args)
    log = get_logger(__name__)
    log.debug("Cement Framework Initialized!")

    if not len(args) > 1:
        args.append('default')

    (res, output_txt) = run_command(args[1])
    return (res, output_txt)
Exemple #5
0
def main(args=None):
    try:
        lay_cement(config=default_config, banner=BANNER, args=args)

        log = get_logger(__name__)
        log.debug("Cement Framework Initialized!")

        if not len(sys.argv) > 1:
            sys.argv.append('default')

        run_command(sys.argv[1])

    except CementArgumentError, e:
        # Display the apps exception names instead for the Cement exceptions.
        print("CementTestArgumentError > %s" % e)
        sys.exit(e.code)
Exemple #6
0
def main(args=None):
    try:    
        lay_cement(config=default_config, banner=BANNER, args=args)
    
        log = get_logger(__name__)
        log.debug("Cement Framework Initialized!")

        if not len(sys.argv) > 1:
            sys.argv.append('default')
        
        run_command(sys.argv[1])
            
    except CementArgumentError, e:
        # Display the apps exception names instead for the Cement exceptions.
        print("CementTestArgumentError > %s" % e)
        sys.exit(e.code)
Exemple #7
0
def main(args=None):
    try:
        if not args:
            args = sys.argv
            
        lay_cement(config=default_config, banner=BANNER, args=args, 
                   version=VERSION)
    
        log = get_logger(__name__)
        log.debug("Cement Framework Initialized!")

        if not len(args) > 1:
            args.append('default')
        
        run_command(args[1])
            
    except MFConfigError, e:
        print("MFConfigError > %s" % e)
        sys.exit(e.code)
Exemple #8
0
def main():
    ensure_abi_compat(__name__, REQUIRED_CEMENT_ABI)
    
    # Warning: You shouldn't modify below this point unless you know what 
    # you're doing.
    
    lay_cement(default_config, version_banner=BANNER)
    
    log = get_logger(__name__)
    log.debug("Cement Framework Initialized!")
    
    # react to the passed command.  command should be the first arg always
    try:
        if not len(sys.argv) > 1:
            raise CementArgumentError, "A command is required. See --help?"
        
        run_command(sys.argv[1])
            
    except CementArgumentError, e:
        print("CementArgumentError > %s" % e)