2018-02-27 23:05:39 +00:00
|
|
|
#!/usr/bin/env python
|
2019-07-12 06:46:20 +00:00
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
2018-02-27 23:05:39 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
# required by external automated processes and should not be moved, renamed or converted to a symbolic link
|
2019-08-21 05:23:28 +00:00
|
|
|
original = 'examples/scripts/ConfigureRemotingForAnsible.ps1'
|
|
|
|
# required to be packaged with ansible-test and must match the original file, but cannot be a symbolic link
|
|
|
|
# the packaged version is needed to run tests when ansible-test has been installed
|
|
|
|
# keeping the packaged version identical to the original makes sure tests cover both files
|
|
|
|
packaged = 'test/lib/ansible_test/_data/setup/ConfigureRemotingForAnsible.ps1'
|
2018-02-27 23:05:39 +00:00
|
|
|
|
2019-08-21 05:23:28 +00:00
|
|
|
copy_valid = False
|
2018-02-27 23:05:39 +00:00
|
|
|
|
2019-08-21 05:23:28 +00:00
|
|
|
if os.path.isfile(original) and os.path.isfile(packaged):
|
|
|
|
with open(original, 'rb') as original_file:
|
|
|
|
original_content = original_file.read()
|
2018-02-27 23:05:39 +00:00
|
|
|
|
2019-08-21 05:23:28 +00:00
|
|
|
with open(packaged, 'rb') as packaged_file:
|
|
|
|
packaged_content = packaged_file.read()
|
2018-02-27 23:05:39 +00:00
|
|
|
|
2019-08-21 05:23:28 +00:00
|
|
|
if original_content == packaged_content:
|
|
|
|
copy_valid = True
|
2018-02-27 23:05:39 +00:00
|
|
|
|
2019-08-21 05:23:28 +00:00
|
|
|
if not copy_valid:
|
|
|
|
print('%s: must be an exact copy of "%s"' % (packaged, original))
|
2018-02-27 23:05:39 +00:00
|
|
|
|
2019-08-21 05:23:28 +00:00
|
|
|
for path in [original, packaged]:
|
|
|
|
directory = path
|
|
|
|
|
|
|
|
while True:
|
|
|
|
directory = os.path.dirname(directory)
|
|
|
|
|
|
|
|
if not directory:
|
|
|
|
break
|
|
|
|
|
|
|
|
if not os.path.isdir(directory):
|
|
|
|
print('%s: must be a directory' % directory)
|
|
|
|
|
|
|
|
if os.path.islink(directory):
|
|
|
|
print('%s: cannot be a symbolic link' % directory)
|
|
|
|
|
|
|
|
if not os.path.isfile(path):
|
|
|
|
print('%s: must be a file' % path)
|
|
|
|
|
|
|
|
if os.path.islink(path):
|
|
|
|
print('%s: cannot be a symbolic link' % path)
|
2018-02-27 23:05:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|