def com_google_fonts_check_fontbakery_version():
  """Do we have the latest version of FontBakery installed?"""

  try:
    import subprocess
    installed_str = None
    latest_str = None
    is_latest = False
    failed = False
    pip_cmd = ["pip", "search", "fontbakery"]
    pip_output = subprocess.check_output(pip_cmd, stderr=subprocess.STDOUT)
    for line in pip_output.decode().split('\n'):
      if 'INSTALLED' in line:
        installed_str = line.split('INSTALLED')[1].strip()
      if 'LATEST' in line:
        latest_str = line.split('LATEST')[1].strip()
      if '(latest)' in line:
        is_latest = True

    if not (is_latest or is_up_to_date(installed_str, latest_str)):
      failed = True
      yield FAIL, (f"Current Font Bakery version is {installed_str},"
                   f" while a newer {latest_str} is already available."
                    " Please upgrade it with 'pip install -U fontbakery'")
    yield INFO, pip_output.decode()
  except subprocess.CalledProcessError as e:
    yield ERROR, ("Running 'pip search fontbakery' returned an error code."
                  " Output follows :\n\n{}\n").format(e.output.decode())

  if not failed:
    yield PASS, "Font Bakery is up-to-date"
def com_google_fonts_check_fontbakery_version ( ) : try : import subprocess installed_str = None latest_str = None is_latest = False failed = False pip_cmd = [ "pip" , "search" , "fontbakery" ] pip_output = subprocess . check_output ( pip_cmd , stderr = subprocess . STDOUT ) for line in pip_output . decode ( ) . split ( '\n' ) : if 'INSTALLED' in line : installed_str = line . split ( 'INSTALLED' ) [ 1 ] . strip ( ) if 'LATEST' in line : latest_str = line . split ( 'LATEST' ) [ 1 ] . strip ( ) if '(latest)' in line : is_latest = True if not ( is_latest or is_up_to_date ( installed_str , latest_str ) ) : failed = True yield FAIL , ( f"Current Font Bakery version is {installed_str}," f" while a newer {latest_str} is already available." " Please upgrade it with 'pip install -U fontbakery'" ) yield INFO , pip_output . decode ( ) except subprocess . CalledProcessError as e : yield ERROR , ( "Running 'pip search fontbakery' returned an error code." " Output follows :\n\n{}\n" ) . format ( e . output . decode ( ) ) if not failed : yield PASS , "Font Bakery is up-to-date"
Do we have the latest version of FontBakery installed?