def _check_install(self):
        """Check if tlgu installed, if not install it."""
        try:
            subprocess.check_output(['which', 'tlgu'])
        except Exception as exc:
            logger.info('TLGU not installed: %s', exc)
            logger.info('Installing TLGU.')
            if not subprocess.check_output(['which', 'gcc']):
                logger.error('GCC seems not to be installed.')
            else:
                tlgu_path_rel = '~/cltk_data/greek/software/greek_software_tlgu'
                tlgu_path = os.path.expanduser(tlgu_path_rel)
                if not self.testing:
                    print('Do you want to install TLGU?')
                    print('To continue, press Return. To exit, Control-C.')
                    input()
                else:
                    print('Automated or test build, skipping keyboard input confirmation for installation of TLGU.')
                try:
                    command = 'cd {0} && make install'.format(tlgu_path)
                    print('Going to run command:', command)
                    p_out = subprocess.call(command, shell=True)
                    if p_out == 0:
                        logger.info('TLGU installed.')
                    else:
                        logger.error('TLGU install without sudo failed.')
                except Exception as exc:
                    logger.error('TLGU install failed: %s', exc)
                else:  # for Linux needing root access to '/usr/local/bin'
                    if not self.testing:
                        print('Could not install without root access. Do you want to install TLGU with sudo?')
                        command = 'cd {0} && sudo make install'.format(tlgu_path)
                        print('Going to run command:', command)
                        print('To continue, press Return. To exit, Control-C.')
                        input()
                        p_out = subprocess.call(command, shell=True)
                    else:
                        command = 'cd {0} && sudo make install'.format(tlgu_path)
                        p_out = subprocess.call(command, shell=True)
                    if p_out == 0:
                        logger.info('TLGU installed.')
                    else:
                        logger.error('TLGU install with sudo failed.')
def _check_install ( self ) : try : subprocess . check_output ( [ 'which' , 'tlgu' ] ) except Exception as exc : logger . info ( 'TLGU not installed: %s' , exc ) logger . info ( 'Installing TLGU.' ) if not subprocess . check_output ( [ 'which' , 'gcc' ] ) : logger . error ( 'GCC seems not to be installed.' ) else : tlgu_path_rel = '~/cltk_data/greek/software/greek_software_tlgu' tlgu_path = os . path . expanduser ( tlgu_path_rel ) if not self . testing : print ( 'Do you want to install TLGU?' ) print ( 'To continue, press Return. To exit, Control-C.' ) input ( ) else : print ( 'Automated or test build, skipping keyboard input confirmation for installation of TLGU.' ) try : command = 'cd {0} && make install' . format ( tlgu_path ) print ( 'Going to run command:' , command ) p_out = subprocess . call ( command , shell = True ) if p_out == 0 : logger . info ( 'TLGU installed.' ) else : logger . error ( 'TLGU install without sudo failed.' ) except Exception as exc : logger . error ( 'TLGU install failed: %s' , exc ) else : if not self . testing : print ( 'Could not install without root access. Do you want to install TLGU with sudo?' ) command = 'cd {0} && sudo make install' . format ( tlgu_path ) print ( 'Going to run command:' , command ) print ( 'To continue, press Return. To exit, Control-C.' ) input ( ) p_out = subprocess . call ( command , shell = True ) else : command = 'cd {0} && sudo make install' . format ( tlgu_path ) p_out = subprocess . call ( command , shell = True ) if p_out == 0 : logger . info ( 'TLGU installed.' ) else : logger . error ( 'TLGU install with sudo failed.' )
Check if tlgu installed, if not install it.