archiver/util.py
def check_dependencies():
    """Check that all necessary dependencies are installed, and have valid versions"""

    python_vers = float('{}.{}'.format(sys.version_info.major, sys.version_info.minor))
    if python_vers < 3.5:
        print('{}[X] Python version is not new enough: {} (>3.5 is required){}'.format(ANSI['red'], python_vers, ANSI['reset']))
        print('    See https://github.com/pirate/bookmark-archiver#troubleshooting for help upgrading your Python installation.')
        raise SystemExit(1)

    if FETCH_PDF or FETCH_SCREENSHOT or FETCH_DOM:
        if run(['which', CHROME_BINARY], stdout=DEVNULL).returncode:
            print('{}[X] Missing dependency: {}{}'.format(ANSI['red'], CHROME_BINARY, ANSI['reset']))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format(CHROME_BINARY))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)

        # parse chrome --version e.g. Google Chrome 61.0.3114.0 canary / Chromium 59.0.3029.110 built on Ubuntu, running on Ubuntu 16.04
        try:
            result = run([CHROME_BINARY, '--version'], stdout=PIPE)
            version_str = result.stdout.decode('utf-8')
            version_lines = re.sub("(Google Chrome|Chromium) (\\d+?)\\.(\\d+?)\\.(\\d+?).*?$", "\\2", version_str).split('\n')
            version = [l for l in version_lines if l.isdigit()][-1]
            if int(version) < 59:
                print(version_lines)
                print('{red}[X] Chrome version must be 59 or greater for headless PDF, screenshot, and DOM saving{reset}'.format(**ANSI))
                print('    See https://github.com/pirate/bookmark-archiver for help.')
                raise SystemExit(1)
        except (IndexError, TypeError, OSError):
            print('{red}[X] Failed to parse Chrome version, is it installed properly?{reset}'.format(**ANSI))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format(CHROME_BINARY))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)

    if FETCH_WGET:
        if run(['which', 'wget'], stdout=DEVNULL).returncode or run(['wget', '--version'], stdout=DEVNULL).returncode:
            print('{red}[X] Missing dependency: wget{reset}'.format(**ANSI))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format('wget'))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)

    if FETCH_FAVICON or SUBMIT_ARCHIVE_DOT_ORG:
        if run(['which', 'curl'], stdout=DEVNULL).returncode or run(['curl', '--version'], stdout=DEVNULL).returncode:
            print('{red}[X] Missing dependency: curl{reset}'.format(**ANSI))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format('curl'))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)

    if FETCH_AUDIO or FETCH_VIDEO:
        if run(['which', 'youtube-dl'], stdout=DEVNULL).returncode or run(['youtube-dl', '--version'], stdout=DEVNULL).returncode:
            print('{red}[X] Missing dependency: youtube-dl{reset}'.format(**ANSI))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format('youtube-dl'))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)
Check that all necessary dependencies are installed, and have valid versions
Check that all necessary dependencies are installed, and have valid versions
Check that all necessary dependencies are installed and have valid versions
def check_dependencies():
    python_vers = float('{}.{}'.format(sys.version_info.major, sys.version_info.minor))
    if python_vers < 3.5:
        print('{}[X] Python version is not new enough: {} (>3.5 is required){}'.format(ANSI['red'], python_vers, ANSI['reset']))
        print('    See https://github.com/pirate/bookmark-archiver#troubleshooting for help upgrading your Python installation.')
        raise SystemExit(1)
    if FETCH_PDF or FETCH_SCREENSHOT or FETCH_DOM:
        if run(['which', CHROME_BINARY], stdout=DEVNULL).returncode:
            print('{}[X] Missing dependency: {}{}'.format(ANSI['red'], CHROME_BINARY, ANSI['reset']))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format(CHROME_BINARY))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)
        try:
            result = run([CHROME_BINARY, '--version'], stdout=PIPE)
            version_str = result.stdout.decode('utf-8')
            version_lines = re.sub("(Google Chrome|Chromium) (\\d+?)\\.(\\d+?)\\.(\\d+?).*?$", "\\2", version_str).split('\n')
            version = [l for l in version_lines if l.isdigit()][-1]
            if int(version) < 59:
                print(version_lines)
                print('{red}[X] Chrome version must be 59 or greater for headless PDF, screenshot, and DOM saving{reset}'.format(**ANSI))
                print('    See https://github.com/pirate/bookmark-archiver for help.')
                raise SystemExit(1)
        except (IndexError, TypeError, OSError):
            print('{red}[X] Failed to parse Chrome version, is it installed properly?{reset}'.format(**ANSI))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format(CHROME_BINARY))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)
    if FETCH_WGET:
        if run(['which', 'wget'], stdout=DEVNULL).returncode or run(['wget', '--version'], stdout=DEVNULL).returncode:
            print('{red}[X] Missing dependency: wget{reset}'.format(**ANSI))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format('wget'))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)
    if FETCH_FAVICON or SUBMIT_ARCHIVE_DOT_ORG:
        if run(['which', 'curl'], stdout=DEVNULL).returncode or run(['curl', '--version'], stdout=DEVNULL).returncode:
            print('{red}[X] Missing dependency: curl{reset}'.format(**ANSI))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format('curl'))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)
    if FETCH_AUDIO or FETCH_VIDEO:
        if run(['which', 'youtube-dl'], stdout=DEVNULL).returncode or run(['youtube-dl', '--version'], stdout=DEVNULL).returncode:
            print('{red}[X] Missing dependency: youtube-dl{reset}'.format(**ANSI))
            print('    Run ./setup.sh, then confirm it was installed with: {} --version'.format('youtube-dl'))
            print('    See https://github.com/pirate/bookmark-archiver for help.')
            raise SystemExit(1)
def check_dependencies ( ) : python_vers = float ( '{}.{}' . format ( sys . version_info . major , sys . version_info . minor ) ) if python_vers < 3.5 : print ( '{}[X] Python version is not new enough: {} (>3.5 is required){}' . format ( ANSI [ 'red' ] , python_vers , ANSI [ 'reset' ] ) ) print ( '    See https://github.com/pirate/bookmark-archiver#troubleshooting for help upgrading your Python installation.' ) raise SystemExit ( 1 ) if FETCH_PDF or FETCH_SCREENSHOT or FETCH_DOM : if run ( [ 'which' , CHROME_BINARY ] , stdout = DEVNULL ) . returncode : print ( '{}[X] Missing dependency: {}{}' . format ( ANSI [ 'red' ] , CHROME_BINARY , ANSI [ 'reset' ] ) ) print ( '    Run ./setup.sh, then confirm it was installed with: {} --version' . format ( CHROME_BINARY ) ) print ( '    See https://github.com/pirate/bookmark-archiver for help.' ) raise SystemExit ( 1 ) try : result = run ( [ CHROME_BINARY , '--version' ] , stdout = PIPE ) version_str = result . stdout . decode ( 'utf-8' ) version_lines = re . sub ( "(Google Chrome|Chromium) (\\d+?)\\.(\\d+?)\\.(\\d+?).*?$" , "\\2" , version_str ) . split ( '\n' ) version = [ l for l in version_lines if l . isdigit ( ) ] [ - 1 ] if int ( version ) < 59 : print ( version_lines ) print ( '{red}[X] Chrome version must be 59 or greater for headless PDF, screenshot, and DOM saving{reset}' . format ( ** ANSI ) ) print ( '    See https://github.com/pirate/bookmark-archiver for help.' ) raise SystemExit ( 1 ) except ( IndexError , TypeError , OSError ) : print ( '{red}[X] Failed to parse Chrome version, is it installed properly?{reset}' . format ( ** ANSI ) ) print ( '    Run ./setup.sh, then confirm it was installed with: {} --version' . format ( CHROME_BINARY ) ) print ( '    See https://github.com/pirate/bookmark-archiver for help.' ) raise SystemExit ( 1 ) if FETCH_WGET : if run ( [ 'which' , 'wget' ] , stdout = DEVNULL ) . returncode or run ( [ 'wget' , '--version' ] , stdout = DEVNULL ) . returncode : print ( '{red}[X] Missing dependency: wget{reset}' . format ( ** ANSI ) ) print ( '    Run ./setup.sh, then confirm it was installed with: {} --version' . format ( 'wget' ) ) print ( '    See https://github.com/pirate/bookmark-archiver for help.' ) raise SystemExit ( 1 ) if FETCH_FAVICON or SUBMIT_ARCHIVE_DOT_ORG : if run ( [ 'which' , 'curl' ] , stdout = DEVNULL ) . returncode or run ( [ 'curl' , '--version' ] , stdout = DEVNULL ) . returncode : print ( '{red}[X] Missing dependency: curl{reset}' . format ( ** ANSI ) ) print ( '    Run ./setup.sh, then confirm it was installed with: {} --version' . format ( 'curl' ) ) print ( '    See https://github.com/pirate/bookmark-archiver for help.' ) raise SystemExit ( 1 ) if FETCH_AUDIO or FETCH_VIDEO : if run ( [ 'which' , 'youtube-dl' ] , stdout = DEVNULL ) . returncode or run ( [ 'youtube-dl' , '--version' ] , stdout = DEVNULL ) . returncode : print ( '{red}[X] Missing dependency: youtube-dl{reset}' . format ( ** ANSI ) ) print ( '    Run ./setup.sh, then confirm it was installed with: {} --version' . format ( 'youtube-dl' ) ) print ( '    See https://github.com/pirate/bookmark-archiver for help.' ) raise SystemExit ( 1 )
Check that all necessary dependencies are installed, and have valid versions
Check that all necessary dependencies are installed and have valid versions
"""Check that all necessary dependencies are installed, and have valid versions""" # parse chrome --version e.g. Google Chrome 61.0.3114.0 canary / Chromium 59.0.3029.110 built on Ubuntu, running on Ubuntu 16.04