예제 #1
0
        # at the end of the filename
        base_name = stack_filename[0].split('.exe')[0]
        exe = '{0}.exe'.format(base_name)
        import shutil
        if not os.path.isfile(base_name):
            shutil.copy2(exe, base_name)

try:
    import gooey
except ImportError:
    raise ImportError(
        'The GUI component is not installed, reinstall with `pip install -U panoptes_aggregation[gui]`'
    )

panoptes_aggregation.scripts.pbar_override(panoptes_aggregation.scripts.pbe)
panoptes_aggregation.scripts.pbar_override(panoptes_aggregation.scripts.pbr)
panoptes_aggregation.scripts.gui_override(gooey)

current_folder = os.path.dirname(os.path.abspath(__file__))

gui = gooey.Gooey(program_name="Aggregate",
                  default_size=(1000, 1150),
                  progress_regex=r"^[a-zA-Z:\s|]+ (\d+)% .+$",
                  terminal_font_family="Consolas",
                  navigation='TABBED',
                  image_dir=os.path.join(current_folder, 'icons'))(
                      panoptes_aggregation.scripts.parser_main)

if __name__ == '__main__':
    gui()
예제 #2
0
def AutoGooey(fn):  # pragma: no cover
    """Automatically show a Gooey GUI if --gui is passed as the first argument, else it will just run the function as normal"""
    if check_gui_arg():
        return gooey.Gooey(fn)
    else:
        return fn
예제 #3
0
def gooey_main():
    import gooey
    gooey.Gooey(program_name="NiceShare GUI", )(main)(use_gooey=True)
예제 #4
0
 def ezgooey(*args, **kwargs):
     return gooey.Gooey(*args, **kwargs)
예제 #5
0
    parser_c = subparser.add_parser(
        "ccdft",
        help="Condensed Conceptual DFT.",
        description=description_condensed,
        formatter_class=RawDescriptionHelpFormatter,
    )
    parse_args_condensed(parser_c)

    return parser.parse_args()


def main():
    """Entry point function for Chemtools."""
    arg = parse_args_chemtools()  # parse all variables for each functions
    main_fun = SCRIPT_MAIN[arg.command]  # call the main executable function
    main_fun(arg)  # run the function


if __name__ == "__main__":
    import logging

    try:
        import gooey

        # this is command is equivalent to use decorator
        gooey.Gooey(main)()
    except ImportError:
        logging.warning(
            "Package 'gooey' is needed for GUI command-line tools. Please"
            " install\nit with your package manager.")
예제 #6
0
def main():
    try:
        import gooey
    except ImportError:
        gooey = None
        print("INFO: Failed to import Gooey (GUI disabled)")

    def flex_add_argument(f):
        """Make the add_argument accept (and ignore) the widget option."""
        def f_decorated(*args, **kwargs):
            kwargs.pop('widget', None)
            kwargs.pop('gooey_options', None)
            return f(*args, **kwargs)

        return f_decorated

    # Monkey-patching a private class…
    argparse._ActionsContainer.add_argument = flex_add_argument(
        argparse.ArgumentParser.add_argument)

    # Do not run GUI if it is not available or if command-line arguments are given.
    if gooey is None or len(sys.argv) > 1:
        ArgumentParser = argparse.ArgumentParser

        def gui_decorator(f):
            return f
    else:
        print('Using Gooey')
        ArgumentParser = gooey.GooeyParser
        gui_decorator = gooey.Gooey(
            program_name='Audio splicer',
            progress_regex=r"(\d+)%",
            navigation='TABBED',
            suppress_gooey_flag=True,
        )
        # in gooey mode, --force is always set
        sys.argv.append('--force')

    @gui_decorator
    def get_parser():
        parser = ArgumentParser(
            description=
            'Given a single sound file, tries to split it to segments.'
            'This is a preprocessing step for speech datasets (specifically LibriSpeech).'
            'It can split on silences or using a subtitles file. And will generate a ".trans.txt" file.'
            'Gooey GUI is used if it is installed and no arguments are passed.',
            formatter_class=argparse.ArgumentDefaultsHelpFormatter)

        parser.add_argument('-i',
                            metavar='INPUT_AUDIO',
                            type=Path,
                            widget='FileChooser',
                            nargs='+',
                            gooey_options={
                                'validator': {
                                    'test': 'user_input != None',
                                    'message': 'Choose a valid file path'
                                }
                            },
                            help='audio file input path')
        parser.add_argument(
            '-o',
            metavar='OUT_FOLDER',
            type=Path,
            widget='DirChooser',
            default='{INPUT}/splits-{METHOD}',
            gooey_options={
                'validator': {
                    'test': 'user_input != None',
                    'message': 'Choose a valid directory path'
                }
            },
            help='output directory path. '
            '{INPUT} means the input directory. '
            '{METHOD} means "sil" (silences), or "sub" (subtitles)')
        parser.add_argument(
            '--n_procs',
            default=cpu_count(),
            type=int,
            help='Multiprocessing concurrency level (best to leave at default).'
        )
        parser.add_argument(
            '--samplerate',
            default=0,
            type=int,
            help=
            'Assert target samplerate. If 0 then any samplerate is allowed.')
        # the action: either split based on .rst file, or split based on audio only
        group_subtitles = parser.add_argument_group('Subtitles')
        # read .rst file
        group_subtitles.add_argument(
            '-b',
            '--subtitles',
            metavar='SUBTITLES_FILE',
            type=Path,
            widget='FileChooser',
            gooey_options={
                'validator': {
                    'test': 'user_input != None',
                    'message': 'Choose a valid path'
                }
            },
            help=
            'split audio based on subtitle times from the passed .rst/.ass file'
            'If not passed, will split words based on silences. '
            'Can specify --min_silence_len and --silence_thresh')
        group_subtitles.add_argument(
            '--subtitle_end_offset',
            default=100,
            type=int,
            help='add delay at end of subtitle dialogue (milliseconds). '
            'If the audio segments say more than the text, then make this smaller. '
        )

        group_subtitles.add_argument(
            '--subtitle_rescale',
            default=1.0,
            type=float,
            help='rescale the timings if the audio was rescaled (stretched).'
            'Example1: If subtitle_rescale=2, then it will finish in half the original time.'
            'Example2: If the subtitle dialogues are ahead (appear earlier) of the audio, increase subtitle_rescale.'
        )

        group_silences = parser.add_argument_group('Silences')
        group_silences.add_argument(
            '-sl',
            '--min_silence_len',
            default=700,
            type=int,
            help=
            'must be silent for at least MIN_SILENCE_LEN (ms) to count as a silence. '
        )
        group_silences.add_argument(
            '-st',
            '--silence_thresh',
            default=-50,
            type=float,
            help='consider it silent if quieter than SILENCE_THRESH dBFS. ')

        parser.add_argument('--min_len',
                            default=6000,
                            type=int,
                            help='minimum length for each segment in ms. ')
        parser.add_argument('--max_len',
                            default=13000,
                            type=int,
                            help='maximum length for each segment in ms. ')

        parser.add_argument(
            '--out_fmt',
            metavar='FILE_EXT',
            default='',
            help=
            'output file extension {"", mp3, wav, flac, ...}. Empty means same as input'
        )

        parser.add_argument('-f',
                            '--force',
                            action='store_true',
                            help='Overwrite if output already exists')
        return parser

    parser = get_parser()

    try:
        import argcomplete
        argcomplete.autocomplete(parser)
    except:
        print("INFO: failed to import `argcomplete` lib")

    args = parser.parse_args(sys.argv[1:])

    # expand directory
    input_dir = args.i[0]
    if len(args.i) == 1 and input_dir.is_dir():
        args.i = list(input_dir.rglob('*.mp3'))
        assert len(args.i) > 0, 'No mp3 files found in input directory:'
        print('input is a folder, found mp3 files:', args.i)

    try:
        # noinspection PyUnresolvedReferences
        from argutils import print_args

        print_args(args)
    except:
        pass

    # make args for each input file
    args_list = []
    for i in args.i:
        args_clone = deepcopy(args)
        args_clone.i = i
        args_clone.child = len(args.i) > 1
        args_list.append(args_clone)

    n_procs = args.n_procs
    ret_codes = list(Pool(n_procs).map(go, args_list))

    return max(ret_codes)
예제 #7
0
    #from gooey import Gooey, GooeyParser
except ImportError:
    gooey = None


#from  eclometer.interfaces.util import floatRange, IntRange, jsonLoadFromFile
import sys
import string
import serial.tools.list_ports 

gui_decorator = gooey.Gooey( #target=runECL.runTest,     # Explicitly set the subprocess executable arguments
                            program_name="LTU ECLometer (Version 0.0.2)", 
                            default_size=(1050, 680),   # starting size of the GUI
                            dump_build_config=False,   # Dump the JSON Gooey uses to configure itself
                            load_build_config=None,    # Loads a JSON Gooey-generated configuration
                            monospace_display=False,     # Uses a mono-spaced font in the output screen
                            tabbed_groups=True,
                            navigation='Tabbed',
                            # poll_external_updates=True   # seems to be buggy, at least on osx
                            use_cmd_args = True,         # Substitute any command line arguments provided at run time for the default values specified in the Gooey configuration
                            #suppress_gooey_flag=True,
                            )
    

def flex_add_argument(f):
    '''Make the add_argument accept (and ignore) the widget, metavar and gooey_options option.
       Based on suggestion by KrzysiekJ at https://github.com/chriskiehl/Gooey/issues/296#issuecomment-642115493
    '''
    def f_decorated(*args, **kwargs):
        kwargs.pop('widget', None)
        kwargs.pop('metavar', None)
        kwargs.pop('gooey_options', None)