コード例 #1
0
def run_from_c(*args, **kwargs):
    """ Execute the 1D mesh generation using passed parameters from c++

    The '*args' argument contains the directory to write the log file.
    """
    output_dir = args[0]
    init_logging(output_dir)
    msg = "Status: OK\n"

    try:
        result = run(**kwargs)
        msg += result
    except Exception as e:
        logger.error(str(e))
        msg = "Status: Error\n"
        msg += "Error: " + str(e) + "\n"

    ## Attach log file to returned result.
    #
    msg += "Log:\n"
    log_file_name = path.join(output_dir, get_log_file_name())

    with open(log_file_name, 'r') as file:
        msg += file.read()

    return msg
コード例 #2
0
def crun(*args, **kwargs):
    init_logging()
    print("-------- crun -------")
    print(">>> output dir: ", args[0])
    msg = "staus:ok\n"
    try:
        run(**kwargs)
    except Exception as e:
        msg = "status:error\n"
        msg += "exception:" + str(e) + "\n"

    open("generate_1d_mesh.log", "r");
    with open('generate_1d_mesh.log', 'r') as file:
        msg += file.read()

    return msg
コード例 #3
0
ファイル: slice-image.py プロジェクト: ktbolt/cardiovascular
        logger.info("Path file: %s" % params.path_file_name)
        if not os.path.exists(params.path_file_name):
            logger.error("The path file '%s' was not found." % params.path_file_name)
            return None

    if kwargs.get(Args.HEADER_FILE):
        params.header_file_name = kwargs.get(Args.HEADER_FILE)
        logger.info("Header file: %s" % params.header_file_name)
        if not os.path.exists(params.header_file_name):
            logger.error("The heaer file '%s' was not found." % params.header_file_name)
            return None

    return params

if __name__ == '__main__':
    init_logging()
    args, print_help = parse_args()
    params = set_parameters(**vars(args))
    if not params:
        logger.error("Error in parameters.")
        sys.exit(1)

    # Create graphics interface.   
    graphics = Graphics()

    # Read header file.
    header = Header.read_header_file(params)

    # Read in the volume image.
    image = Image(params)
    image.graphics = graphics