def rsync_ibsdb_main(): import sys default_user = ut.get_user_name() # default_db = 'MUGU_Master' default_db = None # Get positional commandline arguments cmdline_varags = ut.get_cmdline_varargs() if len(cmdline_varags) > 0 and cmdline_varags[0] == 'rsync': # ignore rsync as first command (b/c we are calling from ibeis.__main__) cmdline_varags = cmdline_varags[1:] valid_modes = ['push', 'pull', 'list'] if len(cmdline_varags) < 1: print('Usage: ' # 'python -m ibeis.scripts.rsync_ibeisdb' 'python -m ibeis rsync' '%s --db <db=%s> --user <user=%s>' % (valid_modes, default_db, default_user,)) sys.exit(1) varargs_dict = dict(enumerate(cmdline_varags)) mode = varargs_dict.get(0, None) default_db = varargs_dict.get(1, None) user = ut.get_argval('--user', type_=str, default=default_user) port = ut.get_argval('--port', type_=int, default=22) dbname = ut.get_argval(('--db', '--dbname'), type_=str, default=default_db) workdir = ut.get_argval(('--workdir', '--dbname'), type_=str, default=None, help_='local work dir override') dry_run = ut.get_argflag(('--dryrun', '--dry-run', '--dry')) assert mode in valid_modes, 'mode=%r must be in %r' % (mode, valid_modes) remote_key = ut.get_argval('--remote', type_=str, default='hyrule') remote_map = { 'hyrule': 'hyrule.cs.rpi.edu', 'pachy': 'pachy.cs.uic.edu', 'lewa': '41.203.223.178', 'lev': 'lev.cs.rpi.edu', } remote_workdir_map = { 'hyrule': '/raid/work', 'pachy': '/home/shared_ibeis/data/work', 'lewa': '/data/ibeis', 'lev': '/media/hdd/work', } if ':' in remote_key: remote_key_, remote_workdir = remote_key.split(':') else: remote_key_ = remote_key remote_workdir = remote_workdir_map.get(remote_key, '') remote = remote_map.get(remote_key_, remote_key_) remote_uri = user + '@' + remote + ':' + remote_workdir if mode == 'list': print('remote = %r' % (remote,)) print('need to list') remote_paths = ut.list_remote(remote_uri) print('REMOTE LS -- TODO need to get only ibeis dirs') print('\n'.join(remote_paths)) elif mode in ['push', 'pull']: ut.change_term_title('RSYNC IBEISDB %r' % (dbname,)) sync_ibeisdb(remote_uri, dbname, mode, workdir, port, dry_run)
def run_ibeis(): r""" CommandLine: python -m ibeis python -m ibeis find_installed_tomcat python -m ibeis get_annot_groundtruth:1 """ #ut.set_process_title('IBEIS_main') #main_locals = ibeis.main() #ibeis.main_loop(main_locals) #ut.set_process_title('IBEIS_main') cmdline_varags = ut.get_cmdline_varargs() if len(cmdline_varags) > 0 and cmdline_varags[0] == 'rsync': from ibeis.scripts import rsync_ibeisdb rsync_ibeisdb.rsync_ibsdb_main() sys.exit(0) if ut.get_argflag('--devcmd'): # Hack to let devs mess around when using an installer version # TODO: add more hacks #import utool.tests.run_tests #utool.tests.run_tests.run_tests() ut.embed() # Run the tests of other modules elif ut.get_argflag('--run-utool-tests'): import utool.tests.run_tests retcode = utool.tests.run_tests.run_tests() print('... exiting') sys.exit(retcode) elif ut.get_argflag('--run-vtool-tests'): import vtool.tests.run_tests retcode = vtool.tests.run_tests.run_tests() print('... exiting') sys.exit(retcode) elif ut.get_argflag(('--run-ibeis-tests', '--run-tests')): from ibeis.tests import run_tests retcode = run_tests.run_tests() print('... exiting') sys.exit(retcode) if ut.get_argflag('-e'): """ ibeis -e print -a default -t default """ # Run dev script if -e given import ibeis.dev # NOQA ibeis.dev.devmain() print('... exiting') sys.exit(0) # Attempt to run a test using the funciton name alone # with the --tf flag import ibeis.tests.run_tests import ibeis.tests.reset_testdbs ignore_prefix = [ #'ibeis.tests', 'ibeis.control.__SQLITE3__', '_autogen_explicit_controller'] ignore_suffix = ['_grave'] func_to_module_dict = { 'demo_bayesnet': 'ibeis.algo.hots.demobayes', } ut.main_function_tester('ibeis', ignore_prefix, ignore_suffix, func_to_module_dict=func_to_module_dict) #if ut.get_argflag('-e'): # import ibeis # expt_kw = ut.get_arg_dict(ut.get_func_kwargs(ibeis.run_experiment), # prefix_list=['--', '-']) # ibeis.run_experiment(**expt_kw) # sys.exit(0) doctest_modname = ut.get_argval( ('--doctest-module', '--tmod', '-tm', '--testmod'), type_=str, default=None, help_='specify a module to doctest') if doctest_modname is not None: """ Allow any doctest to be run the main ibeis script python -m ibeis --tmod utool.util_str --test-align:0 python -m ibeis --tmod ibeis.algo.hots.pipeline --test-request_ibeis_query_L0:0 --show python -m ibeis --tf request_ibeis_query_L0:0 --show ./dist/ibeis/IBEISApp --tmod ibeis.algo.hots.pipeline --test-request_ibeis_query_L0:0 --show # NOQA ./dist/ibeis/IBEISApp --tmod utool.util_str --test-align:0 ./dist/IBEIS.app/Contents/MacOS/IBEISApp --tmod utool.util_str --test-align:0 ./dist/IBEIS.app/Contents/MacOS/IBEISApp --run-utool-tests ./dist/IBEIS.app/Contents/MacOS/IBEISApp --run-vtool-tests """ print('[ibeis] Testing module') mod_alias_list = { 'exptdraw': 'ibeis.expt.experiment_drawing' } doctest_modname = mod_alias_list.get(doctest_modname, doctest_modname) module = ut.import_modname(doctest_modname) (nPass, nTotal, failed_list, error_report_list) = ut.doctest_funcs(module=module) retcode = 1 - (len(failed_list) == 0) #print(module) sys.exit(retcode) import ibeis main_locals = ibeis.main() execstr = ibeis.main_loop(main_locals) # <DEBUG CODE> if 'back' in main_locals and CMD: #from ibeis.all_imports import * # NOQA back = main_locals['back'] front = getattr(back, 'front', None) # NOQA #front = back.front #ui = front.ui ibs = main_locals['ibs'] # NOQA exec(execstr)
def run_ibeis(): r""" CommandLine: python -m ibeis python -m ibeis find_installed_tomcat python -m ibeis get_annot_groundtruth:1 """ import ibeis # NOQA #ut.set_process_title('IBEIS_main') #main_locals = ibeis.main() #ibeis.main_loop(main_locals) #ut.set_process_title('IBEIS_main') cmdline_varags = ut.get_cmdline_varargs() if len(cmdline_varags) > 0 and cmdline_varags[0] == 'rsync': from ibeis.scripts import rsync_ibeisdb rsync_ibeisdb.rsync_ibsdb_main() sys.exit(0) if ub.argflag('--devcmd'): # Hack to let devs mess around when using an installer version # TODO: add more hacks #import utool.tests.run_tests #utool.tests.run_tests.run_tests() ut.embed() # Run the tests of other modules elif ub.argflag('--run-utool-tests'): raise Exception('Deprecated functionality') elif ub.argflag('--run-vtool_ibeis-tests'): raise Exception('Deprecated functionality') elif ub.argflag(('--run-ibeis-tests', '--run-tests')): raise Exception('Deprecated functionality') if ub.argflag('-e'): """ ibeis -e print -a default -t default """ # Run dev script if -e given import ibeis.dev # NOQA ibeis.dev.devmain() print('... exiting') sys.exit(0) # Attempt to run a test using the funciton name alone # with the --tf flag # if False: # import ibeis.tests.run_tests # import ibeis.tests.reset_testdbs # import ibeis.scripts.thesis # ignore_prefix = [ # #'ibeis.tests', # 'ibeis.control.__SQLITE3__', # '_autogen_explicit_controller'] # ignore_suffix = ['_grave'] # func_to_module_dict = { # 'demo_bayesnet': 'ibeis.unstable.demobayes', # } # ut.main_function_tester('ibeis', ignore_prefix, ignore_suffix, # func_to_module_dict=func_to_module_dict) #if ub.argflag('-e'): # import ibeis # expt_kw = ut.get_arg_dict(ut.get_func_kwargs(ibeis.run_experiment), # prefix_list=['--', '-']) # ibeis.run_experiment(**expt_kw) # sys.exit(0) doctest_modname = ut.get_argval( ('--doctest-module', '--tmod', '-tm', '--testmod'), type_=str, default=None, help_='specify a module to doctest') if doctest_modname is not None: """ Allow any doctest to be run the main ibeis script python -m ibeis --tmod utool.util_str --test-align:0 python -m ibeis --tmod ibeis.algo.hots.pipeline --test-request_ibeis_query_L0:0 --show python -m ibeis --tf request_ibeis_query_L0:0 --show ./dist/ibeis/IBEISApp --tmod ibeis.algo.hots.pipeline --test-request_ibeis_query_L0:0 --show # NOQA ./dist/ibeis/IBEISApp --tmod utool.util_str --test-align:0 ./dist/IBEIS.app/Contents/MacOS/IBEISApp --tmod utool.util_str --test-align:0 ./dist/IBEIS.app/Contents/MacOS/IBEISApp --run-utool-tests ./dist/IBEIS.app/Contents/MacOS/IBEISApp --run-vtool_ibeis-tests """ print('[ibeis] Testing module') mod_alias_list = { 'exptdraw': 'ibeis.expt.experiment_drawing' } doctest_modname = mod_alias_list.get(doctest_modname, doctest_modname) module = ut.import_modname(doctest_modname) (nPass, nTotal, failed_list, error_report_list) = ut.doctest_funcs(module=module) retcode = 1 - (len(failed_list) == 0) #print(module) sys.exit(retcode) import ibeis main_locals = ibeis.main() execstr = ibeis.main_loop(main_locals) # <DEBUG CODE> if 'back' in main_locals and CMD: back = main_locals['back'] front = getattr(back, 'front', None) # NOQA #front = back.front #ui = front.ui ibs = main_locals['ibs'] # NOQA print('-- EXECSTR --') print(ub.codeblock(execstr)) print('-- /EXECSTR --') exec(execstr)
def rsync_ibsdb_main(): import sys default_user = ut.get_user_name() # default_db = 'MUGU_Master' default_db = None # Get positional commandline arguments cmdline_varags = ut.get_cmdline_varargs() if len(cmdline_varags) > 0 and cmdline_varags[0] == 'rsync': # ignore rsync as first command (b/c we are calling from # ibeis.__main__) cmdline_varags = cmdline_varags[1:] valid_modes = ['push', 'pull', 'list'] if len(cmdline_varags) < 1: print('Usage: ' # 'python -m ibeis.scripts.rsync_ibeisdb' 'python -m ibeis rsync' '%s --db <db=%s> --user <user=%s>' % (valid_modes, default_db, default_user,)) sys.exit(1) varargs_dict = dict(enumerate(cmdline_varags)) mode = varargs_dict.get(0, None) default_db = varargs_dict.get(1, None) user = ut.get_argval('--user', type_=str, default=default_user) port = ut.get_argval('--port', type_=int, default=22) dbnames = ut.get_argval(('--db', '--dbs', '--dbname'), type_=str, default=default_db) dbnames = ut.smart_cast(dbnames, list) workdir = ut.get_argval(('--workdir'), type_=str, default=None, help_='local work dir override') dry_run = ut.get_argflag(('--dryrun', '--dry-run', '--dry')) assert mode in valid_modes, 'mode=%r must be in %r' % ( mode, valid_modes) remote_key = ut.get_argval('--remote', type_=str, default='hyrule') remote_map = { 'hyrule': 'hyrule.cs.rpi.edu', 'pachy': 'pachy.cs.uic.edu', 'lewa': '41.203.223.178', 'lev': 'cthulhu.dyn.wildme.io', } remote_workdir_map = { 'hyrule': '/raid/work', 'pachy': '/home/shared_ibeis/data/work', 'lewa': '/data/ibeis', 'lev': '/media/hdd/work', } if ':' in remote_key: remote_key_, remote_workdir = remote_key.split(':') else: remote_key_ = remote_key if remote_key not in remote_workdir_map: import warnings warnings.warn('Workdir not specified for remote') remote_workdir = remote_workdir_map.get(remote_key, '') remote = remote_map.get(remote_key_, remote_key_) remote_uri = user + '@' + remote + ':' + remote_workdir if mode == 'list': print('remote = %r' % (remote,)) print('need to list') remote_paths = ut.list_remote(remote_uri) print('REMOTE LS -- TODO need to get only ibeis dirs') print('\n'.join(remote_paths)) elif mode in ['push', 'pull']: print('dbnames = {!r}'.format(dbnames)) for dbname in ut.ProgIter(dbnames, label='sync db'): ut.change_term_title('RSYNC IBEISDB %r' % (dbname,)) sync_ibeisdb(remote_uri, dbname, mode, workdir, port, dry_run)
from PyQt5 import QtCore infodict = module_stdinfo_dict(QtCore, 'PYQT_VERSION_STR') else: # Handle normal modules module = ut.import_modname(modname) infodict = module_stdinfo_dict(module) if any([infodict['__file__'].endswith(ext) for ext in ut.LIB_EXT_LIST]): infodict['libdep'] = ut.get_dynlib_dependencies(infodict['__file__']) return print(ut.repr4(infodict, strvals=True)) if __name__ == '__main__': r""" CommandLine: export PYTHONPATH=$PYTHONPATH:/home/joncrall/code/utool/utool/util_scripts python ~/code/utool/utool/util_scripts/pipinfo.py python ~/code/utool/utool/util_scripts/pipinfo.py --allexamples pipinfo.py networkx pipinfo.py sklearn pipinfo.py cv2 pipinfo.py PyQt4 """ modname = ut.get_argval('--modname') if not modname: args = ut.get_cmdline_varargs() if len(args) > 0: modname = args[0] assert modname print_module_info(modname)