|
@@ -1,14 +1,12 @@ |
|
|
#!/usr/bin/python |
|
|
#!/usr/bin/python |
|
|
|
|
|
|
|
|
list_of_sites_filename = "PublicAccessSites.csv" |
|
|
list_of_sites_filename = "PublicAccessSites.csv" |
|
|
|
|
|
other_files_to_copy_filename = "OtherFilesToCopy.csv" |
|
|
template_filename = "CGITemplate" |
|
|
template_filename = "CGITemplate" |
|
|
python_location = "/usr/bin/python" |
|
|
python_location = "/usr/bin/python" |
|
|
|
|
|
|
|
|
cgi_dir = "../CGI/" |
|
|
cgi_dir = "../CGI/" |
|
|
|
|
|
|
|
|
# this should be a config file |
|
|
|
|
|
other_files = ["PublicAccess.py", "PlanningUtils.py", "SouthOxfordshireParser.py", "SouthOxfordshire.cgi"] |
|
|
|
|
|
|
|
|
|
|
|
import csv |
|
|
import csv |
|
|
from os import chmod |
|
|
from os import chmod |
|
|
from shutil import copyfile |
|
|
from shutil import copyfile |
|
@@ -16,11 +14,6 @@ from shutil import copyfile |
|
|
list_of_sites_file = open(list_of_sites_filename) |
|
|
list_of_sites_file = open(list_of_sites_filename) |
|
|
csv_reader = csv.DictReader(list_of_sites_file, quoting=csv.QUOTE_ALL, skipinitialspace=True) |
|
|
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 |
|
|
# create cgi files and write them in the cgi directory |
|
|
template_contents = open(template_filename).read() |
|
|
template_contents = open(template_filename).read() |
|
|
|
|
|
|
|
@@ -29,7 +22,6 @@ template = "#!" + python_location +"\n\n" + template_contents |
|
|
for site_dict in csv_reader: |
|
|
for site_dict in csv_reader: |
|
|
filename = cgi_dir + "%s.cgi" %site_dict["authority_short_name"] |
|
|
filename = cgi_dir + "%s.cgi" %site_dict["authority_short_name"] |
|
|
contents = template %site_dict |
|
|
contents = template %site_dict |
|
|
|
|
|
|
|
|
this_file = open(filename, "w") |
|
|
this_file = open(filename, "w") |
|
|
print "Writing %s" %filename |
|
|
print "Writing %s" %filename |
|
|
this_file.write(contents) |
|
|
this_file.write(contents) |
|
@@ -39,10 +31,16 @@ for site_dict in csv_reader: |
|
|
|
|
|
|
|
|
# copy across other files that are needed |
|
|
# copy across other files that are needed |
|
|
# these should probably come from a config file |
|
|
# 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) |
|
|
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 |
|
|
# write a README to warn people not to svn add stuff to CGI directory |
|
|
readme_message = """ |
|
|
readme_message = """ |
|
|
WARNING - this directory is only for generated files |
|
|
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.write(readme_message) |
|
|
readme_file.close() |
|
|
readme_file.close() |
|
|
|
|
|
|
|
|
# svn add the cgi directory and its contents |
|
|
|
|
|
|
|
|
|