def main(): """""" ap = GooeyParser() ap.add_argument("-targ_dir", default=r'C:\Data\EM\classification', type=str, help="path to directory for saving proofreading data", widget='DirChooser') ap.add_argument( '-base_volume', type=str, default= '487208920048:adultob:seg_v2_9nm_484558417fb_18nm_fb_107004781_otfa_multires_mesh', help='base segmentation volume id in form of ' '"projectId:datasetId:volumeId"') ap.add_argument('-raw_data', type=str, default='487208920048:adultob:full', help='image data volume path') ap.add_argument('-change_stack_id', type=parse_chg_stack, default='200614_prj487208920048_graph_postapr', help='change stack id storing the agglomeration; to use ' 'base volume enter one of: n, none, f. false, 0' 'graph') ap.add_argument( '-remove_token', type=str2bool, default=False, help='flag that decides whether to delete the token created' ' by authenticating to neuroglancer upon exit of the ' 'program. \n' 'Usage: true, yes, t, y, 1 or false, no, n, f, 0; ' 'case-insensitive') ap.add_argument('-timer_interval', type=int, default=600, help='interval of the autosave tiner in sec') ap.set_defaults(func=run_classifier) ap_args = ap.parse_args() ap_args.func(ap_args)
def parse_cli(): """Create Gooey GUI.""" defs = GuiDefaultOptions() parser = GooeyParser(description="Download videos from coub.com", usage="%(prog)s [OPTIONS] INPUT [INPUT]...") # Input input_ = parser.add_argument_group( "Input", description="Specify various input sources\n\n" "All input fields support several items (i.e. names, IDs, " "tags, etc.). Items must be comma-separated.", gooey_options={'columns': 1}) input_.add_argument("--urls", default="", metavar="Direct URLs", help="Provide direct URL input") input_.add_argument("--ids", default="", metavar="Coub IDs", help="Download coubs with the given IDs") input_.add_argument("--channels", default="", metavar="Channels", help="Download channels with the given names") input_.add_argument("--recoubs", metavar="Recoubs", default=defs.RECOUB_LABEL[defs.RECOUBS], choices=["No Recoubs", "With Recoubs", "Only Recoubs"], help="How to treat recoubs during channel downloads") input_.add_argument( "--tags", default="", metavar="Tags", help="Download coubs with at least one of the given tags") input_.add_argument("--searches", default="", metavar="Search Terms", help="Download search results for the given terms") input_.add_argument("--communities", default="", metavar="Communities", help="Download coubs from the given communities") input_.add_argument("--lists", default="", widget="MultiFileChooser", metavar="Link Lists", help="Read coub links from input lists", gooey_options={'message': "Choose link lists"}) input_.add_argument("--random", action="count", metavar="Random", help="Download N*1000 randomly generated coubs") input_.add_argument("--hot", action="store_true", widget="BlockCheckbox", metavar="Hot Section", help="Download coubs from the hot section") # Common Options common = parser.add_argument_group("General", gooey_options={'columns': 1}) common.add_argument("--prompt", choices=["yes", "no"], default=defs.PROMPT, metavar="Prompt Behavior", help="How to answer user prompts") common.add_argument("--repeat", type=coub.positive_int, default=defs.REPEAT, metavar="Loop Count", help="How often to loop the video stream") common.add_argument("--duration", type=coub.valid_time, default=defs.DURATION, metavar="Limit duration", help="Max. duration of the output (FFmpeg syntax)") common.add_argument("--preview", default=defs.PREVIEW, metavar="Preview Command", help="Command to invoke to preview each finished coub") common.add_argument( "--archive", type=coub.valid_archive, default=defs.ARCHIVE, widget="FileSaver", metavar="Archive", gooey_options={'message': "Choose archive file"}, help="Use an archive file to keep track of already downloaded coubs") common.add_argument( "--keep", action="store_const", const=True, default=defs.KEEP, widget="BlockCheckbox", metavar="Keep streams", help="Whether to keep the individual streams after merging") # Download Options download = parser.add_argument_group("Download", gooey_options={'columns': 1}) download.add_argument( "--connections", type=coub.positive_int, default=defs.CONNECTIONS, metavar="Number of connections", help="How many connections to use (>100 not recommended)") download.add_argument( "--retries", type=int, default=defs.RETRIES, metavar="Retry Attempts", help="How often to reconnect to Coub after connection loss " "(<0 for infinite retries)") download.add_argument("--max-coubs", type=coub.positive_int, default=defs.MAX_COUBS, metavar="Limit Quantity", help="How many coub links to parse") # Format Selection formats = parser.add_argument_group("Format", gooey_options={'columns': 1}) formats.add_argument("--v-quality", choices=["Best quality", "Worst quality"], default=defs.QUALITY_LABEL[defs.V_QUALITY], metavar="Video Quality", help="Which video quality to download") formats.add_argument("--a-quality", choices=["Best quality", "Worst quality"], default=defs.QUALITY_LABEL[defs.A_QUALITY], metavar="Audio Quality", help="Which audio quality to download") formats.add_argument( "--v-max", choices=["med", "high", "higher"], default=defs.V_MAX, metavar="Max. Video Quality", help="Cap the max. video quality considered for download") formats.add_argument( "--v-min", choices=["med", "high", "higher"], default=defs.V_MIN, metavar="Min. Video Quality", help="Cap the min. video quality considered for download") formats.add_argument( "--aac", default=defs.AAC_LABEL[defs.AAC], choices=["Only MP3", "No Bias", "Prefer AAC", "Only AAC"], metavar="Audio Format", help="How much to prefer AAC over MP3") formats.add_argument("--special", choices=["None", "Share", "Video only", "Audio only"], default=defs.SPECIAL_LABEL[(defs.SHARE, defs.V_ONLY, defs.A_ONLY)], metavar="Special Formats", help="Use a special format selection") # Output output = parser.add_argument_group("Output", gooey_options={'columns': 1}) output.add_argument("--output-list", type=os.path.abspath, widget="FileSaver", default=defs.OUTPUT_LIST, metavar="Output to List", gooey_options={'message': "Save link list"}, help="Save all parsed links in a list (no download)") output.add_argument("--path", type=os.path.abspath, default=defs.PATH, widget="DirChooser", metavar="Output Directory", help="Where to save downloaded coubs", gooey_options={ 'message': "Pick output destination", 'default_path': defs.PATH, }) output.add_argument( "--merge-ext", default=defs.MERGE_EXT, metavar="Output Container", choices=["mkv", "mp4", "asf", "avi", "flv", "f4v", "mov"], help="What extension to use for merged output files " "(has no effect if no merge is required)") output.add_argument("--name-template", default=defs.NAME_TEMPLATE, metavar="Name Template", help=dedent(f"""\ Change the naming convention of output files Special strings: %id% - coub ID (identifier in the URL) %title% - coub title %creation% - creation date/time %community% - coub community %channel% - channel title %tags% - all tags (separated by _) Other strings will be interpreted literally This option has no influence on the file extension """)) # Advanced Options parser.set_defaults( verbosity=1, ffmpeg_path=defs.FFMPEG_PATH, coubs_per_page=defs.COUBS_PER_PAGE, # allowed: 1-25 tag_sep=defs.TAG_SEP, fallback_char=defs.FALLBACK_CHAR, write_method=defs.WRITE_METHOD, # w -> overwrite, a -> append chunk_size=defs.CHUNK_SIZE, ) args = parser.parse_args() args.input = [] args.input.extend( [coub.mapped_input(u) for u in args.urls.split(",") if u]) args.input.extend([i for i in args.ids.split(",") if i]) args.input.extend([coub.LinkList(l) for l in args.lists.split(",") if l]) args.input.extend([coub.Channel(c) for c in args.channels.split(",") if c]) args.input.extend([coub.Tag(t) for t in args.tags.split(",") if t]) args.input.extend([coub.Search(s) for s in args.searches.split(",") if s]) args.input.extend( [coub.Community(c) for c in args.communities.split(",") if c]) if args.hot: args.input.append(coub.HotSection()) if args.random: for _ in range(args.random): args.input.append(coub.RandomCategory()) # Read archive content if args.archive and os.path.exists(args.archive): with open(args.archive, "r") as f: args.archive_content = {l.strip() for l in f} else: args.archive_content = set() # The default naming scheme is the same as using %id% # but internally the default value is None if args.name_template == "%id%": args.name_template = None # Defining whitespace or an empty string in the config isn't possible # Instead translate appropriate keywords if args.tag_sep == "space": args.tag_sep = " " if args.fallback_char is None: args.fallback_char = "" elif args.fallback_char == "space": args.fallback_char = " " return translate_to_cli(args)
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 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)