def _locate(self, *args, **kwargs): if not self._dont_update_db: try: with sh.contrib.sudo: sh.updatedb() self._dont_update_db = True except sh.ErrorReturnCode_1: print('Invalid password') exit(1) try: return [s.rstrip() for s in sh.locate(*args, **kwargs)] except sh.ErrorReturnCode_1: return []
def _locate(self, *args, **kwargs): if not self._dont_update_db: try: print( 'If you do not want to run sudo, use the following command to configure Phigaro:' ) print(' phigaro-setup --no-updatedb') with sh.contrib.sudo: sh.updatedb() self._dont_update_db = True except sh.ErrorReturnCode_1: print('Invalid password') exit(1) try: return [s.rstrip() for s in sh.locate(*args, **kwargs)] except sh.ErrorReturnCode_1: return []
def build_version_infos(): version_infos = [] if iswin(): possible_dir_name = [ 'Program Files (x86)', 'Program Files', 'ProgramData', ] possible_dir = [] for driver in get_drivers(): for each_dir in possible_dir_name: possible_dir.append(os.path.join(driver, os.sep, each_dir)) possible_dir.append(os.path.abspath(os.curdir)) for each_possible_dir in possible_dir: for java_path in find_wrapper(each_possible_dir, 'java'): try: version_info = _build_version_info(java_path) except NotBelongToJDKError: pass else: color.print_info('') version_infos.append(version_info) else: JAVA_PATTERN = '^.*/java/jdk[^/]*/bin/java$' for item in sh.locate('-A', '-r', JAVA_PATTERN): java_path = item.__str__().strip() try: version_info = _build_version_info(java_path) except NotBelongToJDKError: pass else: color.print_info('') version_infos.append(version_info) return version_infos
def run(self): """ :return: """ import sh env = os.environ.copy() # update RST files from python files sh.cd(os.path.join(PATH_ROOT, 'docs')) out = sh.sphinx_apidoc('-o', '.', '../fludashboard', '--force') print(out) # update RST files from python javascript files path_template = list( sh.grep(sh.locate('jsdoc-sphinx'), 'template$') )[0].replace('\n', '') out = sh.jsdoc( '-t', path_template, '-d', 'jsdoc/', '../fludashboard/static/js/' ) print(out)