Преглед на файлове

Add README file

update scripts for generating CGI scripts
master
duncan.parkes преди 17 години
родител
ревизия
6081b22754
променени са 3 файла, в които са добавени 18 реда и са изтрити 12 реда
  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 Целия файл

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

./createCGI.sh

+ 5
- 0
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

+ 9
- 12
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

Зареждане…
Отказ
Запис