Browse Source

Add README file

update scripts for generating CGI scripts
master
duncan.parkes 17 years ago
parent
commit
6081b22754
3 changed files with 18 additions and 12 deletions
  1. +4
    -0
      python_scrapers/README
  2. +5
    -0
      python_scrapers/createCGI.sh
  3. +9
    -12
      python_scrapers/generateCGIScripts.py

+ 4
- 0
python_scrapers/README View File

@@ -0,0 +1,4 @@
In order to generate the contents of the CGI directory (../CGI)
run

./createCGI.sh

+ 5
- 0
python_scrapers/createCGI.sh View File

@@ -7,3 +7,8 @@ echo Running generateCGIScripts
python generateCGIScripts.py python generateCGIScripts.py


svn add ../CGI/* svn add ../CGI/*

echo Committing changes to svn
(cd ../CGI ; svn commit -m "Removing and regenerating CGI directory")

echo Done

+ 9
- 12
python_scrapers/generateCGIScripts.py View File

@@ -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

Loading…
Cancel
Save