From 50bbbb432dceb56c3745ca2de82c595d6d0eef28 Mon Sep 17 00:00:00 2001 From: "duncan.parkes" Date: Tue, 3 Apr 2007 00:50:48 +0000 Subject: [PATCH] Add README file update scripts for generating CGI scripts --- trunk/python_scrapers/README | 4 ++++ trunk/python_scrapers/createCGI.sh | 5 +++++ trunk/python_scrapers/generateCGIScripts.py | 21 +++++++++------------ 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 trunk/python_scrapers/README diff --git a/trunk/python_scrapers/README b/trunk/python_scrapers/README new file mode 100644 index 0000000..b3030a2 --- /dev/null +++ b/trunk/python_scrapers/README @@ -0,0 +1,4 @@ +In order to generate the contents of the CGI directory (../CGI) +run + +./createCGI.sh diff --git a/trunk/python_scrapers/createCGI.sh b/trunk/python_scrapers/createCGI.sh index 8e989bc..28c9a95 100755 --- a/trunk/python_scrapers/createCGI.sh +++ b/trunk/python_scrapers/createCGI.sh @@ -7,3 +7,8 @@ echo Running generateCGIScripts python generateCGIScripts.py svn add ../CGI/* + +echo Committing changes to svn +(cd ../CGI ; svn commit -m "Removing and regenerating CGI directory") + +echo Done diff --git a/trunk/python_scrapers/generateCGIScripts.py b/trunk/python_scrapers/generateCGIScripts.py index d66e715..0ccd95e 100755 --- a/trunk/python_scrapers/generateCGIScripts.py +++ b/trunk/python_scrapers/generateCGIScripts.py @@ -1,14 +1,12 @@ #!/usr/bin/python list_of_sites_filename = "PublicAccessSites.csv" +other_files_to_copy_filename = "OtherFilesToCopy.csv" template_filename = "CGITemplate" python_location = "/usr/bin/python" cgi_dir = "../CGI/" -# this should be a config file -other_files = ["PublicAccess.py", "PlanningUtils.py", "SouthOxfordshireParser.py", "SouthOxfordshire.cgi"] - import csv from os import chmod from shutil import copyfile @@ -16,11 +14,6 @@ from shutil import copyfile list_of_sites_file = open(list_of_sites_filename) csv_reader = csv.DictReader(list_of_sites_file, quoting=csv.QUOTE_ALL, skipinitialspace=True) -# svn rm the cgi directory - -# create the cgi directory - - # create cgi files and write them in the cgi directory template_contents = open(template_filename).read() @@ -29,7 +22,6 @@ template = "#!" + python_location +"\n\n" + template_contents for site_dict in csv_reader: filename = cgi_dir + "%s.cgi" %site_dict["authority_short_name"] contents = template %site_dict - this_file = open(filename, "w") print "Writing %s" %filename this_file.write(contents) @@ -39,10 +31,16 @@ for site_dict in csv_reader: # copy across other files that are needed # these should probably come from a config file -for filename in other_files: + +other_files_to_copy = open(other_files_to_copy_filename) +other_files_csv_reader = csv.DictReader(other_files_to_copy, quoting=csv.QUOTE_ALL, skipinitialspace=True) + +for file_dict in other_files_csv_reader: + print file_dict + filename = file_dict["filename"] copyfile(filename, cgi_dir+filename) + chmod(cgi_dir+filename, int(file_dict["permissions"])) - # write a README to warn people not to svn add stuff to CGI directory readme_message = """ WARNING - this directory is only for generated files @@ -54,5 +52,4 @@ readme_file = open(cgi_dir+ "README", "w") readme_file.write(readme_message) readme_file.close() -# svn add the cgi directory and its contents