Ejemplo n.º 1
0
def package_installer():
    """
    system dependent post pyinstaller step
    """
    print('[installer] +--- PACKAGE_INSTALLER ---')
    #build_win32_inno_installer()
    cwd = get_setup_dpath()
    # Build the os-appropriate package
    if sys.platform.startswith('win32'):
        installer_src = build_win32_inno_installer()
        installer_fname_fmt = 'ibeis-win32-install-{timestamp}.exe'
    elif sys.platform.startswith('darwin'):
        installer_src = build_osx_dmg_installer()
        installer_fname_fmt = 'ibeis-osx-install-{timestamp}.dmg'
    elif sys.platform.startswith('linux'):
        installer_src = build_linux_zip_binaries()
        installer_fname_fmt = 'ibeis-linux-binary-{timestamp}.zip'
        #try:
        #    raise NotImplementedError('no linux packager (rpm or deb) supported. try running with --build')
        #except Exception as ex:
        #    ut.printex(ex)
        #pass
    # timestamp the installer name
    installer_fname = installer_fname_fmt.format(timestamp=ut.get_timestamp())
    installer_dst = join(cwd, 'dist', installer_fname)
    try:
        ut.move(installer_src, installer_dst)
    except Exception as ex:
        ut.printex(ex, 'error moving setups', iswarning=True)
    print('[installer] L___ FINISH PACKAGE_INSTALLER ___')
Ejemplo n.º 2
0
def download_tomcat():
    """
    Put tomcat into a directory controlled by ibeis

    CommandLine:
        # Reset
        python -c "import utool as ut; ut.delete(ut.unixjoin(ut.get_app_resource_dir('ibeis'), 'tomcat'))"
    """
    print('Grabbing tomcat')
    # FIXME: need to make a stable link
    if ut.WIN32:
        tomcat_binary_url = 'http://mirrors.advancedhosters.com/apache/tomcat/tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36-windows-x86.zip'
    else:
        tomcat_binary_url = 'http://mirrors.advancedhosters.com/apache/tomcat/tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.zip'
    zip_fpath = ut.grab_file_url(tomcat_binary_url, appname='ibeis')
    # Download tomcat into the IBEIS resource directory
    tomcat_dpath = join(dirname(zip_fpath), 'tomcat')
    if not ut.checkpath(tomcat_dpath, verbose=True):
        # hack because unzipping is still weird
        ut.unzip_file(zip_fpath)
        tomcat_dpath_tmp = splitext(zip_fpath)[0]
        ut.move(tomcat_dpath_tmp, tomcat_dpath)
    if ut.checkpath(join(tomcat_dpath, 'bin'), verbose=True):
        scriptnames = ['catalina.sh', 'startup.sh', 'shutdown.sh']
        for fname in scriptnames:
            fpath = join(tomcat_dpath, 'bin', fname)
            if not ut.is_file_executable(fpath):
                print('Adding executable bits to script %r' % (fpath, ))
                ut.chmod_add_executable(fpath)
    return tomcat_dpath
Ejemplo n.º 3
0
def package_installer():
    """
    system dependent post pyinstaller step
    """
    print('[installer] +--- PACKAGE_INSTALLER ---')
    #build_win32_inno_installer()
    cwd = get_setup_dpath()
    # Build the os-appropriate package
    if sys.platform.startswith('win32'):
        installer_src = build_win32_inno_installer()
        installer_fname_fmt = 'ibeis-win32-install-{timestamp}.exe'
    elif sys.platform.startswith('darwin'):
        installer_src = build_osx_dmg_installer()
        installer_fname_fmt = 'ibeis-osx-install-{timestamp}.dmg'
    elif sys.platform.startswith('linux'):
        installer_src = build_linux_zip_binaries()
        installer_fname_fmt = 'ibeis-linux-binary-{timestamp}.zip'
        #try:
        #    raise NotImplementedError('no linux packager (rpm or deb) supported. try running with --build')
        #except Exception as ex:
        #    ut.printex(ex)
        #pass
    # timestamp the installer name
    installer_fname = installer_fname_fmt.format(timestamp=ut.get_timestamp())
    installer_dst = join(cwd, 'dist', installer_fname)
    try:
        ut.move(installer_src, installer_dst)
    except Exception as ex:
        ut.printex(ex, 'error moving setups', iswarning=True)
    print('[installer] L___ FINISH PACKAGE_INSTALLER ___')
Ejemplo n.º 4
0
def revert_to_backup(ibs):
    r"""
    Args:
        db_dir (?):

    CommandLine:
        python -m ibeis.control._sql_helpers --exec-revert_to_backup

    Example:
        >>> # SCRIPT
        >>> from ibeis.control._sql_helpers import *  # NOQA
        >>> import ibeis
        >>> ibs = ibeis.opendb(defaultdb='GZ_Master1')
        >>> result = revert_to_backup(ibs)
        >>> print(result)
    """
    db_path = ibs.get_db_core_path()
    ibs.disconnect_sqldatabase()
    backup_dir = ibs.backupdir

    ut.move(db_path, ut.get_nonconflicting_path(db_path + 'revertfrom.%d.orig'))
    # Carefull may invalidate the cache
    fname, ext = splitext(db_path)
    path_list = sorted(ut.glob(backup_dir, '*%s' % ext))
    previous_backup = path_list[-1]
    ut.copy(previous_backup, db_path)
Ejemplo n.º 5
0
def download_tomcat():
    """
    Put tomcat into a directory controlled by ibeis

    CommandLine:
        # Reset
        python -c "import utool as ut; ut.delete(ut.unixjoin(ut.get_app_resource_dir('ibeis'), 'tomcat'))"
    """
    from os.path import splitext, dirname
    print('Grabbing tomcat')
    # FIXME: need to make a stable link
    if ut.WIN32:
        tomcat_binary_url = 'http://mirrors.advancedhosters.com/apache/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24-windows-x86.zip'
    else:
        tomcat_binary_url = 'http://mirrors.advancedhosters.com/apache/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.zip'
    zip_fpath = ut.grab_file_url(tomcat_binary_url, appname='ibeis')
    # Download tomcat into the IBEIS resource directory
    tomcat_dpath = join(dirname(zip_fpath), 'tomcat')
    if not ut.checkpath(tomcat_dpath, verbose=True):
        # hack because unzipping is still weird
        ut.unzip_file(zip_fpath)
        tomcat_dpath_tmp = splitext(zip_fpath)[0]
        ut.move(tomcat_dpath_tmp, tomcat_dpath)
    if ut.checkpath(join(tomcat_dpath, 'bin'), verbose=True):
        scriptnames = ['catalina.sh', 'startup.sh', 'shutdown.sh']
        for fname in scriptnames:
            fpath = join(tomcat_dpath, 'bin', fname)
            if not ut.is_file_executable(fpath):
                print('Adding executable bits to script %r' % (fpath,))
                ut.chmod_add_executable(fpath)
    return tomcat_dpath
Ejemplo n.º 6
0
    def _setup_links(self, cfg_prefix, config=None):
        """
        Called only when setting up an experiment to make a measurement.

        Creates symlinks such that all data is written to a directory that
        depends on a computer name, cfg_prefix and an arbitrary configuration
        dict.

        Then force the link in the basic directory to point to abs_dpath.
        """
        # Setup directory
        from os.path import expanduser
        assert self.dname is not None

        computer_id = ut.get_argval('--comp', default=ut.get_computer_name())

        conf_dpath = ut.ensuredir((expanduser(self.base_dpath), 'configured'))
        comp_dpath = ut.ensuredir((join(conf_dpath, computer_id)))

        link_dpath = ut.ensuredir((self.base_dpath, 'link'))

        # if True:
        #     # move to new system
        #     old_dpath = join(conf_dpath, self.dbname + '_' + computer_id)
        #     if exists(old_dpath):
        #         ut.move(old_dpath, join(comp_dpath, self.dbname))

        try:
            cfgstr = ut.repr3(config.getstate_todict_recursive())
        except AttributeError:
            cfgstr = ut.repr3(config)

        hashid = ut.hash_data(cfgstr)[0:6]
        suffix = '_'.join([cfg_prefix, hashid])
        dbcode = self.dbname + '_' + suffix

        abs_dpath = ut.ensuredir(join(comp_dpath, dbcode))

        self.dname = dbcode
        self.dpath = abs_dpath
        self.abs_dpath = abs_dpath

        # Place a basic link in the base link directory
        links = []
        links.append(expanduser(join(link_dpath, self.dbname)))
        # # Make a configured but computer agnostic link
        # links.append(expanduser(join(conf_dpath, self.dbname)))

        for link in links:
            try:
                # Overwrite any existing link so the most recently used is
                # the default
                self.link = ut.symlink(abs_dpath, link, overwrite=True)
            except Exception:
                if exists(abs_dpath):
                    newpath = ut.non_existing_path(abs_dpath, suffix='_old')
                    ut.move(link, newpath)
                    self.link = ut.symlink(abs_dpath, link)

        ut.writeto(join(abs_dpath, 'info.txt'), cfgstr)
Ejemplo n.º 7
0
def revert_to_backup(ibs):
    r"""
    Args:
        db_dir (?):

    CommandLine:
        python -m wbia.control._sql_helpers --exec-revert_to_backup

    Example:
        >>> # SCRIPT
        >>> from wbia.control._sql_helpers import *  # NOQA
        >>> import wbia
        >>> ibs = wbia.opendb(defaultdb='elephants')
        >>> result = revert_to_backup(ibs)
        >>> print(result)
    """
    db_path = ibs.get_db_core_path()
    staging_path = ibs.get_db_staging_path()

    ibs.disconnect_sqldatabase()
    backup_dir = ibs.backupdir

    # Core database
    fname, ext = splitext(db_path)
    db_path_ = '%s_revert.sqlite3' % (fname, )
    ut.move(db_path, db_path_)
    fpath, fname = split(fname)
    path_list = sorted(ut.glob(backup_dir, '%s_*%s' % (
        fname,
        ext,
    )))
    assert len(path_list) > 0
    previous_backup = path_list[-1]
    copy_database(previous_backup, db_path)

    # Staging database
    fname, ext = splitext(staging_path)
    staging_path_ = '%s_revert.sqlite3' % (fname, )
    ut.move(staging_path, staging_path_)
    fpath, fname = split(fname)
    path_list = sorted(ut.glob(backup_dir, '%s_*%s' % (
        fname,
        ext,
    )))
    assert len(path_list) > 0
    previous_backup = path_list[-1]
    copy_database(previous_backup, staging_path)

    # Delete the cache
    ut.delete(ibs.cachedir)
Ejemplo n.º 8
0
        'upfront'    : 'front',
        'upright'    : 'right',
        'upback'     : 'back',
        'down'       : 'down',
        'downleft'   : 'left',
        'downfront'  : 'front',
        'downright'  : 'right',
        'downback'   : 'back',
        None         : None,
    }
    for species in species_list
}

src_path = ibs.export_to_coco(species_list, species_mapping=species_mapping, viewpoint_mapping=viewpoint_mapping, include_parts=True, require_image_reviewed=True)
dst_path = '/data/public/datasets/orientation.seaturtle.coco'
ut.move(src_path, dst_path)

################################################################################

# Sea Drgons
ibs = wbia.opendb(dbdir='/data/wbia/SD_Master')

all_aid_list = ibs.get_valid_aids()
all_species_list = ibs.get_annot_species(all_aid_list)
all_flag_list = [
    all_species in set(['seadragon_leafy+head', 'seadragon_weedy+head'])
    for all_species in all_species_list
]
delete_aid_list = ut.compress(all_aid_list, all_flag_list)
ibs.delete_annots(delete_aid_list)
Ejemplo n.º 9
0
def compile_latex_text(input_text, dpath=None, fname=None, verbose=True,
                       move=True, nest_in_doc=None, title=None,
                       preamb_extra=None):
    r"""
    CommandLine:
        python -m utool.util_latex --test-compile_latex_text --show

    Ignore:
        pdflatex -shell-escape --synctex=-1 -src-specials -interaction=nonstopmode\
            ~/code/ibeis/tmptex/latex_formatter_temp.tex

    Example1:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_latex import *  # NOQA
        >>> import utool as ut
        >>> verbose = True
        >>> #dpath = '/home/joncrall/code/ibeis/aidchallenge'
        >>> dpath = dirname(ut.grab_test_imgpath())
        >>> #ut.vd(dpath)
        >>> orig_fpaths = ut.list_images(dpath, fullpath=True)
        >>> figure_str = ut.get_latex_figure_str(orig_fpaths, width_str='2.4in', nCols=2)
        >>> input_text = figure_str
        >>> pdf_fpath = ut.compile_latex_text(input_text, dpath=dpath,
        >>>                                   verbose=verbose)
        >>> output_pdf_fpath = ut.compress_pdf(pdf_fpath)
        >>> print(pdf_fpath)
        >>> ut.quit_if_noshow()
        >>> ut.startfile(pdf_fpath)
    """
    import utool as ut
    if verbose:
        print('[ut] compile_latex_text')

    if nest_in_doc is None:
        nest_in_doc = 'documentclass' not in input_text
    if nest_in_doc:
        text = make_full_document(input_text, title=title,
                                  preamb_extra=preamb_extra)
    if not dpath:
        dpath = os.getcwd()
    if fname is None:
        fname = 'temp_latex'

    # Create temporary work directly
    work_dpath = join(dpath, '.tmptex')
    ut.ensuredir(work_dpath, verbose=verbose > 1)

    fname_tex = ut.ensure_ext(fname, '.tex')
    fname_pdf = ut.ensure_ext(fname, '.pdf')

    tex_fpath = join(work_dpath, fname_tex)
    pdf_fpath_output = join(work_dpath, fname_pdf)
    ut.write_to(tex_fpath, text)

    with ut.ChdirContext(work_dpath, verbose=verbose > 1):
        # print(text)
        args = ' '.join([
            'lualatex', '-shell-escape', '--synctex=-1', '-src-specials',
            '-interaction=nonstopmode', tex_fpath
        ])
        info = ut.cmd2(args, verbose=verbose > 1)
        if not ut.checkpath(pdf_fpath_output, verbose=verbose > 1):
            print('Error compiling LaTeX')
            ut.print_code(text, 'latex')
            print(info['out'])
            raise RuntimeError('latex failed ')

    if move:
        pdf_fpath = join(dpath, fname_pdf)
        ut.move(pdf_fpath_output, pdf_fpath, verbose=verbose > 1)
    else:
        pdf_fpath = pdf_fpath_output
    return pdf_fpath