コード例 #1
0
ファイル: argparser.py プロジェクト: TomekTrzeciak/improver
 def parse_args(self, args=None, namespace=None):
     """Wrap in order to implement some compulsory behaviour."""
     args = super(ArgParser, self).parse_args(args=args,
                                              namespace=namespace)
     if hasattr(args, 'profile') and (args.profile or args.profile_file):
         profile_hook_enable(dump_filename=args.profile_file)
     return args
コード例 #2
0
ファイル: __init__.py プロジェクト: woodsouth/improver
def main(prog_name: parameters.pass_name,
         command: LAST_OPTION,
         *args,
         profile: value_converter(lambda _: _, name='FILENAME') = None,
         memprofile: value_converter(lambda _: _, name='FILENAME') = None,
         verbose=False,
         dry_run=False):
    """IMPROVER NWP post-processing toolbox

    Results from commands can be passed into file-like arguments
    of other commands by surrounding them by square brackets::

        improver command [ command ... ] ...

    Spaces around brackets are mandatory.

    Args:
        prog_name:
            The program name from argv[0].
        command (str):
            Command to execute
        args (tuple):
            Command arguments
        profile (str):
            If given, will write profiling to the file given.
            To write to stdout, use a hyphen (-)
        memprofile (str):
            Creates 2 files, a tracemalloc snapsot at the point of
            highest memory consumption of your program (*_SNAPSHOT)
            and a track of the maximum memory used by your program
            over time (*_MAX_TRACKER).
        verbose (bool):
            Print executed commands
        dry_run (bool):
            Print commands to be executed

    See improver help [--usage] [command] for more information
    on available command(s).
    """
    args = unbracket(args)
    exec_cmd = execute_command
    if profile is not None:
        from improver.profile import profile_hook_enable
        profile_hook_enable(dump_filename=None if profile == '-' else profile)
    if memprofile is not None:
        from improver.memprofile import memory_profile_decorator
        exec_cmd = memory_profile_decorator(exec_cmd, memprofile)
    result = exec_cmd(SUBCOMMANDS_DISPATCHER, prog_name, command,
                      *args, verbose=verbose, dry_run=dry_run)
    return result
コード例 #3
0
ファイル: __init__.py プロジェクト: thbom001/improver
def main(prog_name: parameters.pass_name,
         command: LAST_OPTION,
         *args,
         profile: value_converter(lambda _: _, name='FILENAME') = None,
         verbose=False,
         dry_run=False):
    """IMPROVER NWP post-processing toolbox

    Results from commands can be passed into file-like arguments
    of other commands by surrounding them by square brackets::

        improver command [ command ... ] ...

    Spaces around brackets are mandatory.

    Args:
        prog_name:
            The program name from argv[0].
        command (str):
            Command to execute
        args (tuple):
            Command arguments
        profile (str):
            If given, will write profiling to the file given.
            To write to stdout, use a hyphen (-)
        verbose (bool):
            Print executed commands
        dry_run (bool):
            Print commands to be executed

    See improver help [--usage] [command] for more information
    on available command(s).
    """
    args = unbracket(args)
    if profile is not None:
        from improver.profile import profile_hook_enable
        profile_hook_enable(dump_filename=None if profile == '-' else profile)
    result = execute_command(SUBCOMMANDS_DISPATCHER,
                             prog_name,
                             command,
                             *args,
                             verbose=verbose,
                             dry_run=dry_run)
    return result