From f648d7f54079fe2917838bc98f300606c51a7dfd Mon Sep 17 00:00:00 2001 From: Xuefeng Date: Mon, 18 May 2015 17:32:11 -0400 Subject: [PATCH 1/4] add a tool to construct the config files This is a tool for developers constructing the config files. --- check_config.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 check_config.py diff --git a/check_config.py b/check_config.py new file mode 100644 index 0000000..276d9da --- /dev/null +++ b/check_config.py @@ -0,0 +1,29 @@ +''' + + check_config.py + + + This is a tool for developers constructing the config files. After running + init/build config for your repository, you can check whether missing some + repositories by running this program. + + + python check_config.py + +''' + +import os +import sys + +current_repos = os.path.basename(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +project = 'https://github.com/SeattleTestbed/' + +for repos in os.listdir("../DEPENDENCIES"): + if repos !=".DS_Store": + for line in open("../DEPENDENCIES"+ os.sep + repos + os.sep +"scripts/config_initialize.txt", 'r'): + if line.startswith("#") or line.strip() == '': + continue + url = line.split()[0].strip() + repository = url[len(project): ] + if repository not in os.listdir("../DEPENDENCIES") and repository != current_repos: + print "Need to add "+ repository + " to config_initialize.txt" From 8dc7594e26934cb0fac44b7d9371d2463a77921e Mon Sep 17 00:00:00 2001 From: Xuefeng Date: Wed, 20 May 2015 22:03:48 -0400 Subject: [PATCH 2/4] fixed some issues --- check_config.py | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/check_config.py b/check_config.py index 276d9da..c19b658 100644 --- a/check_config.py +++ b/check_config.py @@ -3,9 +3,13 @@ check_config.py - This is a tool for developers constructing the config files. After running - init/build config for your repository, you can check whether missing some - repositories by running this program. +"This is a tool for developers constructing build configuration files for +SeattleTestbed repositories. After running initialize.py and build.py on +your current init/build config for your repository, this script checks for +all of the dependencies you listed whether they require further repos checked +out and files copied, and prints a message for each missing sub-dependency. +See also https://seattle.poly.edu/wiki/BuildInstructions for a description of +the SeattleTestbed build process." python check_config.py @@ -13,17 +17,31 @@ ''' import os -import sys +# Set current_repo to the name of this repository's base directory. (This should be the repo's name.) current_repos = os.path.basename(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) project = 'https://github.com/SeattleTestbed/' -for repos in os.listdir("../DEPENDENCIES"): - if repos !=".DS_Store": - for line in open("../DEPENDENCIES"+ os.sep + repos + os.sep +"scripts/config_initialize.txt", 'r'): +init = [] +for line in open('config_initialize.txt','r'): + if line.startswith("#") or line.strip() =='': + continue + init.append(line.split()[0].strip()) + +result = dict() +for repo in os.listdir("../DEPENDENCIES"): + if os.path.isdir("../DEPENDENCIES" + os.sep + repo): + for line in open("../DEPENDENCIES"+ os.sep + repo + os.sep +"scripts/config_initialize.txt", 'r'): if line.startswith("#") or line.strip() == '': continue url = line.split()[0].strip() - repository = url[len(project): ] - if repository not in os.listdir("../DEPENDENCIES") and repository != current_repos: - print "Need to add "+ repository + " to config_initialize.txt" + if url not in init: + try: + result[repo].append(url) + except KeyError: + result[repo] = [url] + +for key,value in result.items(): + print "# Additionally required by dependency " + key + ":" + for setting in value: + print setting + '.git' From 74787929530eb9175f55b81e5bba891178ac81c5 Mon Sep 17 00:00:00 2001 From: Xuefeng Date: Fri, 22 May 2015 10:51:07 -0400 Subject: [PATCH 3/4] Add to check build config and fix some issues --- check_config.py | 91 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 27 deletions(-) diff --git a/check_config.py b/check_config.py index c19b658..b95fa51 100644 --- a/check_config.py +++ b/check_config.py @@ -18,30 +18,67 @@ import os -# Set current_repo to the name of this repository's base directory. (This should be the repo's name.) -current_repos = os.path.basename(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) -project = 'https://github.com/SeattleTestbed/' - -init = [] -for line in open('config_initialize.txt','r'): - if line.startswith("#") or line.strip() =='': - continue - init.append(line.split()[0].strip()) - -result = dict() -for repo in os.listdir("../DEPENDENCIES"): - if os.path.isdir("../DEPENDENCIES" + os.sep + repo): - for line in open("../DEPENDENCIES"+ os.sep + repo + os.sep +"scripts/config_initialize.txt", 'r'): - if line.startswith("#") or line.strip() == '': - continue - url = line.split()[0].strip() - if url not in init: - try: - result[repo].append(url) - except KeyError: - result[repo] = [url] - -for key,value in result.items(): - print "# Additionally required by dependency " + key + ":" - for setting in value: - print setting + '.git' +def read_initconfig(filename): + content =[] + for line in open(filename, 'r'): + if line.startswith('#') or line.strip() == '': + continue + content.append(line.strip()) + return content + +def read_buildconfig(filename, repo): + content =[] + for line in open(filename, 'r'): + if line.startswith('#') or line.strip() == '' or line.startswith('test'): + continue + if line.startswith("./"): + line = line.replace("./","DEPENDENCIES"+ os.sep + repo + os.sep) + content.append(line.split()[0].strip()) + return content + +def main(): + # Set current_repo to the name of this repository's base directory. (This should be the repo's name.) + current_repo = os.path.basename(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) + + init_dependencies = read_initconfig('config_initialize.txt') + init_dependencies.append('https://github.com/SeattleTestbed/' + current_repo + ' ../DEPENDENCIES/' + current_repo) + + init_result = {} + for repo in os.listdir("../DEPENDENCIES"): + if os.path.isdir("../DEPENDENCIES" + os.sep + repo): + for line in read_initconfig("../DEPENDENCIES"+ os.sep + repo + os.sep +"scripts/config_initialize.txt"): + url = line.strip() + if url not in init_dependencies: + try: + init_result[repo].append(url) + except KeyError: + init_result[repo] = [url] + + print "Additionally required in config_initialize.txt\n" + + for dependency,config in init_result.items(): + print "# Additionally required by dependency " + dependency + ":" + for setting in config: + print setting + + build_dependencies = read_buildconfig('config_build.txt',current_repo) + + build_result = {} + for repo in os.listdir("../DEPENDENCIES"): + if os.path.isdir("../DEPENDENCIES" + os.sep + repo): + for line in read_buildconfig("../DEPENDENCIES"+ os.sep + repo + os.sep +"scripts/config_build.txt",repo): + if line.strip() not in build_dependencies: + try: + build_result[repo].append(line) + except KeyError: + build_result[repo] = [line] + + print "\nAdditionally required in config_build.txt\n" + + for dependency,config in build_result.items(): + print "# Additionally required by dependency " + dependency + ":" + for setting in config: + print setting + +if __name__ == '__main__': + main() From 44669a2051ab3e138052ab2baca6a735553363bd Mon Sep 17 00:00:00 2001 From: Xuefeng Date: Fri, 22 May 2015 11:10:44 -0400 Subject: [PATCH 4/4] Fix a issue regarding reading build_config --- check_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_config.py b/check_config.py index b95fa51..2963e28 100644 --- a/check_config.py +++ b/check_config.py @@ -33,7 +33,7 @@ def read_buildconfig(filename, repo): continue if line.startswith("./"): line = line.replace("./","DEPENDENCIES"+ os.sep + repo + os.sep) - content.append(line.split()[0].strip()) + content.append(line.strip()) return content def main():