示例#1
0
def parse_args():
    settings_msg = 'Bring torrents from one Gazelle instance to another'
    parser = GooeyParser(description=settings_msg)

    # --from <>
    parser.add_argument('--from',
                        choices=trackers,
                        required=True,
                        help="torrents from which Gazelle instance")

    # -to <>
    parser.add_argument("--to",
                        choices=trackers,
                        required=True,
                        help="sync to which Gazelle instance")

    # --album <> / --folder <>
    group = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 0})
    group.add_argument("--album",
                       help="the folder of the album",
                       widget="DirChooser")
    group.add_argument(
        "--folder",
        help=
        "the folder that contauins all albums. The album folder will be extracted from the site metadata",
        widget="DirChooser")

    # --tid <> / --link <> / --tpath <> / --tfolder <>
    group = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 0})
    group.add_argument(
        "--link",
        help="the whole permalinlk. The tool os smart enough to extract it")
    group.add_argument("--tid", help="the torrent ID")
    group.add_argument(
        "--tpath",
        help=
        "the path that points towards the .torrent file. The infohash will be computed",
        widget="FileChooser")
    group.add_argument("--tfolder",
                       help="the folder containing all the .torrent files",
                       widget="DirChooser")

    parser.add_argument(
        '-c',
        '--config',
        metavar='FILE',
        default=os.path.join(application_path, 'config.cfg'),
        help='config file with login details (default: config.cfg)',
        widget="FileChooser")

    return parser.parse_args()
示例#2
0
def arbitrary_function():
  desc = "Example application to show Gooey's various widgets"
  file_help_msg = "Name of the file you want to process"
  my_cool_parser = GooeyParser(description=desc)
  # my_cool_parser.add_argument("FileChooser", help=file_help_msg, widget="FileChooser")   # positional
  # my_cool_parser.add_argument("DirectoryChooser", help=file_help_msg, widget="DirChooser")   # positional
  # my_cool_parser.add_argument("FileSaver", help=file_help_msg, widget="FileSaver")   # positional
  # my_cool_parser.add_argument("MultiFileSaver", help=file_help_msg, widget="MultiFileChooser")   # positional
  # my_cool_parser.add_argument("directory", help="Directory to store output")          # positional

  my_cool_parser.add_argument('-c', '--countdown', default=2, type=int, help='sets the time to count down from you see its quite simple!')
  my_cool_parser.add_argument('-j', '--cron-schedule', type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
  my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
  my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
  my_cool_parser.add_argument('-v', '--verbose', action='count')
  my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
  my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
  my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
  my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
  verbosity = my_cool_parser.add_mutually_exclusive_group()
  verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
  print my_cool_parser._actions
  print 'inside of main(), my_cool_parser =', my_cool_parser

  args = my_cool_parser.parse_args()
  main(args)
示例#3
0
def main():
    desc = "Example application to show Gooey's various widgets"
    my_cool_parser = GooeyParser(description=desc)
    my_cool_parser.add_argument("Example", help="fill ",
                                widget="FileChooser")  # positional
    verbosity = my_cool_parser.add_mutually_exclusive_group()
    verbosity.add_argument('-t',
                           '--verbozze',
                           dest='verbose',
                           action="store_true",
                           help="Show more details")
    verbosity.add_argument('-q',
                           '--quiet',
                           dest='quiet',
                           action="store_true",
                           help="Only output on error")
    print my_cool_parser._actions
    print 'inside of main(), my_cool_parser =', my_cool_parser

    args = my_cool_parser.parse_args()
    print sys.argv
    print args.countdown
    print args.showtime

    start_time = _time()
    print 'Counting down from %s' % args.countdown
    while _time() - start_time < args.countdown:
        if args.showtime:
            print 'printing message at: %s' % _time()
        else:
            print 'printing message at: %s' % hashlib.md5(str(
                _time())).hexdigest()
        _sleep(.5)
    print 'Finished running the program. Byeeeeesss!'
示例#4
0
def opt_model(parser: GooeyParser = GooeyParser()):
    model_option = parser.add_mutually_exclusive_group()
    model_option.add_argument(
        "--model-vgg",
        type=str,
        choices=model_vgg,
        metavar='VGGNet',
    )
    model_option.add_argument(
        "--model-res",
        type=str,
        choices=model_res,
        metavar='ResNet',
    )
    model_option.add_argument(
        "--model-des",
        type=str,
        choices=model_dense,
        metavar='DenseNet',
    )
    model_option.add_argument(
        "--model-squ",
        type=str,
        choices=model_squeeze,
        metavar='SqueezeNet',
    )
    model_option.add_argument(
        "--model-oth",
        type=str,
        choices=model_others,
        metavar='Ohter Networks',
    )
示例#5
0
def opt_device(parser: GooeyParser = GooeyParser()):
    device_option = parser.add_mutually_exclusive_group()
    device_option.add_argument(
        "--cpu",
        metavar="CPU",
        action='store_true',
    )

    n_gpus = torch.cuda.device_count()
    available_gpu_text = 'Available GPU number: '
    for i in range(n_gpus):
        available_gpu_text += str(i) + ' '

    device_option.add_argument(
        "--gpu",
        type=str,
        help=available_gpu_text,
        metavar="GPU",
        gooey_options={
            'validator': {
                'test':
                'all([e.isdigit() for e in user_input.replace(" ","").split(",")])',
                'message': 'Gpu device number must be positive integer.'
            }
        })
示例#6
0
def main():
  desc = "Example application to show Gooey's various widgets"
  file_help_msg = "Name of the file you want to process"
  my_cool_parser = GooeyParser(description=desc)
  my_cool_parser.add_argument("FileChooser", help=file_help_msg, widget="FileChooser")   # positional
  # my_cool_parser.add_argument("DirectoryChooser", help=file_help_msg, widget="DirChooser")   # positional
  # my_cool_parser.add_argument("FileSaver", help=file_help_msg, widget="FileSaver")   # positional
  my_cool_parser.add_argument("MultiFileSaver", help=file_help_msg, widget="MultiFileChooser")   # positional
  # my_cool_parser.add_argument("directory", help="Directory to store output")          # positional

  my_cool_parser.add_argument('-d', '--duration', default=2, type=int, help='Duration (in seconds) of the program output')
  my_cool_parser.add_argument('-s', '--cron-schedule', type=int, help='datetime when the cron should begin', widget='DateChooser')
  my_cool_parser.add_argument("-c", "--showtime", action="store_true", help="display the countdown timer")
  my_cool_parser.add_argument("-p", "--pause", action="store_true", help="Pause execution")
  my_cool_parser.add_argument('-v', '--verbose', action='count')
  my_cool_parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite output file (if present)")
  my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
  my_cool_parser.add_argument("-w", "--writelog", default="writelogs", help="Dump output to local file")
  my_cool_parser.add_argument("-e", "--error", action="store_true", help="Stop process on error (default: No)")
  verbosity = my_cool_parser.add_mutually_exclusive_group()
  verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")

  args = my_cool_parser.parse_args()
  display_message()
示例#7
0
def main():
    # Retrieve current working directory (`cwd`)
    cwd = os.getcwd()
    cwd

    # Change directory 
    # os.chdir("/home/rene/Proyectos/Validacion_Python")

    # List all files and directories in current directory
    print(os.listdir('.'))
    desc = "Aplicación que genera hojas de validación de nómina"
    file_help_msg = "Elige el archivo de la quincena a validar"

    my_cool_parser = GooeyParser(description=desc)
    my_cool_parser.add_argument("FileChooser", help=file_help_msg, widget="FileChooser")
    verbosity = my_cool_parser.add_mutually_exclusive_group()
    verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Mostrar más detalles")
    verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Sólo muestra salida en error")

    args = my_cool_parser.parse_args()
    # display_message()

    def here_is_smore():
        pass
    # Load in the workbook
    wb = load_workbook(input("Archivo: "))

    # Get sheet names
    print(wb.sheetnames)
示例#8
0
    def test_required_not_enforced(self):
        parser = GooeyParser()
        ArgumentParser.original_parse_args = ArgumentParser.parse_args

        parser.add_argument('--arg', type=int, required=True)
        parser.add_argument('--argn', type=int, nargs='+')
        parser.add_argument('argp', type=int)
        mutex = parser.add_mutually_exclusive_group(required=True)
        mutex.add_argument('--one', action='store_true')
        mutex.add_argument('--two', action='store_true')

        # No error when we don't provide required arguments
        cmd_args.parse_cmd_args(parser)

        # Test that required/argn have been restored in parser
        argrequired = next(action for action in parser._actions
                           if action.dest == 'arg').required
        self.assertEqual(argrequired, True)
        argnnargs = next(action for action in parser._actions
                         if action.dest == 'argn').nargs
        self.assertEqual(argnnargs, '+')
        argpnargs = next(action for action in parser._actions
                         if action.dest == 'argp').nargs
        self.assertEqual(argpnargs, None)
        mutexrequired = next(
            mutex for mutex in parser._mutually_exclusive_groups).required
        self.assertEqual(mutexrequired, True)
示例#9
0
def main():
  desc = "Example application to show Gooey's various widgets"
  file_help_msg = "Name of the file you want to process"
  my_cool_parser = GooeyParser(description=desc)
  my_cool_parser.add_argument("FileChooser", help=file_help_msg, widget="FileChooser")   # positional
  my_cool_parser.add_argument("DirectoryChooser", help=file_help_msg, widget="DirChooser")   # positional
  my_cool_parser.add_argument("FileSaver", help=file_help_msg, widget="FileSaver")   # positional
  my_cool_parser.add_argument("MultiFileSaver", help=file_help_msg, widget="MultiFileChooser")   # positional
  my_cool_parser.add_argument("MultiDirChooser", help=file_help_msg, widget="MultiDirChooser")   # positional
  my_cool_parser.add_argument("directory", help="Directory to store output")          # positional

  my_cool_parser.add_argument('-d', '--duration', default=2, type=int, help='Duration (in seconds) of the program output')
  my_cool_parser.add_argument('-s', '--cron-schedule', type=int, help='datetime when the cron should begin', widget='DateChooser')
  my_cool_parser.add_argument("-c", "--showtime", action="store_true", help="display the countdown timer")
  my_cool_parser.add_argument("-p", "--pause", action="store_true", help="Pause execution")
  my_cool_parser.add_argument('-v', '--verbose', action='count')
  my_cool_parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite output file (if present)")
  my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
  my_cool_parser.add_argument("-w", "--writelog", default="writelogs", help="Dump output to local file")
  my_cool_parser.add_argument("-e", "--error", action="store_true", help="Stop process on error (default: No)")
  verbosity = my_cool_parser.add_mutually_exclusive_group()
  verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")

  args = my_cool_parser.parse_args()
  display_message()
示例#10
0
def param_parser():
    main_parser=GooeyParser(description="Generate GCP report")
    main_parser.add_argument("inputfolder", metavar="Input Folder", widget="DirChooser", help="Select input las/laz folder", default="")
    main_parser.add_argument("-genreport", metavar="Generate Only Report", help=" **You can select this if you allready have the 'CGP_<tilename>_result.txt' files generated\n  Please select the appropriate 'method used' and the 'GCP Control File Has index ?' option\n used to generate the files", action="store_true")
    main_parser.add_argument("filepattern",metavar="Input File Pattern", help="Provide a file pattern seperated by ';' for multiple patterns \nex: (*.laz) or (123*_456*.laz; 345*_789*.laz )", default='*.laz')
    main_parser.add_argument("filetype",metavar="Input File Type", help="Select input file type", choices=['las', 'laz', 'txt'], default='laz') 
    main_parser.add_argument("outputpath", metavar="Output Directory",widget="DirChooser", help="Output directory", default='')
    main_parser.add_argument("tilelayoutfile", metavar="TileLayout file", widget="FileChooser", help="Select TileLayout file (.json)", default='')
    main_parser.add_argument("--buffer",metavar="Buffer", help="Provide buffer", type=int, default=200)
    main_parser.add_argument("control", metavar="Control file", widget="FileChooser", help="Select the GCP height control file")

    main_parser.add_argument("projname", metavar="Project Name", default='')
    main_parser.add_argument('areaname', metavar="Area Name", default='')
    main_parser.add_argument('deltax', metavar="x shift", default=0, type=float)
    main_parser.add_argument('deltay', metavar="y shift", default=0, type=float)
    main_parser.add_argument("armse", metavar="Standard Deviation for filtering", help="The report status will be Not Accepted if value greater than the value provided", type=float)

    technique = main_parser.add_mutually_exclusive_group("Select method to use")
    technique.add_argument('-tin', '--tinmethod', dest='PointTin',
                           action="store_true", help="Use Point to Tin method (Must have ground classfication done before running this method)")
    technique.add_argument('-p', '--pointstat', dest='PatchStats',
                           action="store_true", help="Use Statistical/average elevation Method")
    main_parser.add_argument("--radius", metavar="Radius for Surface avarage", default=2.0, type=float)
    main_parser.add_argument("--hasindex", metavar="GCP Control file Has Index?", action= "store_true")
    main_parser.add_argument("--gndclass", metavar="Ground Classes", default='2 8')

    main_parser.add_argument("--cores", metavar="General", help="Number of cores to be used for tiling process", type=int, default=4, gooey_options={
            'validator': {
                'test': '2 <= int(user_input) <= 14',
                'message': 'Must be between 2 and 14'
            }})
    return main_parser.parse_args()
示例#11
0
def arbitrary_function():
  desc = "Example application to show Gooey's various widgets"
  file_help_msg = "Name of the file you want to process"
  my_cool_parser = GooeyParser(description=desc)
  my_cool_parser.add_argument("FileChooser", help=file_help_msg, widget="FileChooser")   # positional
  my_cool_parser.add_argument("DirectoryChooser", help=file_help_msg, widget="DirChooser")   # positional
  my_cool_parser.add_argument("FileSaver", help=file_help_msg, widget="FileSaver")   # positional
  my_cool_parser.add_argument("MultiFileSaver", help=file_help_msg, widget="MultiFileChooser")   # positional
  my_cool_parser.add_argument("directory", help="Directory to store output")          # positional

  my_cool_parser.add_argument('-c', '--countdown', default=2, type=int, help='sets the time to count down from you see its quite simple!')
  my_cool_parser.add_argument('-j', '--cron-schedule', type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
  my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
  my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
  my_cool_parser.add_argument('-v', '--verbose', action='count')
  my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
  my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
  my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
  my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
  verbosity = my_cool_parser.add_mutually_exclusive_group()
  verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
  print my_cool_parser._actions
  print 'inside of main(), my_cool_parser =', my_cool_parser

  args = my_cool_parser.parse_args()
  main(args)
 def mutext_group(self, options):
     """
     Basic radio group consisting of two options.
     """
     parser = GooeyParser()
     group = parser.add_mutually_exclusive_group(**options)
     group.add_argument("-b", type=str)
     group.add_argument("-d", type=str, widget="DateChooser")
     return parser
示例#13
0
def opt_dataset(parser: GooeyParser = GooeyParser()):
    dataset_kind = parser.add_mutually_exclusive_group()
    dataset_kind.add_argument('--user_dataset',
                              widget='DirChooser',
                              dest="Your Dataset")

    dataset_kind.add_argument(
        '--example_dataset',
        choices=['MNIST', 'FashionMNIST', 'CIFAR10', 'CIFAR100'],
        dest="Prepared Dataset")
示例#14
0
def main():
    parser = GooeyParser()
    parser.add_argument('-if', metavar="源音频文件", widget="FileChooser")
    parser.add_argument('-of', metavar="导出音频文件", widget="FileChooser")
    parser.add_argument('-m', metavar="待嵌入的文件", widget='FileChooser')
    funn = parser.add_mutually_exclusive_group()
    funn.add_argument('-est', dest='est', metavar='预估容量', action='store_true')
    funn.add_argument('-emb', dest='emb', metavar='嵌入', action='store_true')
    funn.add_argument('-ext', dest='ext', metavar='提取', action='store_true')

    parser.add_argument('-verify',
                        metavar='签名',
                        action='store_true',
                        widget='CheckBox')
    parser.add_argument('-pk', metavar='证书路径', widget='FileChooser')
    parser.add_argument('-enc',
                        metavar='加密',
                        choices=['Plain', 'AES'],
                        widget='Dropdown')
    parser.add_argument('-key', metavar='密钥')
    parser.add_argument('-ths', metavar='阈值', default=1600, type=int)
    parser.add_argument('-frame', metavar='点数', default=441, type=int)

    args = parser.parse_args()
    vv = vars(args)
    # print(vv['est'], vv['emb'], vv['ext'])
    # exit(0)
    if vv['est']:
        size, srt, ll = estimate(vv['if'], vv['ths'], vv['frame'])
        print(
            '{} Bytes available under {}Hz, {}kbps in average, under {} points per frame, threshold = {}'
            .format(size, srt, size * 8 / ll / srt, vv['frame'], vv['ths']))
    elif vv['emb']:
        cc = Cryp(mode=getenc(vv['enc']),
                  password=vv['key'],
                  verify=vv['verify'],
                  key=vv['pk'])
        mm = open(vv['message'], 'rb').read()
        ee = cc.encrypt(mm)
        embeed(EMess(ee), vv['if'], vv['of'], vv['ths'], vv['frame'])
    elif vv['ext']:
        dd = Cryp(mode=getenc(vv['enc']),
                  password=vv['key'],
                  verify=vv['verify'],
                  key=vv['pk'])
        ee = extract(vv['if'], vv['ths'], vv['frame'])
        mm, broken = dd.decrypt(ee)
        if broken:
            print('data may broken during embeeding.')
        if vv['of'] is None:
            print(mm)
        else:
            open(vv['of'], 'wb').write(mm)
    else:
        print('Unrecognized command. Exiting.')
示例#15
0
def main():
    parser = GooeyParser(description='Just display the console')

    parser.add_argument('--host',
                        help='Ze host!',
                        default=os.environ.get('HOST'))
    group = parser.add_mutually_exclusive_group(
        required=False,
        # gooey_options={"initial_selection": 0}
    )
    group.add_argument("-b", type=str)
    group.add_argument("-d", type=str, widget="DateChooser")
    args = parser.parse_args()
    print(args)
示例#16
0
def parse_args():
    settings_msg = 'Gazelle 站点的转载工具'
    parser = GooeyParser(description=settings_msg)

    # --from <>
    parser.add_argument('--from', choices=trackers, required=True, help="来源")

    # -to <>
    parser.add_argument("--to", choices=trackers, required=True, help="同步到")

    # --album <> / --folder <>
    group = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 0})
    group.add_argument("--album",
                       help="单种模式:请指定直接包含音乐文件的目录",
                       widget="DirChooser")
    group.add_argument("--folder",
                       help="批量模式:请指定直接包含音乐文件目录的上层目录",
                       widget="DirChooser")

    # --tid <> / --link <> / --tpath <> / --tfolder <>
    group = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 0})
    group.add_argument("--link", help="使用来源站点的种子永久链接(PL)")
    group.add_argument("--tid", help="使用来源站点的种子id(torrentid)")
    group.add_argument("--tpath", help="使用来源站点的种子文件", widget="FileChooser")
    group.add_argument("--tfolder", help="使用一个包含种子文件的文件夹", widget="DirChooser")

    parser.add_argument('-c',
                        '--config',
                        metavar='FILE',
                        default=os.path.join(application_path, 'config.cfg'),
                        help='包含登陆凭证的配置文件 (默认: config.cfg)',
                        widget="FileChooser")

    return parser.parse_args()
示例#17
0
def main():
    parser = GooeyParser(description="GE DICOM Text Parser")
    parser.add_argument('outputfile',
                        help='Select Output Spreadsheet Filename',
                        widget="FileChooser")

    area_threshold_group = parser.add_mutually_exclusive_group(required=True)
    area_threshold_group.add_argument('--inputfile',
                                      help='Input DCM File',
                                      widget='FileChooser')
    area_threshold_group.add_argument('--inputdir',
                                      help='Input DCM Directory',
                                      widget='DirChooser')

    args = parser.parse_args()
    runFile(args)
示例#18
0
def main():
    desc = 'Converts *.spc binary files to text using the spc module'
    parser = GooeyParser(description=desc)
    parser.add_argument('filefolder',
                        widget='DirChooser',
                        help='Input directory containing spc file')
    fformat = parser.add_mutually_exclusive_group()
    fformat.add_argument('-c',
                         '--csv',
                         help='Comma separated output file (.csv) [default]',
                         action='store_true')
    fformat.add_argument('-t',
                         '--txt',
                         help='Tab separated output file (.txt)',
                         action='store_true')
    args = parser.parse_args()

    if args.txt:
        exten = '.txt'
        delim = '\t'
    else:
        # defaults
        exten = '.csv'
        delim = ','

    flist = []

    # only directory here
    ffn = os.path.abspath(args.filefolder)
    for f in os.listdir(ffn):
        flist.append(os.path.join(ffn, f))

    # process files
    for fpath in flist:
        if fpath.lower().endswith('spc'):

            foutp = fpath[:-4] + exten
            try:
                print(fpath, end=' ')
                f = spc.File(fpath)
                f.write_file(foutp, delimiter=delim)
                print('Converted')
            except:
                print('Error processing %s' % fpath)
        else:
            print('%s not spc file, skipping' % fpath)
示例#19
0
def beautify_main():
    parser = GooeyParser(
        description=
        "beautify your code with customized command or standard commands")
    parser.add_argument(
        "-p",
        "--path",
        help="the path you want to execute the command",
        required=True,
        widget="DirChooser",
    )
    group = parser.add_mutually_exclusive_group()
    group.add_argument("-a",
                       "--autopep8",
                       help="use autopep8 to beautify py",
                       action="store_true")
    group.add_argument("-b",
                       "--black",
                       help="use black to beautify py",
                       action="store_true")
    group.add_argument("-g",
                       "--gofmt",
                       help="use gofmt to beautify go",
                       action="store_true")
    group.add_argument("-c", "--customized", help="use customized command")
    args = parser.parse_args()
    path = args.path
    if args.autopep8:
        beautify(".py", "autopep8 --in-place {{root}}/{{file}}", path)
    elif args.black:
        beautify(".py", "black {{root}}/{{file}}", path)
    elif args.gofmt:
        beautify(".go", "gofmt -w {{root}}/{{file}}", path)
    elif args.customized:
        customized = args.customized
        try:
            beautify(
                customized.split(" ** ")[0],
                customized.split(" ** ")[1], path)
        except Exception as e:
            print_exc()
            print("illegal customized command")
            sys.exit()
    else:
        print("unknown tools")
        sys.exit()
def arbitrary_function():
    desc = u"\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u002c \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c "
    file_help_msg = u"\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430\u002c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c"
    my_cool_parser = GooeyParser(description=desc)
    my_cool_parser.add_argument(
        u"\u0432\u044b\u0431\u043e\u0440\u0430\u0444\u0430\u0439\u043b\u043e\u0432",
        help=file_help_msg,
        widget="FileChooser",
    )  # positional
    my_cool_parser.add_argument(
        u"\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c",
        help=file_help_msg,
        widget="MultiFileChooser",
    )  # positional

    my_cool_parser.add_argument(
        "-d",
        u"--\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c",
        default=2,
        type=int,
        help=u"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0028 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0029 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b",
    )
    my_cool_parser.add_argument(
        "-s",
        u"--\u043a\u0440\u043e\u043d \u002d \u0433\u0440\u0430\u0444\u0438\u043a",
        type=int,
        help=u"\u0414\u0430\u0442\u0430",
        widget="DateChooser",
    )
    my_cool_parser.add_argument("-c", "--showtime", action="store_true", help="display the countdown timer")
    my_cool_parser.add_argument("-p", "--pause", action="store_true", help="Pause execution")
    my_cool_parser.add_argument("-v", "--verbose", action="count")
    my_cool_parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite output file (if present)")
    my_cool_parser.add_argument("-r", "--recursive", choices=["yes", "no"], help="Recurse into subfolders")
    my_cool_parser.add_argument("-w", "--writelog", default="writelogs", help="Dump output to local file")
    my_cool_parser.add_argument("-e", "--error", action="store_true", help="Stop process on error (default: No)")
    verbosity = my_cool_parser.add_mutually_exclusive_group()
    verbosity.add_argument("-t", "--verbozze", dest="verbose", action="store_true", help="Show more details")
    verbosity.add_argument("-q", "--quiet", dest="quiet", action="store_true", help="Only output on error")
    # print my_cool_parser._actions
    # print 'inside of main(), my_cool_parser =', my_cool_parser

    args = my_cool_parser.parse_args()
    main(args)
示例#21
0
文件: mockapp.py 项目: Maikflow/Gooey
def main():
  '''
  does stuff with parser.parse_args()
  '''
  desc = "Mock application to test Gooey's functionality"
  file_help_msg = "Name of the file you want to process"
  my_cool_parser = GooeyParser(description=desc)
  my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser")  # positional
  my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output")  # positional
  # my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!', widget='DateChooser')
  my_cool_parser.add_argument('-c', '--cron-schedule', default=10, type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
  my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
  my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
  my_cool_parser.add_argument('-v', '--verbose', action='count')
  my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
  my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
  my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
  my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
  verbosity = my_cool_parser.add_mutually_exclusive_group()
  verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
  print my_cool_parser._actions

  print 'inside of main(), my_cool_parser =', my_cool_parser

  args = my_cool_parser.parse_args()

  print sys.argv
  print args.countdown
  print args.showtime

  start_time = _time()
  print 'Counting down from %s' % args.countdown
  while _time() - start_time < args.countdown:
    if args.showtime:
      print 'printing message at: %s' % _time()
    else:
      print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest()
    _sleep(.5)
  print 'Finished running the program. Byeeeeesss!'
  raise ValueError("Something has gone wrong! AHHHHHHHHHHH")
示例#22
0
文件: mockapp.py 项目: madsbk/Gooey
def main():
  '''
  does stuff with parser.parse_args()
  '''
  desc = "Mock application to test Gooey's functionality"
  file_help_msg = "Name of the file you want to process"
  my_cool_parser = GooeyParser(description=desc)
  my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser")  # positional
  my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output")  # positional
  # my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!', widget='DateChooser')
  my_cool_parser.add_argument('-c', '--cron-schedule', default=10, type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
  my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
  my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
  my_cool_parser.add_argument('-v', '--verbose', action='count')
  my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
  my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
  my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
  my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
  verbosity = my_cool_parser.add_mutually_exclusive_group()
  verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
  print my_cool_parser._actions

  print 'inside of main(), my_cool_parser =', my_cool_parser

  args = my_cool_parser.parse_args()

  print sys.argv
  print args.countdown
  print args.showtime

  start_time = _time()
  print 'Counting down from %s' % args.countdown
  while _time() - start_time < args.countdown:
    if args.showtime:
      print 'printing message at: %s' % _time()
    else:
      print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest()
    _sleep(.5)
  print 'Finished running the program. Byeeeeesss!'
  raise ValueError("Something has gone wrong! AHHHHHHHHHHH")
示例#23
0
def main():
    parser = GooeyParser(description="Gooey's widgets Example ")

    parser.add_argument("directory")
    parser.add_argument("FileChooser", widget="FileChooser")
    parser.add_argument("DirectoryChooser", widget="DirChooser")
    parser.add_argument("FileSaver", widget="FileSaver")
    parser.add_argument("MultiFileSaver", widget="MultiFileChooser")

    parser.add_argument('-c', '--count', action='count')
    parser.add_argument("-s", "--store-true", action="store_true")
    parser.add_argument("-i", "--input", default="default string")
    parser.add_argument('-t', '--type', default=0, type=int)
    parser.add_argument('-d', '--dateChooser', type=int, widget='DateChooser')
    parser.add_argument('-r', '--recursive', choices=['yes', 'no'])

    group = parser.add_mutually_exclusive_group()
    group.add_argument('-g1', '--group-1', dest='group1', action="store_true")
    group.add_argument('-g2', '--group-2', dest='group2', action="store_true")

    args = parser.parse_args()
示例#24
0
def main():
    desc = 'Converts *.spc binary files to text using the spc module'
    parser = GooeyParser(description=desc)
    parser.add_argument('filefolder', widget='DirChooser', help='Input directory containing spc file')
    fformat = parser.add_mutually_exclusive_group()
    fformat.add_argument('-c', '--csv', help='Comma separated output file (.csv) [default]',
                         action='store_true')
    fformat.add_argument('-t', '--txt', help='Tab separated output file (.txt)',
                         action='store_true')
    args = parser.parse_args()

    if args.txt:
        exten = '.txt'
        delim = '\t'
    else:
        # defaults
        exten = '.csv'
        delim = ','

    flist = []

    # only directory here
    ffn = os.path.abspath(args.filefolder)
    for f in os.listdir(ffn):
        flist.append(os.path.join(ffn, f))

    # process files
    for fpath in flist:
        if fpath.lower().endswith('spc'):

            foutp = fpath[:-4] + exten
            try:
                print(fpath, end=' ')
                f = spc.File(fpath)
                f.write_file(foutp, delimiter=delim)
                print('Converted')
            except:
                print('Error processing %s' % fpath)
        else:
            print('%s not spc file, skipping' % fpath)
示例#25
0
def main():
    parser = GooeyParser(description='Transcribe/translate audio.')

    group = parser.add_mutually_exclusive_group()
    group.add_argument("-en", "--English", action="store_true")
    group.add_argument("-hi", "--Hindi", action="store_true")
    group.add_argument("-es", "--Spanish", action="store_true")
    group.add_argument("-fr", "--French", action="store_true")
    group.add_argument("-ar", "--Arabic", action="store_true")
    group.add_argument("-bn", "--Bengali", action="store_true")
    group.add_argument("-ru", "--Russian", action="store_true")
    group.add_argument("-pt", "--Portuguese", action="store_true")
    group.add_argument("-id", "--Indonesian", action="store_true")
    args = parser.parse_args()

    def run():
        if args.English:
            test.main("en")
        elif args.Hindi:
            test.main("hi")
        elif args.Spanish:
            test.main("es")
        elif args.French:
            test.main("fr")
        elif args.Arabic:
            test.main("ar")
        elif args.Bengali:
            test.main("bn")
        elif args.Russian:
            test.main("ru")
        elif args.Portuguese:
            test.main("pt")
        elif args.Indonesian:
            test.main("id")
        else:
            test.main("en")

    run()
    print('Transcription complete!')
示例#26
0
def parse_args(args):
    parser = GooeyParser(
        description=
        "Sort any BodyShop content. Higher numbers come earlier in the catalog!"
    )

    indexGroup = parser.add_mutually_exclusive_group(required=True)
    indexGroup.add_argument("-i",
                            "--Index",
                            type=hex,
                            help="Value to apply to sortindex, in hex.")
    indexGroup.add_argument(
        "-m",
        "--Mapfile",
        help=
        "File listing suffix:index pairs. Sortindex to apply is determined by the suffix (characters after the last _ in the file name) of the file.",
        widget="FileChooser")

    parser.add_argument("Filenames",
                        help="File(s) to process",
                        nargs="*",
                        widget="MultiFileChooser")

    return parser.parse_args(args)
示例#27
0
def main():
  desc = "Example application to show Gooey's various widgets"
  my_cool_parser = GooeyParser(description=desc)
  my_cool_parser.add_argument("Example", help="fill ", widget="FileChooser")   # positional
  verbosity = my_cool_parser.add_mutually_exclusive_group()
  verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
  print my_cool_parser._actions
  print 'inside of main(), my_cool_parser =', my_cool_parser

  args = my_cool_parser.parse_args()
  print sys.argv
  print args.countdown
  print args.showtime

  start_time = _time()
  print 'Counting down from %s' % args.countdown
  while _time() - start_time < args.countdown:
    if args.showtime:
      print 'printing message at: %s' % _time()
    else:
      print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest()
    _sleep(.5)
  print 'Finished running the program. Byeeeeesss!'
def param_parser():
    stored_args = {}
    # get the script name without the extension & use it to build up
    # the json filename
    script_name = os.path.splitext(os.path.basename(__file__))[0]
    congifg_folder = AtlassGen.makedir("C:\\pythontools")
    args_file = os.path.join(congifg_folder,
                             "{}-args.json".format(script_name))
    '''
    globalmapperexe = glob.glob('C:\\Program Files\\'+'GlobalMapper2*')
    globalmapperexe = '{0}\\global_mapper.exe'.format(globalmapperexe[0])
    print(globalmapperexe)
    # Read in the prior arguments as a dictionary
    if os.path.isfile(args_file):
        with open(args_file) as data_file:
            stored_args = json.load(data_file)
    '''
    parser = GooeyParser(description="Make Contour")
    parser.add_argument("inputfolder",
                        metavar="LAS file Folder",
                        widget="DirChooser",
                        help="Select las file folder",
                        default=stored_args.get('inputfolder'))
    parser.add_argument(
        "filepattern",
        metavar="Input File Pattern",
        help=
        "Provide a file pattern seperated by ';' for multiple patterns (*.laz or 123*_456*.laz;345*_789* )",
        default=stored_args.get('filepattern'))
    parser.add_argument("layoutfile",
                        metavar="TileLayout file",
                        widget="FileChooser",
                        help="TileLayout file(.json)",
                        default=stored_args.get('layoutfile'))
    parser.add_argument("outputpath",
                        metavar="Output Directory",
                        widget="DirChooser",
                        help="Output directory",
                        default=stored_args.get('outputpath'))
    cls_type = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 0})
    cls_type.add_argument("--type1",
                          metavar="Type 1  [classes- DEM, 3,4,9]",
                          action='store_true')
    cls_type.add_argument("--type2",
                          metavar="Type 2 [classes- DEM, 3,4,5,6,1,9,10,13]",
                          action='store_true')
    cls_type.add_argument("--type3",
                          metavar="Type 3 [classes- DEM, 3,4,5,6,1,9,10,13]",
                          action='store_true')
    parser.add_argument("--diff",
                        metavar="Diff - Make ascfs to check coverage",
                        action='store_true',
                        default=True)
    parser.add_argument(
        "projection",
        metavar="Projection",
        choices=['AMG (Australian Map Grid)', 'MGA (Map Grid of Australia)'],
        default=stored_args.get('projection'))
    parser.add_argument(
        "datum",
        metavar="Datum",
        choices=['D_AUSTRALIAN_1984', 'D_AUSTRALIAN_1966', 'GDA94'],
        default=stored_args.get('datum'))
    parser.add_argument("zone",
                        metavar="UTM Zone",
                        choices=['50', '51', '52', '53', '54', '55', '56'],
                        default=stored_args.get('zone'))
    parser.add_argument("step",
                        metavar="Step for lasgrid",
                        type=float,
                        default=stored_args.get('step'))
    parser.add_argument("gmexe",
                        metavar="Global Mapper EXE",
                        widget="FileChooser",
                        help="Location of Global Mapper exe",
                        default='globalmapperexe')
    parser.add_argument("-workspace",
                        metavar="Create Global Mapper workspace",
                        action='store_true')
    parser.add_argument(
        "-onlymapC",
        metavar="Create only the map catalogs(ascs must be available",
        action='store_true')
    parser.add_argument("-c",
                        "--cores",
                        metavar="Cores",
                        help="No of cores to run",
                        type=int,
                        default=stored_args.get('cores'))

    args = parser.parse_args()

    # Store the values of the arguments so we have them next time we run
    with open(args_file, 'w') as data_file:
        # Using vars(args) returns the data as a dictionary
        json.dump(vars(args), data_file)

    return args
示例#29
0
def main():
    p = GooeyParser(
        description='Post-Process RASDRviewer/RASDRproc spectrum data output files')
    p.add_argument(      "--version", action='version', version='%(prog)s '+DEF_VERSION)
    # NB: need to order these with the most used options first
    # http://stackoverflow.com/questions/20165843/argparse-how-to-handle-variable-number-of-arguments-nargs
    p.add_argument(      "file", widget="FileChooser")
    p.add_argument('-b', '--background', type=str, metavar='PATH', default='', widget="FileChooser",
        help='Specify how to perform background subtraction;'+
             'if the word automatic is used, then the background will be taken'+
             'from the average of all lines in the file.  Otherwise, it is taken'+
             'as a file to process.  The file must have the same frequency plan as the foreground file.')
    p.add_argument('-a', '--average', type=int, metavar='N', default=DEF_AVERAGE,
        help='Specify the number of spectra to average for each plot')
    p.add_argument('-s', '--smooth', type=int, metavar='N', default=0,
        help='Smooth final plot using a sliding window of N points')
    p.add_argument('--fcenter', dest='fc', type=float, default=0.0,
        help='Define the offset for the center frequency in Hz')  #default=%f'%0.0)
    p.add_argument('--statistics', type=str, metavar='PATH', default=None, widget="FileChooser",
        help='Dump statistical information to a file in comma-separated-values format')
    p.add_argument('-i', '--info', action='store_true', default=False,
        help='Produce information about a file only; do not generate any plots')
    p.add_argument('-g', '--gui', action='store_true', default=False,
        help='Create interactive PLOTS')
    g = p.add_mutually_exclusive_group()
    g.add_argument("-v", "--verbose", default=False, help="Turn on verbose output", action="store_true")
    g.add_argument("-q", "--quiet", default=False, help='Suppress progress messages', action="store_true")
    # call matplotlib.use() only once
    p.set_defaults(matplotlib_use = False)
    p.add_argument('-c', '--cancel-dc', dest='canceldc', action='store_true', default=False,
        help='Cancel out component at frequency bin for 0Hz')
    p.add_argument('-d', '--delimiter', type=str, metavar='CHAR', default=DEF_DELIM,
        help='Specify the delimiter character to use"')
    p.add_argument('-e', '--localtime', action='store_true', default=False,
        help='Indicate that .csv file has timestamps in RASDRviewer\'s "LocalTime" format')
    p.add_argument('-k', '--calibration', type=float, metavar='CONST', default=DEF_CALIB,
        help='Specify the calibration constant for the system; 0.0=uncal')    #default=%f'%DEF_CALIB)
    p.add_argument('-l', '--line', action='store_true', default=False,
        help='Perform line-by-line processing instead of loading entire file(s); NOTE: much slower but tolerates low memory better.')
##    p.add_argument('-m', '--milliwatt', dest='dbm', action='store_true', default=False,
##        help='Plot in decibels referenced to 1mW (dBm/Hz)')
##    p.add_argument('-t', '--datetime', action='store_true', default=False,
##        help='Indicate that timestamps in the .csv file are in Excel\'s datetime format')
    p.add_argument('--debug', action='store_true', default=False,
        help='Drop into ipython shell at predefined point(s) to debug the script')
    p.add_argument('--hold', action='store_true', default=False,
        help='Perform a maximum value HOLD during averaging and plot it as a second line')
    p.add_argument('--bplot', action='store_true', default=False,
        help='If using background file, choose whether to plot the background reference in a difffert color')
    p.add_argument('--ptype', type=str, metavar='TYPE', default='log',
        help='Control plot vertical scale (linear or log)')
    p.add_argument('--atype', type=str, metavar='TYPE', default='log',
        help='Control averaging method (linear or log)')
        # http://www.dtic.mil/dtic/tr/fulltext/u2/657404.pdf
    ## for handling RASDRviewer versions
    v = DEF_VERSION.split('.')
    ver = v[0]+'.'+v[1]+'.'+v[2]
    p.add_argument('--format', type=str, metavar='X.Y.Z', default=ver,
        help='Specify the RASDRviewer .csv output format to interpret')

    opts = p.parse_args(sys.argv)
    execute(opts)
def arbitrary_function():
    desc = u"\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u002c \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c "
    file_help_msg = u"\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430\u002c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c"
    my_cool_parser = GooeyParser(description=desc)
    my_cool_parser.add_argument(
        u"\u0432\u044b\u0431\u043e\u0440\u0430\u0444\u0430\u0439\u043b\u043e\u0432",
        help=file_help_msg,
        widget="FileChooser")  # positional
    my_cool_parser.add_argument(
        u"\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c",
        help=file_help_msg,
        widget="MultiFileChooser")  # positional

    my_cool_parser.add_argument(
        '-d',
        u'--\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c',
        default=2,
        type=int,
        help=
        u'\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0028 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0029 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b'
    )
    my_cool_parser.add_argument(
        '-s',
        u'--\u043a\u0440\u043e\u043d \u002d \u0433\u0440\u0430\u0444\u0438\u043a',
        type=int,
        help=u'\u0414\u0430\u0442\u0430',
        widget='DateChooser')
    my_cool_parser.add_argument("-c",
                                "--showtime",
                                action="store_true",
                                help="display the countdown timer")
    my_cool_parser.add_argument("-p",
                                "--pause",
                                action="store_true",
                                help="Pause execution")
    my_cool_parser.add_argument('-v', '--verbose', action='count')
    my_cool_parser.add_argument("-o",
                                "--overwrite",
                                action="store_true",
                                help="Overwrite output file (if present)")
    my_cool_parser.add_argument('-r',
                                '--recursive',
                                choices=['yes', 'no'],
                                help='Recurse into subfolders')
    my_cool_parser.add_argument("-w",
                                "--writelog",
                                default="writelogs",
                                help="Dump output to local file")
    my_cool_parser.add_argument("-e",
                                "--error",
                                action="store_true",
                                help="Stop process on error (default: No)")
    verbosity = my_cool_parser.add_mutually_exclusive_group()
    verbosity.add_argument('-t',
                           '--verbozze',
                           dest='verbose',
                           action="store_true",
                           help="Show more details")
    verbosity.add_argument('-q',
                           '--quiet',
                           dest='quiet',
                           action="store_true",
                           help="Only output on error")
    # print my_cool_parser._actions
    # print 'inside of main(), my_cool_parser =', my_cool_parser

    args = my_cool_parser.parse_args()
    main(args)
示例#31
0
def main():
    p = GooeyParser(
        description=
        'Post-Process RASDRviewer/RASDRproc spectrum data output files')
    p.add_argument("--version",
                   action='version',
                   version='%(prog)s ' + DEF_VERSION)
    # NB: need to order these with the most used options first
    # http://stackoverflow.com/questions/20165843/argparse-how-to-handle-variable-number-of-arguments-nargs
    p.add_argument("file", widget="FileChooser")
    p.add_argument(
        '-b',
        '--background',
        type=str,
        metavar='PATH',
        default='',
        widget="FileChooser",
        help='Specify how to perform background subtraction;' +
        'if the word automatic is used, then the background will be taken' +
        'from the average of all lines in the file.  Otherwise, it is taken' +
        'as a file to process.  The file must have the same frequency plan as the foreground file.'
    )
    p.add_argument(
        '-a',
        '--average',
        type=int,
        metavar='N',
        default=DEF_AVERAGE,
        help='Specify the number of spectra to average for each plot')
    p.add_argument('-s',
                   '--smooth',
                   type=int,
                   metavar='N',
                   default=0,
                   help='Smooth final plot using a sliding window of N points')
    p.add_argument('--fcenter',
                   dest='fc',
                   type=float,
                   default=0.0,
                   help='Define the offset for the center frequency in Hz'
                   )  #default=%f'%0.0)
    p.add_argument(
        '--statistics',
        type=str,
        metavar='PATH',
        default=None,
        widget="FileChooser",
        help=
        'Dump statistical information to a file in comma-separated-values format'
    )
    p.add_argument(
        '-i',
        '--info',
        action='store_true',
        default=False,
        help='Produce information about a file only; do not generate any plots'
    )
    p.add_argument('-g',
                   '--gui',
                   action='store_true',
                   default=False,
                   help='Create interactive PLOTS')
    g = p.add_mutually_exclusive_group()
    g.add_argument("-v",
                   "--verbose",
                   default=False,
                   help="Turn on verbose output",
                   action="store_true")
    g.add_argument("-q",
                   "--quiet",
                   default=False,
                   help='Suppress progress messages',
                   action="store_true")
    # call matplotlib.use() only once
    p.set_defaults(matplotlib_use=False)
    p.add_argument('-c',
                   '--cancel-dc',
                   dest='canceldc',
                   action='store_true',
                   default=False,
                   help='Cancel out component at frequency bin for 0Hz')
    p.add_argument('-d',
                   '--delimiter',
                   type=str,
                   metavar='CHAR',
                   default=DEF_DELIM,
                   help='Specify the delimiter character to use"')
    p.add_argument(
        '-e',
        '--localtime',
        action='store_true',
        default=False,
        help=
        'Indicate that .csv file has timestamps in RASDRviewer\'s "LocalTime" format'
    )
    p.add_argument(
        '-k',
        '--calibration',
        type=float,
        metavar='CONST',
        default=DEF_CALIB,
        help='Specify the calibration constant for the system; 0.0=uncal'
    )  #default=%f'%DEF_CALIB)
    p.add_argument(
        '-l',
        '--line',
        action='store_true',
        default=False,
        help=
        'Perform line-by-line processing instead of loading entire file(s); NOTE: much slower but tolerates low memory better.'
    )
    ##    p.add_argument('-m', '--milliwatt', dest='dbm', action='store_true', default=False,
    ##        help='Plot in decibels referenced to 1mW (dBm/Hz)')
    ##    p.add_argument('-t', '--datetime', action='store_true', default=False,
    ##        help='Indicate that timestamps in the .csv file are in Excel\'s datetime format')
    p.add_argument(
        '--debug',
        action='store_true',
        default=False,
        help=
        'Drop into ipython shell at predefined point(s) to debug the script')
    p.add_argument(
        '--hold',
        action='store_true',
        default=False,
        help=
        'Perform a maximum value HOLD during averaging and plot it as a second line'
    )
    p.add_argument(
        '--bplot',
        action='store_true',
        default=False,
        help=
        'If using background file, choose whether to plot the background reference in a difffert color'
    )
    p.add_argument('--ptype',
                   type=str,
                   metavar='TYPE',
                   default='log',
                   help='Control plot vertical scale (linear or log)')
    p.add_argument('--atype',
                   type=str,
                   metavar='TYPE',
                   default='log',
                   help='Control averaging method (linear or log)')
    # http://www.dtic.mil/dtic/tr/fulltext/u2/657404.pdf
    ## for handling RASDRviewer versions
    v = DEF_VERSION.split('.')
    ver = v[0] + '.' + v[1] + '.' + v[2]
    p.add_argument(
        '--format',
        type=str,
        metavar='X.Y.Z',
        default=ver,
        help='Specify the RASDRviewer .csv output format to interpret')

    opts = p.parse_args(sys.argv)
    execute(opts)
示例#32
0
def main():
    desc = "Example application to show Gooey's various widgets"
    parser = GooeyParser(description=desc, add_help=False)

    parser.add_argument('--textfield', default=2, widget="TextField", gooey_options={
        'validator': {
            'test': 'int(user_input) > 5',
            'message': 'number must be greater than 5'
        }
    })
    parser.add_argument('--textarea', default="oneline twoline", widget='Textarea')
    parser.add_argument('--password', default="hunter42", widget='PasswordField')
    parser.add_argument('--commandfield', default="cmdr", widget='CommandField')
    parser.add_argument('--dropdown',
                        choices=["one", "two"], default="two", widget='Dropdown')
    parser.add_argument('--listboxie',
                    nargs='+',
                    default=['Option three', 'Option four'],
                    choices=['Option one', 'Option two', 'Option three',
                             'Option four'],
                    widget='Listbox',
                    gooey_options={
                        'height': 300,
                        'validate': '',
                        'heading_color': '',
                        'text_color': '',
                        'hide_heading': True,
                        'hide_text': True,
                    }
                )
    parser.add_argument('-c', '--counter', default=3, action='count', widget='Counter')
    #
    parser.add_argument("-o", "--overwrite", action="store_true",
                                default=True,
                                widget='CheckBox')

    ### Mutex Group ###
    verbosity = parser.add_mutually_exclusive_group(
        required=True,
        gooey_options={
            'initial_selection': 1
        }
    )
    verbosity.add_argument(
        '--mutexone',
        default=True,
        action='store_true',
        help="Show more details")

    verbosity.add_argument(
        '--mutextwo',
        default='mut-2',
        widget='TextField')

    parser.add_argument("--filechooser", default="fc-value", widget='FileChooser')
    parser.add_argument("--filesaver", default="fs-value", widget='FileSaver')
    parser.add_argument("--dirchooser", default="dc-value", widget='DirChooser')
    parser.add_argument("--datechooser", default="2015-01-01", widget='DateChooser')

    dest_vars = [
        'textfield',
        'textarea',
        'password',
        'commandfield',
        'dropdown',
        'listboxie',
        'counter',
        'overwrite',
        'mutextwo',
        'filechooser',
        'filesaver',
        'dirchooser',
        'datechooser'

    ]


    args = parser.parse_args()
    import time
    time.sleep(3)
    for i in dest_vars:
        assert getattr(args, i) is not None
    print("Success")
示例#33
0
    def test_validate_form(self):
        """
        Testing the major validation cases we support.
        """
        writer = MagicMock()
        exit = MagicMock()
        monkey_patch = control.validate_form(gooey_params(),
                                             write=writer,
                                             exit=exit)
        ArgumentParser.original_parse_args = ArgumentParser.parse_args
        ArgumentParser.parse_args = monkey_patch

        parser = GooeyParser()
        # examples:
        # ERROR: mismatched builtin type
        parser.add_argument('a',
                            type=int,
                            gooey_options={'initial_value': 'not-an-int'})
        # ERROR: mismatched custom type
        parser.add_argument('b',
                            type=custom_type,
                            gooey_options={'initial_value': 'not-a-float'})
        # ERROR: missing required positional arg
        parser.add_argument('c')
        # ERROR: missing required 'optional' arg
        parser.add_argument('--oc', required=True)
        # VALID: This is one of the bizarre cases which are possible
        # but don't make much sense. It should pass through as valid
        # because there's no way for us to send a 'not present optional value'
        parser.add_argument('--bo', action='store_true', required=True)
        # ERROR: a required mutex group, with no args supplied.
        # Should flag all as missing.
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('--gp1-a', type=str)
        group.add_argument('--gp1-b', type=str)

        # ERROR: required mutex group with a default option but nothing
        # selected will still fail
        group2 = parser.add_mutually_exclusive_group(required=True)
        group2.add_argument('--gp2-a', type=str)
        group2.add_argument('--gp2-b', type=str, default='Heeeeyyyyy')

        # VALID: now, same as above, but now the option is actually enabled via
        # the initial selection. No error.
        group3 = parser.add_mutually_exclusive_group(
            required=True, gooey_options={'initial_selection': 1})
        group3.add_argument('--gp3-a', type=str)
        group3.add_argument('--gp3-b', type=str, default='Heeeeyyyyy')
        # VALID: optional mutex.
        group4 = parser.add_mutually_exclusive_group()
        group4.add_argument('--gp4-a', type=str)
        group4.add_argument('--gp4-b', type=str)
        # VALID: arg present and type satisfied
        parser.add_argument('ga',
                            type=str,
                            gooey_options={'initial_value': 'whatever'})
        # VALID: arg present and custom type satisfied
        parser.add_argument('gb',
                            type=custom_type,
                            gooey_options={'initial_value': '1234'})
        # VALID: optional
        parser.add_argument('--gc')

        # now we're adding the same
        with instrumentGooey(parser, target='test') as (app, frame, gapp):
            # we start off with no errors
            self.assertFalse(s.has_errors(gapp.fullState()))

            # now we feed our form-validation
            cmd = s.buildFormValidationCmd(gapp.fullState())
            asdf = shlex.split(cmd)[1:]
            parser.parse_args(shlex.split(cmd)[1:])
            assert writer.called
            assert exit.called

        result = deserialize_inbound(writer.call_args[0][0].encode('utf-8'),
                                     'utf-8')
        # Host->Gooey communication is all done over the PublicGooeyState schema
        # as such, we coarsely validate it's shape here
        validate_public_state(result)

        # manually merging the two states back together
        nextState = s.mergeExternalState(gapp.fullState(), result)
        # and now we find that we have errors!
        self.assertTrue(s.has_errors(nextState))
        items = s.activeFormState(nextState)
        self.assertIn('invalid literal', get_by_id(items, 'a')['error'])
        self.assertIn('KABOOM!', get_by_id(items, 'b')['error'])
        self.assertIn('required', get_by_id(items, 'c')['error'])
        self.assertIn('required', get_by_id(items, 'oc')['error'])
        for item in get_by_id(items, 'group_gp1_a_gp1_b')['options']:
            self.assertIsNotNone(item['error'])
        for item in get_by_id(items, 'group_gp2_a_gp2_b')['options']:
            self.assertIsNotNone(item['error'])

        for item in get_by_id(items, 'group_gp3_a_gp3_b')['options']:
            self.assertIsNone(item['error'])
        # should be None, since this one was entirely optional
        for item in get_by_id(items, 'group_gp4_a_gp4_b')['options']:
            self.assertIsNone(item['error'])
        self.assertIsNone(get_by_id(items, 'bo')['error'])
        self.assertIsNone(get_by_id(items, 'ga')['error'])
        self.assertIsNone(get_by_id(items, 'gb')['error'])
        self.assertIsNone(get_by_id(items, 'gc')['error'])
def main():
    """Executing script"""

    desc = u'Выбериате вариант и нажмите на кнопку "Запуск"'

    my_cool_parser = GooeyParser(description=desc)

    verbosity = my_cool_parser.add_mutually_exclusive_group()
    verbosity.add_argument(
        '-t',
        '--verbozze',
        dest='First',
        action="store_true",
        help="Сформировать общий файл и вручную проставить порядковый номер")
    verbosity.add_argument('-q',
                           '--quiet',
                           dest='Second',
                           action="store_true",
                           help="Разбить на файлы (максимум 20 записей)")
    verbosity.add_argument(
        '-e',
        '--extra',
        dest='Third',
        action="store_true",
        help="Разбить на файлы по субъектам (максимум 20 записей)")

    global args

    args = my_cool_parser.parse_args()
    global input_path
    global output_path
    global template_all_path
    global template_short_path
    global example_path

    input_path = u'//a104124/A/input/'
    output_path = u'//a104124/A/output/'
    template_all_path = u'//a104124/A/example/template_full.xlsx'
    template_short_path = u'//a104124/A/example/template_short.xlsx'
    example_path = u'//a104124/A/example/'

    all_df = read_concat(input_path)

    if args.First == True:
        split_save(all_df)
        print 'Общий файл сохранен. Проставьте, пожалуйста, порядковый номер, сохраните файл и нажмите "След. этап" для нарезки файлов'
    elif args.Second == True:
        print 'second'
        temp = read_index()
        split_save_short(all_df)
        split_save_invest(all_df)
        print('Готово.')
        print("""Результат находится в папке: \\\\a104124\A\output""")
    elif args.Third == True:
        temp = read_index()
        all_df.loc[all_df['level_8'] == u'Московская обл.',
                   'level_8'] = u'Московская область'
        for region in all_df['level_8'].unique():
            split_save_region(all_df, region)

    else:
        print(
            'На прошлом шаге не был выбран вариант, нажмите на кнопку редактировать'
        )
示例#35
0
def get_parser():
    desc = "Example application to show Gooey's various widgets"
    parser = GooeyParser(description=desc, add_help=False)

    parser.add_argument('--textfield', default=2, widget="TextField")
    parser.add_argument('--textarea',
                        default="oneline twoline",
                        widget='Textarea')
    parser.add_argument('--password',
                        default="hunter42",
                        widget='PasswordField')
    parser.add_argument('--commandfield',
                        default="cmdr",
                        widget='CommandField')
    parser.add_argument('--dropdown',
                        choices=["one", "two"],
                        default="two",
                        widget='Dropdown')
    parser.add_argument(
        '--listboxie',
        nargs='+',
        default=['Option three', 'Option four'],
        choices=['Option one', 'Option two', 'Option three', 'Option four'],
        widget='Listbox',
        gooey_options={
            'height': 300,
            'validate': '',
            'heading_color': '',
            'text_color': '',
            'hide_heading': True,
            'hide_text': True,
        })
    parser.add_argument('-c',
                        '--counter',
                        default=3,
                        action='count',
                        widget='Counter')
    parser.add_argument("-o",
                        "--overwrite",
                        action="store_true",
                        default=True,
                        widget='CheckBox')
    parser.add_argument("-bo",
                        "--blockcheckbox",
                        action="store_true",
                        default=True,
                        widget='BlockCheckbox')

    ### Mutex Group ###
    verbosity = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 1})
    verbosity.add_argument('--mutexone',
                           default=True,
                           action='store_true',
                           help="Show more details")

    verbosity.add_argument('--mutextwo', default='mut-2', widget='TextField')

    parser.add_argument("--filechooser",
                        default="fc-value",
                        widget='FileChooser')
    parser.add_argument("--filesaver", default="fs-value", widget='FileSaver')
    parser.add_argument("--dirchooser",
                        default="dc-value",
                        widget='DirChooser')
    parser.add_argument("--datechooser",
                        default="2015-01-01",
                        widget='DateChooser')
    parser.add_argument("--multidirchooser",
                        default="2015-01-01",
                        widget='MultiDirChooser')

    return parser
示例#36
0
def parse_args():
    settings_msg = 'Gazelle 站点的转载工具'
    parser = GooeyParser(description=settings_msg)

    # --from <>
    parser.add_argument('--from',
                        metavar='From',
                        choices=trackers,
                        required=True,
                        help="来源站点")

    # -to <>
    parser.add_argument("--to",
                        metavar='To',
                        choices=trackers,
                        required=True,
                        help="目标站点")

    # --album <> / --folder <>
    group = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 0})
    group.add_argument("--album",
                       metavar='Album',
                       help="单种模式:请指定直接包含音乐文件的目录",
                       widget="DirChooser")
    group.add_argument("--folder",
                       metavar='Folder',
                       help="批量模式:请指定直接包含音乐文件目录的上层目录",
                       widget="DirChooser")

    # --tid <> / --link <> / --tpath <> / --tfolder <>
    group = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 0})
    group.add_argument("--link", metavar='PL Link', help="使用来源站点的种子永久链接(PL)")
    group.add_argument("--tid",
                       metavar='Torrent ID',
                       help="使用来源站点的种子id(torrentid)")
    group.add_argument("--tpath",
                       metavar='Torrent Path',
                       help="使用来源站点的种子文件",
                       widget="FileChooser")
    group.add_argument("--tfolder",
                       metavar='Torrent Folder',
                       help="使用一个包含种子文件的文件夹",
                       widget="DirChooser")

    parser.add_argument('-c',
                        '--config',
                        metavar='Config File Path',
                        default=os.path.join(application_path, 'config.cfg'),
                        help='包含登陆凭证的配置文件 (默认: config.cfg)',
                        widget="FileChooser")

    # parser.add_argument(
    #     '--nolog',
    #     dest='nolog',
    #     action='store_true',
    #     help='取消日志上传'
    # )
    # parser.set_defaults(nolog = False)

    return parser.parse_args()
def main():
    desc = "Example application to show Gooey's various widgets"
    parser = GooeyParser(description=desc, add_help=False)

    parser.add_argument('--textfield',
                        default=2,
                        widget="TextField",
                        gooey_options={
                            'validator': {
                                'test': 'int(user_input) > 5',
                                'message': 'number must be greater than 5'
                            }
                        })
    parser.add_argument('--textarea',
                        default="oneline twoline",
                        widget='Textarea')
    parser.add_argument('--password',
                        default="hunter42",
                        widget='PasswordField')
    parser.add_argument('--commandfield',
                        default="cmdr",
                        widget='CommandField')
    parser.add_argument('--dropdown',
                        choices=["one", "two"],
                        default="two",
                        widget='Dropdown')
    parser.add_argument(
        '--listboxie',
        nargs='+',
        default=['Option three', 'Option four'],
        choices=['Option one', 'Option two', 'Option three', 'Option four'],
        widget='Listbox',
        gooey_options={
            'height': 300,
            'validate': '',
            'heading_color': '',
            'text_color': '',
            'hide_heading': True,
            'hide_text': True,
        })
    parser.add_argument('-c',
                        '--counter',
                        default=3,
                        action='count',
                        widget='Counter')
    #
    parser.add_argument("-o",
                        "--overwrite",
                        action="store_true",
                        default=True,
                        widget='CheckBox')

    ### Mutex Group ###
    verbosity = parser.add_mutually_exclusive_group(
        required=True, gooey_options={'initial_selection': 1})
    verbosity.add_argument('--mutexone',
                           default=True,
                           action='store_true',
                           help="Show more details")

    verbosity.add_argument('--mutextwo', default='mut-2', widget='TextField')

    parser.add_argument("--filechooser",
                        default="fc-value",
                        widget='FileChooser')
    parser.add_argument("--filesaver", default="fs-value", widget='FileSaver')
    parser.add_argument("--dirchooser",
                        default="dc-value",
                        widget='DirChooser')
    parser.add_argument("--datechooser",
                        default="2015-01-01",
                        widget='DateChooser')
    parser.add_argument("--colourchooser",
                        default="#000000",
                        widget='ColourChooser')

    dest_vars = [
        'textfield', 'textarea', 'password', 'commandfield', 'dropdown',
        'listboxie', 'counter', 'overwrite', 'mutextwo', 'filechooser',
        'filesaver', 'dirchooser', 'datechooser', 'colourchooser'
    ]

    args = parser.parse_args()
    import time
    time.sleep(3)
    for i in dest_vars:
        assert getattr(args, i) is not None
    print("Success")
示例#38
0
                        'heading_color': '',
                        'text_color': '',
                        'hide_heading': True,
                        'hide_text': True,
                    })
parser.add_argument('--counter', default=3, action='count', widget='Counter')
parser.add_argument("--overwrite1",
                    action="store_true",
                    default=True,
                    widget='CheckBox')
parser.add_argument("--overwrite2",
                    action="store_true",
                    default=True,
                    widget='BlockCheckbox')

verbosity = parser.add_mutually_exclusive_group(
    gooey_options={'initial_selection': 0})
verbosity.add_argument('--mutexone', default='hello')

parser.add_argument('--mutextwo', default='3', widget='Slider')
parser.add_argument('--mutextwo', default='1', widget='IntegerField')
parser.add_argument('--mutextwo', default='4', widget='DecimalField')

parser.add_argument("--filechooser", default="fc-value", widget='FileChooser')
parser.add_argument("--filesaver", default="fs-value", widget='FileSaver')
parser.add_argument("--dirchooser", default="dc-value", widget='DirChooser')
parser.add_argument("--datechooser",
                    default="2015-01-01",
                    widget='DateChooser')
parser.add_argument("--colourchooser",
                    default="#000000",
                    widget='ColourChooser')