def get_tomcat_startup_tmpdir(): dpath_list = [ #os.environ.get('CATALINA_TMPDIR', None), ut.ensure_app_resource_dir('ibeis', 'tomcat', 'ibeis_startup_tmpdir'), ] tomcat_startup_dir = ut.search_candidate_paths(dpath_list, verbose=True) return tomcat_startup_dir
def find_tomcat(verbose=ut.NOT_QUIET): r""" Searches likely places for tomcat to be installed Returns: str: tomcat_dpath Ignore: locate --regex "tomcat/webapps$" CommandLine: python -m ibeis find_tomcat Example: >>> # SCRIPT >>> from ibeis.control.wildbook_manager import * # NOQA >>> tomcat_dpath = find_tomcat() >>> result = ('tomcat_dpath = %s' % (str(tomcat_dpath),)) >>> print(result) """ # Tomcat folder must be named one of these and contain specific files fname_list = ['Tomcat', 'tomcat'] #required_subpaths = ['webapps', 'bin', 'bin/catalina.sh'] required_subpaths = ['webapps'] # Places for local install of tomcat priority_paths = [ # Number one preference is the CATALINA_HOME directory os.environ.get('CATALINA_HOME', None), # We put tomcat here if we can't find it ut.get_app_resource_dir('ibeis', 'tomcat') ] if ut.is_developer(): # For my machine to use local catilina dpath_list = [] else: # Places for system install of tomcat if ut.WIN32: dpath_list = ['C:/Program Files (x86)', 'C:/Program Files'] elif ut.DARWIN: dpath_list = ['/Library'] # + dpath_list else: dpath_list = ['/var/lib', '/usr/share', '/opt', '/lib'] return_path = ut.search_candidate_paths(dpath_list, fname_list, priority_paths, required_subpaths, verbose=verbose) tomcat_dpath = return_path print('tomcat_dpath = %r ' % (tomcat_dpath, )) return tomcat_dpath
def find_tomcat(verbose=ut.NOT_QUIET): r""" Returns: str: tomcat_dpath CommandLine: python -m ibeis.control.manual_wildbook_funcs --test-find_tomcat python -m ibeis --tf find_tomcat Example: >>> # SCRIPT >>> from ibeis.control.manual_wildbook_funcs import * # NOQA >>> tomcat_dpath = find_tomcat() >>> result = ('tomcat_dpath = %s' % (str(tomcat_dpath),)) >>> print(result) """ import utool as ut import os fname_list = ['Tomcat', 'tomcat'] if ALLOW_SYSTEM_TOMCAT: # Places for system install of tomcat if ut.WIN32: dpath_list = ['C:/Program Files (x86)', 'C:/Program Files'] else: dpath_list = ['/var/lib', '/usr/share', '/opt', '/lib'] if ut.DARWIN: dpath_list = ['/Library'] + dpath_list else: dpath_list = [] priority_paths = [ # Numberone preference is the CATALINA_HOME directory os.environ.get('CATALINA_HOME', None), # We put tomcat here if we can't find it ut.get_app_resource_dir('ibeis', 'tomcat') ] required_subpaths = [ 'webapps', 'bin', 'bin/catalina.sh', ] return_path = ut.search_candidate_paths(dpath_list, fname_list, priority_paths, required_subpaths, verbose=verbose) tomcat_dpath = return_path print('tomcat_dpath = %r ' % (tomcat_dpath,)) return tomcat_dpath
def find_tomcat(verbose=ut.NOT_QUIET): r""" Searches likely places for tomcat to be installed Returns: str: tomcat_dpath Ignore: locate --regex "tomcat/webapps$" CommandLine: python -m ibeis find_tomcat Example: >>> # SCRIPT >>> from ibeis.control.wildbook_manager import * # NOQA >>> tomcat_dpath = find_tomcat() >>> result = ('tomcat_dpath = %s' % (str(tomcat_dpath),)) >>> print(result) """ # Tomcat folder must be named one of these and contain specific files fname_list = ['Tomcat', 'tomcat'] #required_subpaths = ['webapps', 'bin', 'bin/catalina.sh'] required_subpaths = ['webapps'] # Places for local install of tomcat priority_paths = [ # Number one preference is the CATALINA_HOME directory os.environ.get('CATALINA_HOME', None), # We put tomcat here if we can't find it ut.get_app_resource_dir('ibeis', 'tomcat') ] if ut.is_developer(): # For my machine to use local catilina dpath_list = [] else: # Places for system install of tomcat if ut.WIN32: dpath_list = ['C:/Program Files (x86)', 'C:/Program Files'] elif ut.DARWIN: dpath_list = ['/Library'] + dpath_list else: dpath_list = ['/var/lib', '/usr/share', '/opt', '/lib'] return_path = ut.search_candidate_paths( dpath_list, fname_list, priority_paths, required_subpaths, verbose=verbose) tomcat_dpath = return_path print('tomcat_dpath = %r ' % (tomcat_dpath,)) return tomcat_dpath
def find_java_jvm(): r""" CommandLine: python -m ibeis.control.manual_wildbook_funcs --test-find_java_jvm Example: >>> # DISABLE_DOCTEST >>> from ibeis.control.manual_wildbook_funcs import * # NOQA >>> result = find_java_jvm() >>> print(result) """ candidate_path_list = [ #os.environ.get('JAVA_HOME', None), #'/usr/lib/jvm/java-7-openjdk-amd64', ] jvm_fpath = ut.search_candidate_paths(candidate_path_list, verbose=True) ut.assertpath(jvm_fpath, 'IBEIS cannot find Java Runtime Environment') return jvm_fpath
def find_java_jvm(): r""" CommandLine: python -m ibeis find_java_jvm Example: >>> # DISABLE_DOCTEST >>> from ibeis.control.wildbook_manager import * # NOQA >>> jvm_fpath = find_java_jvm() >>> result = ('jvm_fpath = %r' % (jvm_fpath,)) >>> print(result) """ candidate_path_list = [ os.environ.get('JAVA_HOME', None), '/usr/lib/jvm/java-7-openjdk-amd64', ] jvm_fpath = ut.search_candidate_paths(candidate_path_list, verbose=True) ut.assertpath(jvm_fpath, 'IBEIS cannot find Java Runtime Environment') return jvm_fpath
def find_and_open_path(path, mode='split', verbose=0, enable_python=True, enable_url=True): """ Fancy-Find. Does some magic to try and find the correct path. Currently supports: * well-formed absolute and relatiave paths * ill-formed relative paths when you are in a descendant directory * python modules that exist in the PYTHONPATH """ import utool as ut import os def try_open(path): # base = '/home/joncrall/code/VIAME/packages/kwiver/sprokit/src/bindings/python/sprokit/pipeline' # base = '/home' if path and exists(path): if verbose: print('EXISTS path = {!r}\n'.format(path)) open_fpath(path, mode=mode, verbose=verbose) return True def expand_module(path): # if True or filetype in {'py', 'pyx'}: # filetype = get_current_filetype() from xdoctest import static_analysis as static try: path = static.modname_to_modpath(path) # print('rectified module to path = {!r}'.format(path)) except Exception as ex: # if True or filetype in {'py', 'pyx'}: return None return path if enable_url: # https://github.com/Erotemic url = extract_url_embeding(path) if is_url(url): ut.open_url_in_browser(url, 'google-chrome') return path = expanduser(path) if try_open(path): return if try_open(os.path.expandvars(path)): return # path = 'sprokit/pipeline/pipeline.h' # base = os.getcwd() # base = '/home/joncrall/code/VIAME/packages/kwiver/sprokit/src/bindings/python/sprokit/pipeline' if path.startswith('<') and path.endswith('>'): path = path[1:-1] if path.endswith(':'): path = path[:-1] if try_open(path): return # Search downwards for relative paths candidates = [] if not os.path.isabs(path): limit = {'~', os.path.expanduser('~')} start = os.getcwd() candidates += list(ut.ancestor_paths(start, limit=limit)) candidates += os.environ['PATH'].split(os.sep) result = ut.search_candidate_paths(candidates, [path], verbose=verbose) if result is not None: path = result current_fpath = get_current_fpath() if os.path.islink(current_fpath): newbase = os.path.dirname(os.path.realpath(current_fpath)) resolved_path = os.path.join(newbase, path) if try_open(resolved_path): return if try_open(path): return else: if enable_python: if try_open(expand_module(path)): return #vim.command('echoerr "Could not find path={}"'.format(path)) print('Could not find path={}'.format(path))