Automatically exported from code.google.com/p/planningalerts
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.5 KiB

  1. #!/usr/bin/python
  2. list_of_sites_filename = "PublicAccessSites.csv"
  3. template_filename = "CGITemplate"
  4. python_location = "/usr/bin/python"
  5. cgi_dir = "../CGI/"
  6. # this should be a config file
  7. other_files = ["PublicAccess.py", "PlanningUtils.py", "SouthOxfordshireParser.py", "SouthOxfordshire.cgi"]
  8. import csv
  9. from os import chmod
  10. from shutil import copyfile
  11. list_of_sites_file = open(list_of_sites_filename)
  12. csv_reader = csv.DictReader(list_of_sites_file, quoting=csv.QUOTE_ALL, skipinitialspace=True)
  13. # svn rm the cgi directory
  14. # create the cgi directory
  15. # create cgi files and write them in the cgi directory
  16. template_contents = open(template_filename).read()
  17. template = "#!" + python_location +"\n\n" + template_contents
  18. for site_dict in csv_reader:
  19. filename = cgi_dir + "%s.cgi" %site_dict["authority_short_name"]
  20. contents = template %site_dict
  21. this_file = open(filename, "w")
  22. print "Writing %s" %filename
  23. this_file.write(contents)
  24. this_file.close()
  25. chmod(filename, 0755)
  26. # copy across other files that are needed
  27. # these should probably come from a config file
  28. for filename in other_files:
  29. copyfile(filename, cgi_dir+filename)
  30. # write a README to warn people not to svn add stuff to CGI directory
  31. readme_message = """
  32. WARNING - this directory is only for generated files
  33. and files which are automatically copied in.
  34. Anything manually added here will be svn deleted.
  35. """
  36. readme_file = open(cgi_dir+ "README", "w")
  37. readme_file.write(readme_message)
  38. readme_file.close()
  39. # svn add the cgi directory and its contents