Verify requirements_all in Travis
This commit is contained in:
parent
a0ff8819a9
commit
b5fc7f5e71
4 changed files with 25 additions and 8 deletions
|
@ -8,6 +8,7 @@ import importlib
|
|||
import os
|
||||
import pkgutil
|
||||
import re
|
||||
import sys
|
||||
|
||||
COMMENT_REQUIREMENTS = [
|
||||
'RPi.GPIO',
|
||||
|
@ -68,8 +69,9 @@ def gather_modules():
|
|||
reqs.setdefault(req, []).append(package)
|
||||
|
||||
if errors:
|
||||
print("Found errors")
|
||||
print('\n'.join(errors))
|
||||
print("******* ERROR")
|
||||
print("Errors while importing: ", ', '.join(errors))
|
||||
print("Make sure you import 3rd party libraries inside methods.")
|
||||
return None
|
||||
|
||||
output.append('# Home Assistant core')
|
||||
|
@ -95,6 +97,12 @@ def write_file(data):
|
|||
req_file.write(data)
|
||||
|
||||
|
||||
def validate_file(data):
|
||||
""" Validates if requirements_all.txt is up to date. """
|
||||
with open('requirements_all.txt', 'r') as req_file:
|
||||
return data == ''.join(req_file)
|
||||
|
||||
|
||||
def main():
|
||||
""" Main """
|
||||
if not os.path.isfile('requirements_all.txt'):
|
||||
|
@ -104,7 +112,16 @@ def main():
|
|||
data = gather_modules()
|
||||
|
||||
if data is None:
|
||||
return
|
||||
sys.exit(1)
|
||||
|
||||
if sys.argv[-1] == 'validate':
|
||||
if validate_file(data):
|
||||
print("requirements_all.txt is up to date.")
|
||||
sys.exit(0)
|
||||
print("******* ERROR")
|
||||
print("requirements_all.txt is not up to date")
|
||||
print("Please run script/gen_requirements_all.py")
|
||||
sys.exit(1)
|
||||
|
||||
write_file(data)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue