def main(): # Gooey stuff parser = GooeyParser(description="Gather AncestryDNA Matches") username = parser.add_argument('username', metavar='Ancestry User Name') password = parser.add_argument('password', metavar='Ancestry Password', widget='PasswordField') user_max = parser.add_argument( 'pages', metavar='Number of match pages to gather', help='1 page is about 50 matches. Default is 30 pages (~1500 matches).' ) if user_max == "": user_max = "30" max_pages = int(user_max) args = parser.parse_args() # Delete old files delete_old() # Create new files make_data_file("nodes.csv") make_data_file("edges.csv") # Login # username, password, max_pages = get_credentials() payload = {"username": username, "password": password} # Create session object session_requests = requests.session() # Start Session with session_requests as session: session.post(login_url, data=payload) data = get_json(session, prefix_url) # Get the list of tests available test_guids = get_guids(data) print() for k, v in test_guids.items(): # Print them out...work on formatting print("Test", str(k) + ":", v[0], v[1]) print() test_selection = int( input("Select the Test # that you want to gather \ matches for: ")) guid = test_guids[test_selection][1] # Start to gather match data using number of pages variable print("Gathering match details. Please wait.") for page_number in range(1, max_pages + 1): test_url = str(prefix_url + guid + matches_url_suffix + str(page_number)) matches = get_json(session, test_url) harvest_matches(session, matches, guid) time.sleep(1)
def gui_main(): parser = GooeyParser( description="Creating blanks for C language source code files") parser.add_argument('source_dir', widget='DirChooser', help="The directory containing source code files to be processed.") args = parser.parse_args() main(args.source_dir)
def param_parser(): parser = GooeyParser(description="Add attributes to a Tile Layout") parser.add_argument("inputfile", metavar="Input Tilelayout File", widget="FileChooser", help="Select Tilelayout json file") parser.add_argument("output_dir", metavar="Output Directory", widget="DirChooser", help="Output directory", default="") attr_group = parser.add_argument_group("Attribute", gooey_options={ 'show_border': True, 'columns': 3 }) attr_group.add_argument("attrname", metavar="Attribute Name", help="Attribute Name\n\n") attr_group.add_argument( "attrval", metavar="Attribute Value", help= "if Naming convention for files used, \nreplace x,y with %X% and %Y%.\nex: dem_%X%m_%Y%m.asc" ) attr_group.add_argument( "--division", metavar="Shorten X, Y", help= "Reduce the X and Y values to the nearest 100,1000. \nleave blank for None\n", type=int) args = parser.parse_args() return args
def param_parser(): main_parser = GooeyParser(description="Check Header") main_parser.add_argument("inputfolder", metavar="Input Folder", widget="DirChooser", help="Select input las/laz folder", default="") main_parser.add_argument("outputfolder", metavar="Output Folder", widget="DirChooser", help="Select output folder", default="") main_parser.add_argument("filetype", metavar="Input File Type", default='laz') main_parser.add_argument("attrib", metavar="Attribute To search", default='') main_parser.add_argument("cores", metavar="Cores", help="No of cores to run in", type=int, default=8) return main_parser.parse_args()
def arg_define(): parser = GooeyParser(description='Pix Plot analysis') parser.add_argument( 'image_Dir', widget='DirChooser', help= 'Folder containing all images prepared for analysis. Images should be in JPEG format ending in .jpg' ) parser.add_argument( 'model_use', widget='FileChooser', help='Select the pretrained model that you want to use.') parser.add_argument( 'clusters', action='store', type=int, help='Choose the number of hotspots you want pix_plot to find') parser.add_argument('output', widget='DirChooser', help='The folder where output files will be stored') parser.add_argument('method', widget='Dropdown', choices=['umap', 'tsne'], action='store', help='Select method for mapping, type umap or TSNE') args = parser.parse_args() return args
def main(): # TODO Add option to load previous guild id parser = GooeyParser(description='Game listener') parser.add_argument( 'guild_id', metavar='Server ID', help='Can be found using the .info command!' ) parser.add_argument( 'vc_id', metavar='Voice Channel ID', help='Can be found using the .info command!' ) args = parser.parse_args() print(stylize("-----------------------------------------------------------------------------", attr("bold"))) print(stylize("Thanks for checking out ImposterBot!", attr("underlined"))) print(stylize("================================================", attr("bold"))) print(stylize("ImposterBot is an ongoing project and is open source.", fg("green"))) print("If you have any questions or issues or would like to learn more, check it out here:") print(stylize("ImposterBot GitHub.", fg("blue") + attr("bold"))) print(stylize("https://github.com/shiv213/ImposterBot", fg("blue"))) print(stylize("Made with <3 by Shiv Trivedi.", fg("violet") + attr("bold"))) print(stylize("-----------------------------------------------------------------------------", attr("bold"))) while running: pointer_loop() time.sleep(1) changes_loop() if previous_state != current_state: pushData["serverID"] = args.guild_id pushData["vcID"] = args.vc_id # pushData["roomCode"] = "TESTER" # pushData["players"] = {} # pushData["players"]["red"] = "alive" # pushData["players"]["blue"] = "alive" # pushData["players"]["green"] = "alive" # pushData["players"]["pink"] = "alive" # pushData["players"]["orange"] = "alive" # pushData["players"]["yellow"] = "alive" # pushData["players"]["black"] = "alive" # pushData["players"]["white"] = "alive" # pushData["players"]["purple"] = "alive" # pushData["players"]["brown"] = "alive" # pushData["players"]["cyan"] = "alive" # pushData["players"]["lime"] = "alive" if current_state == VoteState(0): pushData["gameState"] = "game" print(stylize("MUTED", fg("red") + attr("bold"))) else: pushData["gameState"] = "discussion" print(stylize("UNMUTED", fg("green") + attr("bold"))) # print(pushData) response = requests.post('https://imposter-bot.herokuapp.com/push', json=pushData) # response = requests.post('http://127.0.0.1/push', json=pushData) if response.status_code != 200: print("Connection error!")
def main(): if is_windows: ctypes.windll.shcore.SetProcessDpiAwareness(2) parser = GooeyParser(description='') parser.add_argument('--src', metavar='源目录', widget='DirChooser', help='源目录, 如大疆SD的目录就是: X:\\DCIM') parser.add_argument( '--dst', metavar='输出目录', widget='DirChooser', help='目的目标, 如D:\\Target,则会将DCIM内的文件拷贝到D:\\Target\\DCIM') argcomplete.autocomplete(parser) args = parser.parse_args() if not args.src or not args.dst: parser.print_usage() exit(1) if not os.path.exists(args.src): print('source path:{} does not exist.'.format(args.src)) exit(1) if not os.path.exists(args.src): print('source path:{} does not exist.'.format(args.dst)) exit(1) print('{} -> {}'.format(args.src, args.dst)) args.dst = util.get_copy_dst_name(args.src, args.dst) copy_files(args.src, args.dst) error = check_copy(args.src, args.dst) if error: exit(1) exit(0)
def get_params(): parser = GooeyParser() parser.add_argument('text1', metavar='Text 1', help='Text 1 help') parser.add_argument('date', metavar='Date', widget='DateChooser') args = parser.parse_args() return args
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)
def main(): parser = GooeyParser( description = 'Assign students to presentation topics') # parser.add_argument( # '--test', # action='store_true', # help = 'Runs a test') parser.add_argument( 'input', widget = 'FileChooser', type = argparse.FileType('r'), help = 'A text file containing a list of presentations along with student names and their preferences') parser.add_argument( '--similarity', type = float, default = 0.95, help = 'A number between 0.7 and 1.0 indicating the tolerance used when comparing strings. 1.0 is strictest.') args = parser.parse_args() assert 1.0 >= args.similarity >= 0.7, "Similarity must be between 0.7 and 1.0" jaro_winkler_threshold = args.similarity prefs = Prefs.from_text(args.input) sol = prefs.solve() prefs.print(sol)
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 argumentParser(): parser = GooeyParser(description="Ying Da Wang, Ryan Armstrong, Peyman Mostaghimi") parser.add_argument('Input_Images', help='Folder containing input images', widget="DirChooser") #parser.add_argument('Network_Weights', help="Name and location of the network weights", widget='FileChooser') parser.add_argument('Scale_Factor', type=str, choices=['4'], help='Upsampling factor (Future releases will support more options)') parser.add_argument('Bit_Depth', type=str, choices=['uint8'], help='Bit depth of your input images (Future releases will support more options)') parser.add_argument('Image_Dimension',type=str, choices=['2D','3D'], help='Dimensions of input images') parser.add_argument('Use_CPU', type=str, choices=['yes', 'no'], help='Force the network to use the CPU (will default to CPU if no compatible GPU is detected)') ''' parser = argparse.ArgumentParser(description='') parser.add_argument('--Input_Images', type=str, help='Folder containing input images') #parser.add_argument('--Network_Weights', type=str, help="Name and location of the network weights") parser.add_argument('--Scale_Factor', type=str, help='Upsampling factor (Future releases will support more options)') parser.add_argument('--Bit_Depth', type=str, help='Bit depth of your input images (Future releases will support more options)') parser.add_argument('--Image_Dimension',type=str, help='Dimensions of input images') parser.add_argument('--Use_CPU', type=str2bool, help='Force the network to use the CPU (will default to CPU if no compatible GPU is detected)') ''' args = parser.parse_args() return args
def main(): desc = "A Python GUI App to convert Jupyter Notebooks to other formats" template_select_help_msg = "Select a template (.tplx-file) to apply" my_parser = GooeyParser(description=desc) my_parser.add_argument( "Input_Directory", help="Select a directory to filled with notebooks", widget="DirChooser" ) my_parser.add_argument( "Template_File", help=template_select_help_msg, widget="FileChooser" ) args = my_parser.parse_args() # get all of the .ipynb file paths nb_filepath_list = [file for file in (Path(args.Input_Directory)).glob("**/*.ipynb")] # construct template file path template_file_Path = Path(args.Template_File) for f in nb_filepath_list: print('Converting Notebook:') print('infile Path') print(f) nbnode = file_to_nbnode(f) print('Out file Path') outfile_Path = Path(f.parent, Path(f.stem)) print(outfile_Path) # create lab_title.tplx file where the lab title from the input notebook file name is derived lab_title_str = extract_lab_title(f) create_lab_title_template(lab_title_str, "lab_title.tplx") export_nbnode(nbnode, outfile_Path, pdf=False, template_file=template_file_Path)
def main(): # TODO Add option to load previous guild id parser = GooeyParser(description='Game listener') parser.add_argument( 'guild_id', metavar='Server ID', help='Can be found using the .server command!' ) args = parser.parse_args() print(stylize("-----------------------------------------------------------------------------", attr("bold"))) print(stylize("Thanks for checking out ImposterBot!", attr("underlined"))) print(stylize("================================================", attr("bold"))) print(stylize("ImposterBot is an ongoing project and is open source.", fg("green"))) print("If you have any questions or issues or would like to learn more, check it out here:") print(stylize("ImposterBot GitHub.", fg("blue") + attr("bold"))) print(stylize("https://github.com/shiv213/ImposterBot", fg("blue"))) print(stylize("Made with <3 by Shiv Trivedi.", fg("violet") + attr("bold"))) print(stylize("-----------------------------------------------------------------------------", attr("bold"))) while running: pointer_loop() time.sleep(1) changes_loop() if previous_state != current_state: if current_state == 0: print(stylize("MUTED", fg("red") + attr("bold"))) else: print(stylize("UNMUTED", fg("green") + attr("bold"))) db.child("guilds/" + args.guild_id).child("voteState").set(current_state)
def arbitrary_function(): desc = u"コマンドライン引数を入力してください" file_help_msg = u"処理したいファイルの名前" my_cool_parser = GooeyParser(description=desc) my_cool_parser.add_argument('foo', metavar=u"ファイルブラウザ", help=file_help_msg, widget="FileChooser") # positional my_cool_parser.add_argument('-d', metavar=u'--デュレーション', default=2, type=int, help=u'プログラム出力の期間(秒)') my_cool_parser.add_argument('-s', metavar=u'--スケジュール', help=u'日時プログラムを開始すべき', widget='DateChooser') my_cool_parser.add_argument("-c", metavar=u"--ショータイム", action="store_true", help=u"カウントダウンタイマーを表示します") my_cool_parser.add_argument("-p", metavar=u"--ポーズ", action="store_true", help=u"一時停止の実行") args = my_cool_parser.parse_args() main(args)
def makeParser(self, **kwargs): parser = GooeyParser(description='description') parser.add_argument( '--widget', action='store_true', **kwargs) return parser
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)) # 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="ABP swaths") parser.add_argument("laspath", metavar="LAS files", widget="DirChooser", help="Select input las/laz file", default=stored_args.get('laspath')) parser.add_argument("filetype",metavar="Input File type", help="laz or las", default='laz') parser.add_argument("outputfolder", metavar="output Directory",widget="DirChooser", help="output directory", default=stored_args.get('outputfolder')) parser.add_argument("areaname", metavar="AreaName",default=stored_args.get('areaname')) parser.add_argument("-co", "--cores",metavar="Cores", help="No of cores to run in", type=int, default=8) 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
def main(): ## Parse Command-Line arguments parser = GooeyParser(description="Task Exporter") parser.add_argument("user_name", help="Your library user name", type=str) parser.add_argument("password", help="Your library password", type=str, widget='PasswordField') # parser.add_argument("output_file", help="Output csv filename", type=str, widget='FileSaver') args = parser.parse_args() ## Read configuration file config = configparser.ConfigParser() config.read("config.cfg") library_client = LibraryTimeEntryProvider( library_url=config['Library']['server_url'], user_name=args.user_name, password=args.password, library_workitem_query=config['Library']['workitem_query']) clockify_client = ClockifyTimeEntryProvider( config["Clockify"]["api_key"], config["Clockify"]["workspace_id"]) ## OLD METHOD - Export to CSV then manual Import # export_library_tasks_to_file(library_client, args.output_file) ## NEW METHOD - Automatic Sync with library and clockify myServiceTest = ClockifyTaskSyncService(library_client, clockify_client) myServiceTest.sync()
def makeParser(self, **kwargs): parser = GooeyParser(description='description') parser.add_argument('--widget', action='count', widget="Counter", **kwargs) return parser
def main(): my_cool_parser = GooeyParser() my_cool_parser.add_argument('--No', choices=[True, False], default=True) my_cool_parser.add_argument('--Yes', choices=[True, False], default=False) args = my_cool_parser.parse_args()
def main(): desc = "Select file to parse for file attributes" parser = GooeyParser(description=desc, add_help=False) parser.add_argument("--filename", default="", widget='FileChooser') parser.add_argument("--dirchooser", default="", widget='DirChooser') args = parser.parse_args() file = args.filename dir = args.dirchooser if not file and not dir: print("No files selected") if dir and not file: scanDir(dir) elif file and not dir: scanFile(file) with os.scandir(dir) as dir_contents: for entry in dir_contents: info = entry.stat() print( f'{entry.name}\t Last Modified: {convert_date(info.st_mtime)}') print(f'{entry.name}\t Item Size: {info.st_size} bytes') print( f'{entry.name}\t Last Accessed: {convert_date(info.st_atime)}') print( f'{entry.name}\t Creation Time: {convert_date(info.st_ctime)}') print(f'{entry.name}\t Group ID of Owner: {info.st_gid}') print(f'{entry.name}\t Use ID of Owner: {info.st_uid}')
def main(): parser = GooeyParser() parser.add_argument('filename1') parser.add_argument('secret-advanced-argument', default='TOO POWERFUL!!', gooey_options={'visible': False}) args = parser.parse_args()
def test_parent_arguments_are_not_overridden(self): """ Verifies that the same named argument in a parent and child parser is accepted, and only the child parser survives. """ # Verify how vanilla argparse works base_parser = argparse.ArgumentParser(add_help=False) action1 = base_parser.add_argument("a_file", default="a") parser = argparse.ArgumentParser(parents=[base_parser]) action2 = parser.add_argument("a_file", default="b") self._verify_duplicate_parameters(action1, action2, parser) # So a child can't override a parent - this isn't textbook inheritance # Run the same test on GooeyParser base_parser = GooeyParser(add_help=False) action1 = base_parser.add_argument("a_file", widget="FileChooser", default="a") parser = GooeyParser(parents=[base_parser]) action2 = parser.add_argument("a_file", widget="DirChooser", default="b") self._verify_duplicate_parameters(action1, action2, parser) self.assertEqual(parser.widgets["a_file"], "FileChooser")
def get_gui(): parser = GooeyParser( description=( 'GUI for extracting and converting text. ' ) % locals(), ) parser.add_argument( 'filename', help='Filename to extract text from', widget='FileChooser' ) parser.add_argument( '-e', '--encoding', type=str, default=DEFAULT_ENCODING, choices=_get_available_encodings(), help='Specify the encoding of the output', ) parser.add_argument('-il', '--input-language', choices=LANGS_NETWORK.nodes, help='The input language to be converted from, for a full list please visit https://g2p-studio.herokuapp.com/api/v1/langs') parser.add_argument('-ol', '--output-language', choices=LANGS_NETWORK.nodes, help='The output language to be converted to, for a full list please visit https://g2p-studio.herokuapp.com/api/v1/langs') parser.add_argument( '-m', '--mapping', type=os.path.abspath, required=False, widget='FileChooser', help='Path to a custom lookup table for conversion. Only use this if the g2p library does not have the mapping you want.', ) return parser
def main(): parser = GooeyParser(description="Show pubmed abstract.") parser.add_argument("PMID", help="PMID of the article.") args = parser.parse_args() # 发送请求, 返回请求 response = requests.get("https://pubmed.ncbi.nlm.nih.gov/{}/".format( args.PMID)) body = response.text # 解析html soup = BeautifulSoup(body, "html.parser") # find title print("Title:\n") print(soup.find(name="title").text.strip("\n")) # find abstract print("\n\nAbstract:\n") print( soup.find(attrs={ "id": "enc-abstract" }).find(name="p").text.strip("\n")) return
def main(): parser = GooeyParser(description='Just display the console') parser.add_argument('--host', help='Ze host!', default=os.environ.get('HOST')) args = parser.parse_args()
def add(parser: GooeyParser = GooeyParser()) -> GooeyParser: parser.add_argument( "--save-directory", metavar="Save directory", widget="DirChooser", ) return parser
def main(): parser = GooeyParser(description='Route monotoring') parser.add_argument('Date select', help='Enter Date', widget='DateChooser') parser.add_argument('--query', help='Base search string') args = parser.parse_args() print(args.query)
def get_params(): parser = GooeyParser() parser.add_argument('search_term', help="The search term") parser.add_argument(dest='mode', widget='Dropdown', choices=['Director', 'IMDB Code', 'Keyword']) args = parser.parse_args() return args.mode, args.search_term
def main(): parser = GooeyParser(description="A Graphical User Interface for the sampleSheet check script") parser.add_argument('samplesheet', metavar='samplesheet', help='The Samplesheet to check', widget='FileChooser') return parser.parse_args()
def main(): parser = GooeyParser(description='Zelda clean this mess\nReorganize date/pod -> pod/date') parser.add_argument('pattern', nargs='?', default=r"""(.*)_(.*)_(.*)_(.*)_(.*)_(.*)-(.{8})-(.*).datx_(.*)""", help="pattern which allow to get groups\nmoteur = mo.group(1)\nuseless = mo.group(2)\nbanc = mo.group(3)\npod = mo.group(4)\nuseless = mo.group(5)\nrun = mo.group(6)\ndate = mo.group(7)\nheure = mo.group(8)") parser.add_argument('srcDir', nargs='?', default=os.getcwd(), widget='FileChooser', help='Engine directory : root/???/*.*') args = parser.parse_args() Zelda.trier(args.srcDir, args.pattern)
def get_params(): parser = GooeyParser() parser.add_argument('search_term', help="The search term") parser.add_argument( dest='mode', widget='Dropdown', choices=['Director', 'IMDB Code', 'Keyword'] ) args = parser.parse_args() return args.mode, args.search_term
def main(): parser = GooeyParser(prog="example_progress_bar_2") parser.add_argument("steps", type=int, default=15) parser.add_argument("delay", type=int, default=1) args = parser.parse_args(sys.argv[1:]) for i in range(args.steps): print("progress: {}/{}".format(i+1, args.steps)) sys.stdout.flush() sleep(args.delay)
def main(): parser = GooeyParser(description="Calculate a rocket stage's delta V for KSP") parser.add_argument("mass_initial", help="Initial mass of the spacecraft (tonnes)", type=float) parser.add_argument("mass_final", help="Final mass of the spacecraft (tonnes)", type=float) parser.add_argument("isp", help="Specific impulse", type=float) parser.add_argument("--thrust", help="Thrust per engine (0 for unknown)", type=float, default=0.0) parser.add_argument("--engine_count", help="Number of engines", type=int, default=1) args = parser.parse_args() thrust = args.thrust * args.engine_count get_and_process_stage(args.mass_initial, args.mass_final, args.isp, thrust)
def arbitrary_function(): desc = u"\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u5f15\u6570\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044" file_help_msg = u"\u51e6\u7406\u3057\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u540d\u524d" my_cool_parser = GooeyParser(description=desc) my_cool_parser.add_argument(u"\u30d5\u30a1\u30a4\u30eb\u30d6\u30e9\u30a6\u30b6", help=file_help_msg, widget="FileChooser") # positional my_cool_parser.add_argument('-d', u'--\u30c7\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3', default=2, type=int, help=u'\u30d7\u30ed\u30b0\u30e9\u30e0\u51fa\u529b\u306e\u671f\u9593\uff08\u79d2\uff09') my_cool_parser.add_argument('-s', u'--\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb', type=int, help=u'\u65e5\u6642\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u958b\u59cb\u3059\u3079\u304d', widget='DateChooser') my_cool_parser.add_argument("-c", u"--\u30b7\u30e7\u30fc\u30bf\u30a4\u30e0", action="store_true", help=u"\u30ab\u30a6\u30f3\u30c8\u30c0\u30a6\u30f3\u30bf\u30a4\u30de\u30fc\u3092\u8868\u793a\u3057\u307e\u3059") my_cool_parser.add_argument("-p", u"--\u30dd\u30fc\u30ba", action="store_true", help=u"\u4e00\u6642\u505c\u6b62\u306e\u5b9f\u884c") args = my_cool_parser.parse_args() main(args)
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( 'foo', metavar=u"\u0432\u044b\u0431\u043e\u0440\u0430\u0444\u0430\u0439\u043b\u043e\u0432", help=file_help_msg, widget="FileChooser") my_cool_parser.add_argument( 'bar', metavar=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") my_cool_parser.add_argument( '-d', metavar=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', metavar=u'--\u043a\u0440\u043e\u043d \u002d \u0433\u0440\u0430\u0444\u0438\u043a', help=u'\u0414\u0430\u0442\u0430', widget='DateChooser') args = my_cool_parser.parse_args() main(args)
def main(): parser = GooeyParser(description='Process some integers.') parser.add_argument( 'required_field', metavar='Some Field', help='Enter some text!') parser.add_argument( '-f', '--foo', metavar='Some Flag', action='store_true', help='I turn things on and off') args = parser.parse_args() print('Hooray!')
def _parser(): parser = GooeyParser(description='Look up an object in VizieR' ' and print mean/median' ' values of given parameters') parser.add_argument('object', help='Object, e.g. HD20010', nargs='+') parser.add_argument('-p', '--params', default=True, action='store_true', help='List of parameters (Teff, logg, [Fe/H] be default)') parser.add_argument('-m', '--method', choices=['median', 'mean', 'both'], default='both', help='Which method to print values (mean or median). Default is both') parser.add_argument('-c', '--coordinate', default=False, action='store_true', help='Return the RA and DEC (format for NOT\'s visibility plot)') return parser.parse_args()
def main(): my_cool_parser = GooeyParser(description='This Demo will raise an error!') my_cool_parser.add_argument( "explode", metavar='Should I explode?', help="Determines whether or not to raise the error", choices=['Yes', 'No'], default='Yes') args = my_cool_parser.parse_args() if 'yes' in args.explode.lower(): print('Will throw error in') for i in range(5, 0, -1): print(i) time.sleep(.7) raise Exception(BOOM) print(NO_BOOM) print('No taste for danger, eh?')
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)
def _parser(): '''The argparse stuff''' parser = GooeyParser(description='CRIRES spectrum to an 1D spectrum') parser.add_argument('fname', action='store', widget='FileChooser', help='Input fits file') parser.add_argument('--output', default=False, help='Output to this name. If nothing is given, output will be: "wmin-wmax.fits"') parser.add_argument('-u', '--unit', default='angstrom', choices=['angstrom', 'nm'], help='The unit of the output wavelength') parser.add_argument('-c', '--clobber', default=True, action='store_false', help='Do not overwrite existing files.') args = parser.parse_args() return args
def main(): parser = GooeyParser(description="PowerPoint Exporter") parser.add_argument('powerpoint', widget="FileChooser") parser.add_argument('output', help="Folder to place resulting images", widget="DirChooser") parser.add_argument('width', help="Width of resulting image (0-3072)") parser.add_argument('height', help="Height of resulting image (0-3072)") args = parser.parse_args() if not (os.path.isfile(args.powerpoint) and os.path.isdir(args.output)): raise "Invalid paths!" export_presentation(args.powerpoint, args.output, args.width, args.height) print "Done!"
def parse_args(progress_regex=r"^progress: (\d+)%$", disable_stop_button=True): """ Use GooeyParser to build up the arguments we will use in our script Save the arguments in a default json file so that we can retrieve them every time we run the script. """ 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] args_file = "{}-args.json".format(script_name) # 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='Mail Merge') parser.add_argument('data_directory', action='store', default=stored_args.get('data_directory'), widget='DirChooser', help="Source directory that contains Excel files") parser.add_argument('output_directory', action='store', widget='DirChooser', default=stored_args.get('output_directory'), help="Output directory to save merged files") #parser.add_argument("FileSaver", help="Name the output file you want to process", widget="FileSaver") #parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite output file (if present)") #parser.add_argument("-s", "--sheets", action="store_true", help="Would you like to ignore multiple sheets?") 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
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 parse_args_gooey(): '''parse command line arguments''' parser = GooeyParser(description="Convert pgm image to png or jpg") parser.add_argument("directory", default=None, help="directory containing PGM image files", widget='DirChooser') parser.add_argument("--output-directory", default=None, help="directory to use for converted files", widget='DirChooser') parser.add_argument("--format", default='png', choices=['png', 'jpg'], help="type of file to convert to (png or jpg)") return parser.parse_args()
def main(): # get some settings from setting file settings = SettingFileReader() defaultOutput = settings.getSetting("defaultSettings", "output") defaultWidth = settings.getSetting("defaultSettings", "width") defaultFramerate = settings.getSetting("defaultSettings", "framerate") defaultBitrateKb = settings.getSetting("defaultSettings", "bitratekb") description = "Download tracks and playlists from Youtube." #parser = argparse.ArgumentParser(description=description) parser = GooeyParser(description=description) parser.add_argument('-output', required=True, help='Folder to save the tracks' , widget="DirChooser") parser.add_argument('-track', required=False, default=None, help='Youtube track ID' ) parser.add_argument('-playlist', required=False, default=None, help='Youtube playlist ID' ) parser.add_argument('-audio', action="store_true", default=False, help="Download only the audio part (usualy m4a format)") args = parser.parse_args() # the user must have chosen between a track and a Playlist. # Though none of them is mandatory, so we have to check. if(not args.track and not args.playlist): print("[ERROR] You must fill at least one of those fields:\n\t- Track - to download a single track\n\t- Playlist - to download a entire playlist") else: pw = PafyWrapper() # download a track if(args.track): try: pw.downloadTrack(args.track, path=args.output, audio=args.audio) except ValueError as e: print("[INVALID URL]" + e) if(args.playlist): #try: print(args.playlist) pw.downloadPlaylist(args.playlist, path=args.output, audio=args.audio)
def main(): parser = GooeyParser(description="Compares Images!") parser.add_argument('directoryName', help="Name of the directory to process.", widget = "DirChooser") parser.add_argument('masterName', help="Name of the master image. Please put master image in the chosen directory.", widget = "FileChooser") parser.add_argument('--showOriginalImage', help = "(optional), default is False", nargs = "?", default = False) parser.add_argument('--showRegionOfInterest', help = "(optional), default is true", nargs = "?", default = True) parser.add_argument('--verbose', help = "Show Full Information, default is False", nargs = "?", default = False) # parser.add_argument('outputFileName', help="name of the output file") # parser.add_argument('extension', help = "(optional)name of extension (ex: JPG)") args = parser.parse_args() test_dirj = args.directoryName masterName = args.masterName showOriginalImage = args.showOriginalImage showRegionOfInterest = args.showRegionOfInterest if showOriginalImage == False: showOriginalImage = False else: showOriginalImage = True if showRegionOfInterest == True or showRegionOfInterest == "True" or showRegionOfInterest == "true": showRegionOfInterest = True else: showRegionOfInterest = False verbose = args.verbose if verbose != False or verbose != "false" or verbose != "False": verbose = True else: verbose = False # extensionFinal = pconfig.extension if (extension == "") else ("*" + extension) extensionFinal = pconfig.extension controlInfo = imageProcessor(masterName, test_dirj, showOriginalImage, showRegionOfInterest, verbose = verbose, control = True) controlScore = controlInfo[1] info = [] for fileName in glob.glob(os.path.join(test_dirj, extensionFinal)): if fileName.lower() != os.path.join(test_dirj, masterName).lower(): imageInfo = imageProcessor(fileName, test_dirj, showOriginalImage, showRegionOfInterest, controlScore = controlScore) info.append(imageInfo) print "Output File Name:" + writeInfo(info,test_dirj, controlInfo) print "done"
def main(): parser = GooeyParser(description='Package your Gooey applications into standalone executables') parser.add_argument( "program_name", metavar='Program Name', help='Destination name for the packaged executable' ) parser.add_argument( "source_path", metavar="Program Source", help='The main source file of your program', widget="FileChooser" ) parser.add_argument( "output_dir", metavar="Output Directory", help='Location to store the generated files', widget="DirChooser" ) args = parser.parse_args() if not os.path.exists(args.source_path): raise IOError('{} does not appear to be a valid file path'.format(args.source_path)) if not os.path.exists(args.output_dir): raise IOError('{} does not appear to be a valid directory'.format(args.output_dir)) with open(os.path.join(local_path(), 'build_template'), 'r') as f: spec_details = f.read().format(program_name=args.program_name, source_path=args.source_path) fileno, path = tempfile.mkstemp(prefix='gooeybuild', suffix='.spec') with open(path, 'w') as f: f.write(spec_details) cmd = 'pyinstaller "{0}" --distpath="{1}"'.format(path, args.output_dir) print cmd from pexpect.popen_spawn import PopenSpawn child = PopenSpawn(cmd) child.logfile = sys.stdout child.wait() print dedent(''' ___ _ _ ______ _ / _ \| | | | _ \ | | / /_\ \ | | | | | |___ _ __ ___| | | _ | | | | | | / _ \| '_ \ / _ \ | | | | | | | | |/ / (_) | | | | __/_| \_| |_/_|_| |___/ \___/|_| |_|\___(_) ''') print 'Wrote Executable file to {}'.format(args.output_dir)
def parse_args(): """ Use GooeyParser to build up the arguments we will use in our script Save the arguments in a default json file so that we can retrieve them every time we run the script. """ 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] args_file = "{}-args.json".format(script_name) # 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='Create Quarterly Marketing Report') parser.add_argument('data_directory', action='store', default=stored_args.get('data_directory'), widget='DirChooser', help="Source directory that contains Excel files") parser.add_argument('output_directory', action='store', widget='DirChooser', default=stored_args.get('output_directory'), help="Output directory to save summary report") parser.add_argument('cust_file', action='store', default=stored_args.get('cust_file'), widget='FileChooser', help='Customer Account Status File') parser.add_argument('-d', help='Start date to include', default=stored_args.get('d'), widget='DateChooser') 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
def _parser(): """Take care of all the argparse stuff. :returns: the args """ parser = GooeyParser(description='Wavelength Calibrate CRIRES Spectra') parser.add_argument('fname', action='store', widget='FileChooser', help='Input fits file') parser.add_argument('-o', '--output', default=False, action='store', widget='FileChooser', help='Ouput Filename',) parser.add_argument('-t', '--telluric', default=False, action='store', widget='FileChooser', help='Telluric line Calibrator',) #parser.add_argument('-t', '--telluric', # help='Over plot telluric spectrum', # action='store_true') #parser.add_argument('-c', '--ccf', # default='none', # choices=['none', 'sun', 'model', 'telluric', 'both'], # help='Calculate the CCF for Sun/model or tellurics ' # 'or both.') #parser.add_argument('--ftype', help='Select which type the fits file is', # choices=['ARES', 'CRIRES'], default='ARES') #parser.add_argument('--fitsext', help='Select fits extention, Default 0.', # choices=['0', '1', '2', '3', '4'], default='0') #parser.add_argument('--fitsext', default=0, type=int, # help='Select fits extention, 0 = Primary header') args = parser.parse_args() return args
def get_args() -> Namespace: parser = GooeyParser(description='Process VMI counts and ' 'create quote and OE Upload files') parser.add_argument( 'count_file', default=INPUT_COUNT_FILE, widget='FileChooser', help='Provide a path to a count file to import (Excel or CSV)') parser.add_argument( 'backorder_file', default=INPUT_BACKORDER_FILE, widget='FileChooser', help='Provide a path to a backorder file to import (Excel or CSV)') parser.add_argument( '--config', dest='config_file', default=os.path.join(BASE_PATH, CONFIG_FOLDER, CONFIG_FILE), widget='FileChooser', help='Provide a config file in JSON format; see example') parser.add_argument( '--product_data', dest='product_data_file', default=os.path.join(BASE_PATH, DATA_FOLDER, DATA_FILE), widget='FileChooser', help='Provide a product data file in CSV or Excel format; see example') parser.add_argument( '--path', '-P', dest='output_path', default=OUTPUT_PATH, widget='DirChooser', help='Provide a folder path for the ouput files') parser.add_argument( '--add_prices', '-A', dest='add_prices', action='store_true', widget='CheckBox', help='Toggle if you want to add prices to upload file') parser.add_argument( '--quote', '-Q', dest='quote_name', default=OUTPUT_QUOTE_FILE, help='Provide a filename prefix for output of Excel quotation file(s)') parser.add_argument( '--OEUpload', '-O', dest='OEUpload_name', default=OUTPUT_OEUPLOAD_FILE, help='Provide a filename for output of Excel OE upload template file') return parser.parse_args()
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 main(): settings_msg = 'Subparser example demonstating bundled configurations ' \ 'for Siege, Curl, and FFMPEG' parser = GooeyParser(description=settings_msg) parser.add_argument('--verbose', help='be verbose', dest='verbose', action='store_true', default=False) subs = parser.add_subparsers(help='commands', dest='command') curl_parser = subs.add_parser( 'curl', help='curl is a tool to transfer data from or to a server') curl_parser.add_argument('Path', help='URL to the remote server', type=str, widget='FileChooser') curl_parser.add_argument('--connect-timeout', help='Maximum time in seconds that you allow curl\'s connection to take') curl_parser.add_argument('--user-agent', help='Specify the User-Agent string ') curl_parser.add_argument('--cookie', help='Pass the data to the HTTP server as a cookie') curl_parser.add_argument('--dump-header', type=argparse.FileType, help='Write the protocol headers to the specified file') curl_parser.add_argument('--progress-bar', action="store_true", help='Make curl display progress as a simple progress bar') curl_parser.add_argument('--http2', action="store_true", help='Tells curl to issue its requests using HTTP 2') curl_parser.add_argument('--ipv4', action="store_true", help=' resolve names to IPv4 addresses only') # ######################################################## siege_parser = subs.add_parser( 'siege', help='Siege is an http/https regression testing and benchmarking utility') siege_parser.add_argument('--get', help='Pull down headers from the server and display HTTP transaction', type=str) siege_parser.add_argument('--concurrent', help='Stress the web server with NUM number of simulated users', type=int) siege_parser.add_argument('--time', help='allows you to run the test for a selected period of time', type=int) siege_parser.add_argument('--delay', help='simulated user is delayed for a random number of seconds between one and NUM', type=int) siege_parser.add_argument('--message', help='mark the log file with a separator', type=int) # ######################################################## ffmpeg_parser = subs.add_parser( 'ffmpeg', help='A complete, cross-platform solution to record, convert and stream audio and video') ffmpeg_parser.add_argument('Output', help='Pull down headers from the server and display HTTP transaction', widget='FileSaver', type=argparse.FileType) ffmpeg_parser.add_argument('--bitrate', help='set the video bitrate in kbit/s (default = 200 kb/s)', type=str) ffmpeg_parser.add_argument('--fps', help='set frame rate (default = 25)', type=str) ffmpeg_parser.add_argument('--size', help='set frame size. The format is WxH (default 160x128)', type=str) ffmpeg_parser.add_argument('--aspect', help='set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)', type=str) ffmpeg_parser.add_argument('--tolerance', help='set video bitrate tolerance (in kbit/s)', type=str) ffmpeg_parser.add_argument('--maxrate', help='set min video bitrate tolerance (in kbit/s)', type=str) ffmpeg_parser.add_argument('--bufsize', help='set ratecontrol buffere size (in kbit)', type=str) parser.parse_args() display_message()
def _parser(): """Take care of all the argparse stuff. :returns: the args """ parser = GooeyParser(description='Plot 1D fits files with wavelength information in the header.') parser.add_argument('fname', action='store', widget='FileChooser', help='Input fits file') parser.add_argument('-m', '--model', default=False, widget='FileChooser', help='If not the Sun shoul be used as a model, put' ' the model here (only support BT-Settl for the' ' moment)',) parser.add_argument('-s', '--sun', help='Over plot solar spectrum', action='store_true') parser.add_argument('-t', '--telluric', help='Over plot telluric spectrum', action='store_true') parser.add_argument('-r', '--rv', help='RV shift to observed spectra in km/s', default=False, type=float) parser.add_argument('-r1', '--rv1', help='RV shift to model/solar spectrum in km/s', default=False, type=float) parser.add_argument('-r2', '--rv2', help='RV shift to telluric spectra in km/s', default=False, type=float) parser.add_argument('-l', '--lines', help='Lines to plot on top (multiple lines is an' ' option). If multiple lines needs to be plotted, then' ' separate with a space', default=False, nargs='+', type=float) parser.add_argument('-c', '--ccf', default='none', choices=['none', 'sun', 'model', 'telluric', 'both'], help='Calculate the CCF for Sun/model or tellurics ' 'or both.') parser.add_argument('--ftype', help='Select which type the fits file is', choices=['1D', 'CRIRES', 'GIANO'], default='1D') parser.add_argument('--fitsext', help='Select fits extention, Default 0.', choices=['0', '1', '2', '3', '4'], default='0') parser.add_argument('--order', help='Select which GIANO order to be investigated', choices=map(str, range(32,81)), default='77') return parser.parse_args()
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)
def generate_trials_gui(): # General information parser = GooeyParser(description='Create_general_experiment') parser.add_argument('Number_of_blocks', default=1, action='store', type=int, help='Number') parser.add_argument('Number_of_training_trials', default=4, action='store', type=int, help='Number') parser.add_argument('Number_of_experiment_trials', default=4, action='store', type=int, help='Number') parser.add_argument('File_name', default='experiment', type=str, help='Name of file with not personalized data') parser.add_argument('--Instruction', widget='FileChooser', help='Choose instruction file') parser.add_argument('--Instruction_show_time', default=5, action='store', type=int, help='Number') # Information about training parser.add_argument('--Training_task', default='letters', choices=['letters', 'figures', 'symbols', 'numbers', 'greek_letters'], help='Choose trial type') parser.add_argument('--Training_number', default=1, action='store', type=int, help='Number of relations') parser.add_argument('--Training_stim_time', default=1, action='store', type=int, help='Number') parser.add_argument('--Training_resp_time', default=1, action='store', type=int, help='Number') parser.add_argument('--Training_feedback', default=1, action='store', type=int, help='Number') parser.add_argument('--Training_feedback_time', default=1, action='store', type=int, help='Number') parser.add_argument('--Training_wait', default=1, action='store', type=int, help='Number') parser.add_argument('--Training_bin', default='1', choices=['1', '0'], help='Choose view type') parser.add_argument('--Training_trial_type', default='1', choices=['1', '2', '3', '4'], help='Choose view type') # Information about experiment parser.add_argument('--Experiment_task', default='letters', choices=['letters', 'figures', 'symbols', 'numbers', 'greek_letters'], help='Choose trial type') parser.add_argument('--Experiment_number', default=1, action='store', type=int, help='Number of relations') parser.add_argument('--Experiment_stim_time', default=1, action='store', type=int, help='Number') parser.add_argument('--Experiment_resp_time', default=1, action='store', type=int, help='Number') parser.add_argument('--Experiment_feedback', default=1, action='store', type=int, help='Number') parser.add_argument('--Experiment_feedback_time', default=1, action='store', type=int, help='Number') parser.add_argument('--Experiment_wait', default=1, action='store', type=int, help='Number') parser.add_argument('--Experiment_bin', default='1', choices=['1', '0'], help='Choose view type') parser.add_argument('--Experiment_trial_type', default='1', choices=['1', '2', '3', '4'], help='Choose view type') args = parser.parse_args() experiment = [] name = args.Instruction.split('/')[-1] for block in range(args.Number_of_blocks): instruction = [block + 1, 'instruction', args.Instruction_show_time, name] experiment.append(instruction) for idx in range(0, args.Number_of_training_trials): trial = [block + 1, args.Training_task, args.Training_number, idx + 1, args.Training_stim_time, args.Training_resp_time, args.Training_feedback, args.Training_feedback_time, args.Training_wait, 0, int(args.Training_bin), int(args.Training_trial_type)] experiment.append(trial) for idx in range(0, args.Number_of_experiment_trials): trial = [block + 1, args.Experiment_task, args.Experiment_number, idx + 1, args.Experiment_stim_time, args.Experiment_resp_time, args.Experiment_feedback, args.Experiment_feedback_time, args.Experiment_wait, 1, int(args.Experiment_bin), int(args.Experiment_trial_type)] experiment.append(trial) save_to_xlsx(experiment, args.File_name)
def _parser(): """Take care of all the CLI/GUI stuff. """ parser = GooeyParser(description='Plot FITS spectra effortless') parser.add_argument('fname', action='store', widget='FileChooser', help='Input fits file', metavar='Fits file') parser.add_argument('-m', '--model', default=False, widget='FileChooser', help='If not the Sun shoul be used as a model, put' ' the model here (only support BT-Settl for the' ' moment)', metavar='Model atmosphere') path_lines = os.path.join(os.path.expanduser('~/.plotfits/'), 'linelist.moog') parser.add_argument('--linelist', # default=False, default=path_lines, widget='FileChooser', help='Linelist with 1 line header and wavelength in 1st col', metavar='Line list') parser.add_argument('-s', '--sun', help='Over plot solar spectrum', action='store_true') parser.add_argument('-t', '--telluric', help='Over plot telluric spectrum', action='store_true') parser.add_argument('-r', '--rv', help='RV shift to observed spectra in km/s', default=False, type=float) parser.add_argument('-r1', '--rv1', help='RV shift to model/solar spectrum in km/s', default=False, type=float) parser.add_argument('-r2', '--rv2', help='RV shift to telluric spectra in km/s', default=False, type=float) parser.add_argument('-l', '--lines', help='Lines to plot on top (multiple lines is an' ' option). If multiple lines needs to be plotted, then' ' separate with a space', default=False, type=float, nargs='+', metavar='Atomic lines') parser.add_argument('-c', '--ccf', default='none', choices=['none', 'sun', 'model', 'telluric', 'both'], help='Calculate the CCF for Sun/model or tellurics or both.') parser.add_argument('--ftype', help='Select which type the fits file is', choices=['1D', 'CRIRES', 'GIANO', 'UVES'], default='1D', metavar='Instrument') parser.add_argument('--fitsext', help='Select fits extention for CRIRES', choices=map(str, range(1, 5)), default='1', metavar='FITS extention') parser.add_argument('--order', help='Select which GIANO order to be investigated', choices=map(str, range(32, 81)), default='77', metavar='GIANO order') return parser.parse_args()
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('-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() 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 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 initOptParser(): parser = GooeyParser(description="Copy files to specified location") # Option for the path of files to move (can be a full directory). parser.add_argument('--files', metavar='file', nargs='*', help='file(s) you wish to copy', widget="MultiFileChooser") parser.add_argument('--directories', metavar='dir', nargs='*', help="The directorie(s) you wish to copy.", widget="MultiDirChooser") # Option to specify which project said files go to. parser.add_argument('-p', '--path', metavar='path',dest='path', type=str, help='Path which will be considered as root of all projects. Default is currently : ' + utils.defaultFolderPath, default=utils.defaultFolderPath, widget="DirChooser") parser.add_argument('projectName', metavar='projectName', type=str, help='The project you wish to retrieve/add files to/from.') # Option to specify the version name of the commit. parser.add_argument('-v', '--version', metavar='versionName', type=str, help='The name of the directory which will be created during an update. By default, this will be : VERSION_X.') # Option allowing overwrite of current version. parser.add_argument('-m', '--message', metavar='logMessage', type=str, help='Use to specify a log message which will be put in a versFile at the root of the project directory.') # Specify --get to retrieve files instead of commiting them. parser.add_argument('-g', '--get', dest='method', action='store_const', help='Retrieve files from project (last version by default)', const=get.get, default=push.push) # Allows 'locking'. Not really a lock. Basically a warning message to all users who try to check out if a user checked out without commiting his files. parser.add_argument('-l', '--lock', action="store_true", help='Locks the current project. '+ 'Unlocked when next push from the locking user is made') # User name. Just to allow 'locking'/'unlocking' parser.add_argument('user', metavar='userName', type=str, help='Specify your name.') parser.add_argument('-a', '--archive', metavar='archivePath', type=str, help='Use to specify a directory which will be used as an archive. Current default is : ' + utils.archivePath, widget="DirChooser") # Will pop up a windows fileselector to choose which files will be copied. parser.add_argument('-s', '--store', metavar="destPath", help='Use to specify where you want the files retrieved from the project to be copied.', widget="DirChooser") # Function to call to get all arguments. args = parser.parse_args() #print(args.files) #print(args.directories) if (args.files == None and args.directories == None): return (None) if (args.files and args.directories): args.files = args.files + args.directories#args.files[0].split(";") + args.directories[0].split(";") elif (args.directories): args.files = args.directories print("The following files/directories will be copied (along with all sub-directories) :") for myFile in args.files: print("- [" + myFile + "]") return (args)