def check_submodules():
 if (not os.path.exists('.git')):
  return
 with open('.gitmodules') as f:
  for l in f:
   if ('path' in l):
    p = l.split('=')[(-1)].strip()
    if (not os.path.exists(p)):
     raise ValueError(('Submodule %s missing' % p))
 proc = subprocess.Popen(['git', 'submodule', 'status'], stdout=subprocess.PIPE)
 (status, _) = proc.communicate()
 status = status.decode('ascii', 'replace')
 for line in status.splitlines():
  if (line.startswith('-') or line.startswith('+')):
   raise ValueError(('Submodule not clean: %s' % line))

def check_submodules ( ) : if ( not os . path . exists ( '.git' ) ) : return with open ( '.gitmodules' ) as f : for l in f : if ( 'path' in l ) : p = l . split ( '=' ) [ ( - 1 ) ] . strip ( ) if ( not os . path . exists ( p ) ) : raise ValueError ( ( 'Submodule %s missing' % p ) ) proc = subprocess . Popen ( [ 'git' , 'submodule' , 'status' ] , stdout = subprocess . PIPE ) ( status , _ ) = proc . communicate ( ) status = status . decode ( 'ascii' , 'replace' ) for line in status . splitlines ( ) : if ( line . startswith ( '-' ) or line . startswith ( '+' ) ) : raise ValueError ( ( 'Submodule not clean: %s' % line ) )
verify that the submodules are checked out and clean use git submodule update --init; on failure .