From a85334f3968958b9444a2e106e9c945988bc9e6f Mon Sep 17 00:00:00 2001 From: Kevin Peterson Date: Wed, 17 Jun 2020 09:29:35 -0500 Subject: [PATCH] Eliminated calls to os.system(). Example IOCs now build on Windows (VS2017). --- .ci-local/travis/post-prepare.py | 38 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/.ci-local/travis/post-prepare.py b/.ci-local/travis/post-prepare.py index 0993e5a..5557fdf 100755 --- a/.ci-local/travis/post-prepare.py +++ b/.ci-local/travis/post-prepare.py @@ -2,26 +2,42 @@ import os import shutil + # ugly hack: copy cue.py so that it can be imported shutil.copy('.ci/cue.py', '.ci-local/travis') from cue import * +def cat(filename): + ''' + Print the contents of a file + ''' + with open(filename, 'r') as fh: + for line in fh: + print(line.strip()) + +def sanity_check(filename): + ''' + Include the contents of a file in the travis log + ''' + print("{}Contents of {}{}".format(ANSI_BLUE, filename, ANSI_RESET)) + cat(filename) + print("{}End of {}{}".format(ANSI_BLUE, filename, ANSI_RESET)) + # Add the path to the driver module to the RELEASE.local file, since it is needed by the example IOC update_release_local('MOTOR_ACS', os.getenv('TRAVIS_BUILD_DIR')) # Copy the travis RELEASE.local to the configure dir -shutil.copy("{}/RELEASE.local".format(cachedir), "configure/RELEASE.local") - -# Sanity check -print("{}Contents of updated configure/RELEASE.local{}".format(ANSI_BLUE, ANSI_RESET)) -os.system('cat configure/RELEASE.local') -print("{}End of updated configure/RELEASE.local{}".format(ANSI_BLUE, ANSI_RESET)) +filename = "configure/RELEASE.local" +shutil.copy("{}/RELEASE.local".format(cachedir), filename) +sanity_check(filename) # Enable the building of example IOCs -print("{}Contents of updated configure/CONFIG_SITE.local{}".format(ANSI_BLUE, ANSI_RESET)) -os.system('echo "BUILD_IOCS = YES" > configure/CONFIG_SITE.local') -os.system('cat configure/CONFIG_SITE.local') -print("{}End of updated configure/CONFIG_SITE.local{}".format(ANSI_BLUE, ANSI_RESET)) +filename = "configure/CONFIG_SITE.local" +fh = open(filename, 'w') +fh.write("BUILD_IOCS = YES") +fh.close() +sanity_check(filename) # Remove cue.py -os.system('rm -f .ci-local/travis/cue.py') +os.remove('.ci-local/travis/cue.py') +os.remove('.ci-local/travis/cue.pyc')