New lazytox.py script (#12862)

This commit is contained in:
Johann Kellerman 2018-03-09 22:27:39 +02:00 committed by GitHub
parent d8a7c547df
commit 37d8cd7b75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 262 additions and 30 deletions

View file

@ -277,23 +277,23 @@ def validate_constraints_file(data):
return data + CONSTRAINT_BASE == req_file.read()
def main():
def main(validate):
"""Main section of the script."""
if not os.path.isfile('requirements_all.txt'):
print('Run this from HA root dir')
return
return 1
data = gather_modules()
if data is None:
sys.exit(1)
return 1
constraints = gather_constraints()
reqs_file = requirements_all_output(data)
reqs_test_file = requirements_test_output(data)
if sys.argv[-1] == 'validate':
if validate:
errors = []
if not validate_requirements_file(reqs_file):
errors.append("requirements_all.txt is not up to date")
@ -309,14 +309,16 @@ def main():
print("******* ERROR")
print('\n'.join(errors))
print("Please run script/gen_requirements_all.py")
sys.exit(1)
return 1
sys.exit(0)
return 0
write_requirements_file(reqs_file)
write_test_requirements_file(reqs_test_file)
write_constraints_file(constraints)
return 0
if __name__ == '__main__':
main()
_VAL = sys.argv[-1] == 'validate'
sys.exit(main(_VAL))