def execute_commands(tpl_rman, ibeis_rman):
    import utool as ut
    GET_ARGVAL = ut.get_argval
    ut.init_catch_ctrl_c()
    if 0:
        print('Version Check Source:')
        for repo in tpl_rman.repos:
            print('python -c "import {0}; print({0}.__file__)"'.format(repo.modname))
            print('python -c "import {0}; print({0}.__version__)"'.format(repo.modname))
    (CODE_DIR, pythoncmd, WIN32, PY2, PY3) = get_sysinfo()
    print(('ibeis_rman = %r' % (ibeis_rman,)))
    wildme_ssh_flags = (GET_ARGFLAG('--move-wildme') or GET_ARGFLAG('--move-wildme-ssh'))
    wildme_https_flags = (GET_ARGFLAG('--move-wildme-https') or GET_ARGFLAG('--move-wildme-http'))
    if (wildme_ssh_flags or wildme_https_flags):
        fmt = ('ssh' if wildme_ssh_flags else 'https')
        move_wildme(ibeis_rman, fmt)
    if GET_ARGFLAG('--status'):
        ibeis_rman.issue('git status')
        sys.exit(0)
    ibeis_rman.ensure()
    if (GET_ARGFLAG('--dump') or GET_ARGFLAG('--dump-scripts')):
        dpath = (('_super_scripts/' + 'scripts') + get_plat_specifier())
        ut.ensuredir(dpath)
        dumps = [(tpl_rman, 'cv2', 'build'), (tpl_rman, 'cv2', 'install'), (ibeis_rman, 'flann', 'build'), (ibeis_rman, 'flann', 'install'), (ibeis_rman, 'hesaff', 'build'), (tpl_rman, 'PyQt', 'system_to_venv'), (tpl_rman, 'libgpuarray', 'build')]
        for (rman, mod, sname) in dumps:
            from os.path import join
            script = rman[mod].get_script(sname).text
            suffix = get_plat_specifier()
            sh_fpath = join(dpath, ((((mod + '_') + sname) + suffix) + '.sh'))
            ut.write_to(sh_fpath, script)
    if GET_ARGFLAG('--requirements'):
        ut.cmd('pip install -r requirements.txt')
    if GET_ARGFLAG('--opencv'):
        cv_repo = tpl_rman['cv2']
        cv_repo.clone()
        script = cv_repo.get_script('build')
        script.exec_()
        cv_repo = tpl_rman['cv2']
        script = cv_repo.get_script('install')
        script.exec_()
    if GET_ARGFLAG('--flann'):
        script = ibeis_rman['flann'].get_script('build')
        script.exec_()
        script = ibeis_rman['flann'].get_script('install')
        script.exec_()
    if GET_ARGFLAG('--pyqt'):
        script = tpl_rman['PyQt'].get_script('system_to_venv')
        script.exec_()
    if GET_ARGFLAG('--hesaff'):
        script = ibeis_rman['hesaff'].get_script('build')
        script.exec_()
    if GET_ARGFLAG('--pydarknet'):
        script = ibeis_rman['pydarknet'].get_script('build')
        script.exec_()
    if GET_ARGFLAG('--pyrf'):
        script = ibeis_rman['pyrf'].get_script('build')
        script.exec_()
    if GET_ARGFLAG('--torch'):
        tpl_rman['pytorch'].clone(recursive=True)
        tpl_rman['pytorch'].issue('git submodule update --init')
        tpl_rman['pytorch'].issue('python setup install')
        tpl_rman['pytorch'].issue('pip install torchvision')
    if (GET_ARGFLAG('--libgpuarray') or GET_ARGFLAG('--dcnn')):
        tpl_rman['libgpuarray'].clone()
        script = tpl_rman['libgpuarray'].get_script('build')
        script.exec_()
    if GET_ARGFLAG('--dcnn'):
        tpl_rman['theano'].clone()
        tpl_rman['lasagne'].clone()
        tpl_rman['theano'].issue('pip install -e .')
        tpl_rman['lasagne'].issue('pip install -e .')
    if (GET_ARGFLAG('--fix') or GET_ARGFLAG('--check')):
        missing_dynlib = tpl_rman.check_cpp_build()
        missing_dynlib += ibeis_rman.check_cpp_build()
        missing_install = tpl_rman.check_installed()
        missing_install += ibeis_rman.check_installed()
        problems = []
        problems += ibeis_rman.check_importable()
        problems += tpl_rman.check_importable()
    if GET_ARGFLAG('--fix'):
        print('Trying to fix problems')
        for repo in missing_dynlib:
            repo.custom_build()
        for (repo, recommended_fix) in problems:
            print(('Trying to fix repo = %r' % (repo,)))
            print((' * recommended_fix = %r' % (recommended_fix,)))
            if (recommended_fix == 'rebuild'):
                repo.custom_build()
                print('Can currently only fix one module at a time. Please re-run')
                sys.exit(1)
            else:
                print(('Not sure how to fix %r' % (repo,)))
    if GET_ARGFLAG('--pull'):
        ibeis_rman.issue('git pull')
    if GET_ARGFLAG('--build'):
        _rman = ibeis_rman.only_with_pysetup()
        _rman.issue('{pythoncmd} setup.py build'.format(pythoncmd=pythoncmd))
    if GET_ARGFLAG('--develop'):
        _rman = ibeis_rman.only_with_pysetup()
        _rman.issue('{pythoncmd} -m pip install -e .'.format(pythoncmd=pythoncmd), sudo=(not ut.in_virtual_env()))
    if GET_ARGFLAG('--clean'):
        _rman = ibeis_rman.only_with_pysetup()
        _rman.issue('{pythoncmd} setup.py clean'.format(pythoncmd=pythoncmd))
    if GET_ARGFLAG('--install'):
        print('WARNING: Dont use install if you are a developer. Use develop instead.')
        _rman = ibeis_rman.only_with_pysetup()
        _rman.issue('python setup.py install'.format(pythoncmd=pythoncmd))
    if GET_ARGFLAG('--push'):
        ibeis_rman.issue('git push')
    if GET_ARGFLAG('--branch'):
        ibeis_rman.issue('git branch')
        sys.exit(0)
    if GET_ARGFLAG('--tag-status'):
        ibeis_rman.issue('git tag')
    tag_name = GET_ARGVAL('--newtag', type_=str, default=None)
    if (tag_name is not None):
        ibeis_rman.issue('git tag -a "{tag_name}" -m "super_setup autotag {tag_name}"'.format(**locals()))
        ibeis_rman.issue('git push --tags')
    if GET_ARGFLAG('--bext'):
        ibeis_rman.issue('{pythoncmd} setup.py build_ext --inplace'.format(pythoncmd=pythoncmd))
    commit_msg = GET_ARGVAL('--commit', type_=str, default=None)
    if (commit_msg is not None):
        ibeis_rman.issue('git commit -am "{commit_msg}"'.format(**locals()))
    branch_name = GET_ARGVAL('--checkout', type_=str, default=None)
    if (branch_name is not None):
        try:
            ibeis_rman.issue('git checkout "{branch_name}"'.format(**locals()))
        except Exception:
            print(('ERROR: Could not checkout branch: %r' % (branch_name,)))
    newbranch_name = GET_ARGVAL('--newbranch', type_=str, default=None)
    if (newbranch_name is not None):
        ibeis_rman.issue('git checkout -b "{newbranch_name}"'.format(**locals()))
        ibeis_rman.issue('git push --set-upstream origin {newbranch_name}'.format(**locals()))
    newlocalbranch_name = GET_ARGVAL('--newlocalbranch', type_=str, default=None)
    if (newlocalbranch_name is not None):
        ibeis_rman.issue('git checkout -b "{newlocalbranch_name}"'.format(**locals()))
    mergebranch_name = GET_ARGVAL('--merge', type_=str, default=None)
    if (mergebranch_name is not None):
        ibeis_rman.issue('git merge "{mergebranch_name}"'.format(**locals()))
    if GET_ARGFLAG('--serverchmod'):
        ibeis_rman.issue('chmod -R 755 *')
    if GET_ARGFLAG('--chown'):
        username = os.environ.get('USERNAME', ut.get_argval('--username'))
        if (username is None):
            username = os.environ.get('USER', None)
        if (username is None):
            raise AssertionError('cannot find username in commandline or environment vars')
        usergroup = username
        ibeis_rman.issue('chown -R {username}:{usergroup} *'.format(**locals()), sudo=True)
    upstream_branch = GET_ARGVAL('--set-upstream', type_=str, default=None)
    if (upstream_branch is not None):
        ibeis_rman.issue('git branch --set-upstream-to=origin/{upstream_branch} {upstream_branch}'.format(**locals()))
    upstream_push = GET_ARGVAL('--upstream-push', type_=str, default=None)
    if (upstream_push is not None):
        ibeis_rman.issue('git push --set-upstream origin {upstream_push}'.format(**locals()))
    if GET_ARGFLAG('--test'):
        failures = []
        for repo_dpath in ibeis_rman.repo_dirs:
            mod_dpaths = ut.get_submodules_from_dpath(repo_dpath, recursive=False, only_packages=True)
            modname_list = ut.lmap(ut.get_modname_from_modpath, mod_dpaths)
            print(('Checking modules = %r' % (modname_list,)))
            for modname in modname_list:
                try:
                    ut.import_modname(modname)
                    print((modname + ' success'))
                except ImportError as ex:
                    failures += [modname]
                    print((modname + ' failure'))
        print(('failures = %s' % (ut.repr3(failures),)))
    if False:
        try:
            from six.moves import input
        except ImportError:
            input = raw_input
        gg_cmd = GET_ARGVAL('--gg', None)
        if (gg_cmd is not None):
            ans = ('yes' if GET_ARGFLAG('-y') else input(('Are you sure you want to run: %r on all directories? ' % (gg_cmd,))))
            if (ans == 'yes'):
                ibeis_rman.issue(gg_cmd)
def execute_commands(tpl_rman, ibeis_rman):
    import utool as ut
    GET_ARGVAL = ut.get_argval
    ut.init_catch_ctrl_c()
    if 0:
        print('Version Check Source:')
        for repo in tpl_rman.repos:
            print('python -c "import {0}; print({0}.__file__)"'.format(repo.modname))
            print('python -c "import {0}; print({0}.__version__)"'.format(repo.modname))
    (CODE_DIR, pythoncmd, WIN32, PY2, PY3) = get_sysinfo()
    print(('ibeis_rman = %r' % (ibeis_rman,)))
    wildme_ssh_flags = (GET_ARGFLAG('--move-wildme') or GET_ARGFLAG('--move-wildme-ssh'))
    wildme_https_flags = (GET_ARGFLAG('--move-wildme-https') or GET_ARGFLAG('--move-wildme-http'))
    if (wildme_ssh_flags or wildme_https_flags):
        fmt = ('ssh' if wildme_ssh_flags else 'https')
        move_wildme(ibeis_rman, fmt)
    if GET_ARGFLAG('--status'):
        ibeis_rman.issue('git status')
        sys.exit(0)
    ibeis_rman.ensure()
    if (GET_ARGFLAG('--dump') or GET_ARGFLAG('--dump-scripts')):
        dpath = (('_super_scripts/' + 'scripts') + get_plat_specifier())
        ut.ensuredir(dpath)
        dumps = [(tpl_rman, 'cv2', 'build'), (tpl_rman, 'cv2', 'install'), (ibeis_rman, 'flann', 'build'), (ibeis_rman, 'flann', 'install'), (ibeis_rman, 'hesaff', 'build'), (tpl_rman, 'PyQt', 'system_to_venv'), (tpl_rman, 'libgpuarray', 'build')]
        for (rman, mod, sname) in dumps:
            from os.path import join
            script = rman[mod].get_script(sname).text
            suffix = get_plat_specifier()
            sh_fpath = join(dpath, ((((mod + '_') + sname) + suffix) + '.sh'))
            ut.write_to(sh_fpath, script)
    if GET_ARGFLAG('--requirements'):
        ut.cmd('pip install -r requirements.txt')
    if GET_ARGFLAG('--opencv'):
        cv_repo = tpl_rman['cv2']
        cv_repo.clone()
        script = cv_repo.get_script('build')
        script.exec_()
        cv_repo = tpl_rman['cv2']
        script = cv_repo.get_script('install')
        script.exec_()
    if GET_ARGFLAG('--flann'):
        script = ibeis_rman['flann'].get_script('build')
        script.exec_()
        script = ibeis_rman['flann'].get_script('install')
        script.exec_()
    if GET_ARGFLAG('--pyqt'):
        script = tpl_rman['PyQt'].get_script('system_to_venv')
        script.exec_()
    if GET_ARGFLAG('--hesaff'):
        script = ibeis_rman['hesaff'].get_script('build')
        script.exec_()
    if GET_ARGFLAG('--pydarknet'):
        script = ibeis_rman['pydarknet'].get_script('build')
        script.exec_()
    if GET_ARGFLAG('--pyrf'):
        script = ibeis_rman['pyrf'].get_script('build')
        script.exec_()
    if GET_ARGFLAG('--torch'):
        tpl_rman['pytorch'].clone(recursive=True)
        tpl_rman['pytorch'].issue('git submodule update --init')
        tpl_rman['pytorch'].issue('python setup install')
        tpl_rman['pytorch'].issue('pip install torchvision')
    if (GET_ARGFLAG('--libgpuarray') or GET_ARGFLAG('--dcnn')):
        tpl_rman['libgpuarray'].clone()
        script = tpl_rman['libgpuarray'].get_script('build')
        script.exec_()
    if GET_ARGFLAG('--dcnn'):
        tpl_rman['theano'].clone()
        tpl_rman['lasagne'].clone()
        tpl_rman['theano'].issue('pip install -e .')
        tpl_rman['lasagne'].issue('pip install -e .')
    if (GET_ARGFLAG('--fix') or GET_ARGFLAG('--check')):
        missing_dynlib = tpl_rman.check_cpp_build()
        missing_dynlib += ibeis_rman.check_cpp_build()
        missing_install = tpl_rman.check_installed()
        missing_install += ibeis_rman.check_installed()
        problems = []
        problems += ibeis_rman.check_importable()
        problems += tpl_rman.check_importable()
    if GET_ARGFLAG('--fix'):
        print('Trying to fix problems')
        for repo in missing_dynlib:
            repo.custom_build()
        for (repo, recommended_fix) in problems:
            print(('Trying to fix repo = %r' % (repo,)))
            print((' * recommended_fix = %r' % (recommended_fix,)))
            if (recommended_fix == 'rebuild'):
                repo.custom_build()
                print('Can currently only fix one module at a time. Please re-run')
                sys.exit(1)
            else:
                print(('Not sure how to fix %r' % (repo,)))
    if GET_ARGFLAG('--pull'):
        ibeis_rman.issue('git pull')
    if GET_ARGFLAG('--build'):
        _rman = ibeis_rman.only_with_pysetup()
        _rman.issue('{pythoncmd} setup.py build'.format(pythoncmd=pythoncmd))
    if GET_ARGFLAG('--develop'):
        _rman = ibeis_rman.only_with_pysetup()
        _rman.issue('{pythoncmd} -m pip install -e .'.format(pythoncmd=pythoncmd), sudo=(not ut.in_virtual_env()))
    if GET_ARGFLAG('--clean'):
        _rman = ibeis_rman.only_with_pysetup()
        _rman.issue('{pythoncmd} setup.py clean'.format(pythoncmd=pythoncmd))
    if GET_ARGFLAG('--install'):
        print('WARNING: Dont use install if you are a developer. Use develop instead.')
        _rman = ibeis_rman.only_with_pysetup()
        _rman.issue('python setup.py install'.format(pythoncmd=pythoncmd))
    if GET_ARGFLAG('--push'):
        ibeis_rman.issue('git push')
    if GET_ARGFLAG('--branch'):
        ibeis_rman.issue('git branch')
        sys.exit(0)
    if GET_ARGFLAG('--tag-status'):
        ibeis_rman.issue('git tag')
    tag_name = GET_ARGVAL('--newtag', type_=str, default=None)
    if (tag_name is not None):
        ibeis_rman.issue('git tag -a "{tag_name}" -m "super_setup autotag {tag_name}"'.format(**locals()))
        ibeis_rman.issue('git push --tags')
    if GET_ARGFLAG('--bext'):
        ibeis_rman.issue('{pythoncmd} setup.py build_ext --inplace'.format(pythoncmd=pythoncmd))
    commit_msg = GET_ARGVAL('--commit', type_=str, default=None)
    if (commit_msg is not None):
        ibeis_rman.issue('git commit -am "{commit_msg}"'.format(**locals()))
    branch_name = GET_ARGVAL('--checkout', type_=str, default=None)
    if (branch_name is not None):
        try:
            ibeis_rman.issue('git checkout "{branch_name}"'.format(**locals()))
        except Exception:
            print(('ERROR: Could not checkout branch: %r' % (branch_name,)))
    newbranch_name = GET_ARGVAL('--newbranch', type_=str, default=None)
    if (newbranch_name is not None):
        ibeis_rman.issue('git checkout -b "{newbranch_name}"'.format(**locals()))
        ibeis_rman.issue('git push --set-upstream origin {newbranch_name}'.format(**locals()))
    newlocalbranch_name = GET_ARGVAL('--newlocalbranch', type_=str, default=None)
    if (newlocalbranch_name is not None):
        ibeis_rman.issue('git checkout -b "{newlocalbranch_name}"'.format(**locals()))
    mergebranch_name = GET_ARGVAL('--merge', type_=str, default=None)
    if (mergebranch_name is not None):
        ibeis_rman.issue('git merge "{mergebranch_name}"'.format(**locals()))
    if GET_ARGFLAG('--serverchmod'):
        ibeis_rman.issue('chmod -R 755 *')
    if GET_ARGFLAG('--chown'):
        username = os.environ.get('USERNAME', ut.get_argval('--username'))
        if (username is None):
            username = os.environ.get('USER', None)
        if (username is None):
            raise AssertionError('cannot find username in commandline or environment vars')
        usergroup = username
        ibeis_rman.issue('chown -R {username}:{usergroup} *'.format(**locals()), sudo=True)
    upstream_branch = GET_ARGVAL('--set-upstream', type_=str, default=None)
    if (upstream_branch is not None):
        ibeis_rman.issue('git branch --set-upstream-to=origin/{upstream_branch} {upstream_branch}'.format(**locals()))
    upstream_push = GET_ARGVAL('--upstream-push', type_=str, default=None)
    if (upstream_push is not None):
        ibeis_rman.issue('git push --set-upstream origin {upstream_push}'.format(**locals()))
    if GET_ARGFLAG('--test'):
        failures = []
        for repo_dpath in ibeis_rman.repo_dirs:
            mod_dpaths = ut.get_submodules_from_dpath(repo_dpath, recursive=False, only_packages=True)
            modname_list = ut.lmap(ut.get_modname_from_modpath, mod_dpaths)
            print(('Checking modules = %r' % (modname_list,)))
            for modname in modname_list:
                try:
                    ut.import_modname(modname)
                    print((modname + ' success'))
                except ImportError as ex:
                    failures += [modname]
                    print((modname + ' failure'))
        print(('failures = %s' % (ut.repr3(failures),)))
    if False:
        try:
            from six.moves import input
        except ImportError:
            input = raw_input
        gg_cmd = GET_ARGVAL('--gg', None)
        if (gg_cmd is not None):
            ans = ('yes' if GET_ARGFLAG('-y') else input(('Are you sure you want to run: %r on all directories? ' % (gg_cmd,))))
            if (ans == 'yes'):
                ibeis_rman.issue(gg_cmd)