| 1 |
import os, sys, shutil |
|---|
| 2 |
|
|---|
| 3 |
def copyhtml(src, dest): |
|---|
| 4 |
for f in os.listdir(src): |
|---|
| 5 |
if os.path.isdir(os.path.join(src, f)): |
|---|
| 6 |
if not os.path.exists(os.path.join(dest, f)): |
|---|
| 7 |
os.mkdir(os.path.join(dest, f)) |
|---|
| 8 |
copyhtml(os.path.join(src, f), os.path.join(dest, f)) |
|---|
| 9 |
else: |
|---|
| 10 |
shutil.copy(os.path.join(src, f), os.path.join(dest, f)) |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
domainHost = raw_input("what is your domain host name ?") |
|---|
| 15 |
if not domainHost: |
|---|
| 16 |
domainHost = "localhost" |
|---|
| 17 |
|
|---|
| 18 |
pictures = raw_input("where do you have your pictures ?") |
|---|
| 19 |
if not os.path.isdir(pictures): |
|---|
| 20 |
print "You must specify the path to your pictures" |
|---|
| 21 |
sys.exit(0) |
|---|
| 22 |
|
|---|
| 23 |
apache = raw_input("where is apache installed ?") |
|---|
| 24 |
if not os.path.isdir(apache): |
|---|
| 25 |
apache = r"C:\Program Files\Apache Group\Apache2" |
|---|
| 26 |
|
|---|
| 27 |
if not os.path.exists(os.path.join(apache, "conf", "httpd.conf")): |
|---|
| 28 |
print "apache instalation not found" |
|---|
| 29 |
apache="" |
|---|
| 30 |
|
|---|
| 31 |
website = raw_input("where do you want to install the files for the website?") |
|---|
| 32 |
if not website: |
|---|
| 33 |
print "You must specify the path for the website" |
|---|
| 34 |
sys.exit(0) |
|---|
| 35 |
|
|---|
| 36 |
print |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
html_files = os.path.join(os.path.split(__file__)[0], "publish_files") |
|---|
| 41 |
pwh = os.path.join(os.path.split(__file__)[0], "milas", "pwh") |
|---|
| 42 |
|
|---|
| 43 |
if not os.path.exists(website): |
|---|
| 44 |
os.mkdir(website) |
|---|
| 45 |
try: |
|---|
| 46 |
copyhtml(html_files, website) |
|---|
| 47 |
print "copy site files to", website |
|---|
| 48 |
except Exception, e: |
|---|
| 49 |
print "not all files from publish_files were copied to website folder" |
|---|
| 50 |
print str(e) |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
try: |
|---|
| 56 |
import mod_python |
|---|
| 57 |
shutil.copy(os.path.join(pwh, "mod_python_changes", "psp.py"), os.path.join(mod_python.__path__[0], "psp.py")) |
|---|
| 58 |
print "customize mod_python/psp.py" |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
except Exception, e: |
|---|
| 68 |
print "\ncould not customize mod_python, is it installed?. Install and run this again", str(e) |
|---|
| 69 |
print |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
if apache: |
|---|
| 75 |
awcfg = """ |
|---|
| 76 |
|
|---|
| 77 |
#Automaticaly added by WCatalog install: |
|---|
| 78 |
|
|---|
| 79 |
%sLoadModule python_module modules/mod_python.so |
|---|
| 80 |
|
|---|
| 81 |
Alias /media/ "%s/" |
|---|
| 82 |
Alias /media "%s" |
|---|
| 83 |
<Directory %s> |
|---|
| 84 |
AddHandler mod_python .asp .asp_ .psp .psp_ .* * |
|---|
| 85 |
PythonHandler mod_python.psp |
|---|
| 86 |
PythonAutoReload Off |
|---|
| 87 |
PythonDebug Off |
|---|
| 88 |
AllowOverride None |
|---|
| 89 |
#Options Indexes MultiViews |
|---|
| 90 |
DirectoryIndex WIndex.asp index.asp index.html index.htm |
|---|
| 91 |
Order allow,deny |
|---|
| 92 |
Allow from all |
|---|
| 93 |
</Directory> |
|---|
| 94 |
<Directory %s/restrict/> |
|---|
| 95 |
AllowOverride None |
|---|
| 96 |
Options none |
|---|
| 97 |
Order deny,allow |
|---|
| 98 |
Deny from all |
|---|
| 99 |
</Directory> |
|---|
| 100 |
|
|---|
| 101 |
Alias /pictures "%s" |
|---|
| 102 |
<Directory "%s"> |
|---|
| 103 |
AllowOverride None |
|---|
| 104 |
Options None |
|---|
| 105 |
Order Allow,Deny |
|---|
| 106 |
Allow from All |
|---|
| 107 |
</Directory> |
|---|
| 108 |
|
|---|
| 109 |
""" |
|---|
| 110 |
|
|---|
| 111 |
try: |
|---|
| 112 |
acfg = os.path.join(apache, "conf", "httpd.conf") |
|---|
| 113 |
f = open(acfg) |
|---|
| 114 |
fcontent = f.read() |
|---|
| 115 |
f.close() |
|---|
| 116 |
|
|---|
| 117 |
what = "LoadModule python_module modules/mod_python.so" |
|---|
| 118 |
domodpy = "" |
|---|
| 119 |
if fcontent.find(what) >= 0: |
|---|
| 120 |
domodpy = "#" |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
f = open(acfg, "w") |
|---|
| 125 |
f.write(fcontent) |
|---|
| 126 |
f.write("\n\n\n") |
|---|
| 127 |
f.write(awcfg % (domodpy, website, website, website, website, pictures, pictures)) |
|---|
| 128 |
f.close() |
|---|
| 129 |
print "edit apache/conf/httpd.conf" |
|---|
| 130 |
except Exception, e: |
|---|
| 131 |
print "\ncould not edit apache/conf/httpd.conf because", str(e) |
|---|
| 132 |
print |
|---|
| 133 |
else: |
|---|
| 134 |
print "apache not found so httpd.conf not updated for WCatalog" |
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
if website: |
|---|
| 139 |
try: |
|---|
| 140 |
if not os.path.exists(os.path.join(website, "restrict", "config_orig.py")): |
|---|
| 141 |
shutil.copy(os.path.join(website, "restrict", "config.py"), os.path.join(website, "restrict", "config_orig.py")) |
|---|
| 142 |
else: |
|---|
| 143 |
shutil.copy(os.path.join(website, "restrict", "config.py"), os.path.join(website, "restrict", "config_old.py")) |
|---|
| 144 |
ccfg = os.path.join(website, "restrict", "config.py") |
|---|
| 145 |
f = open(ccfg) |
|---|
| 146 |
fcontent = f.read() |
|---|
| 147 |
f.close() |
|---|
| 148 |
fcontent = fcontent.replace("<PATH TO YOUR PICTURES FOLDER>", pictures) |
|---|
| 149 |
fcontent = fcontent.replace("<YOUR HOST NAME>", domainHost) |
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
f = open(ccfg, "w") |
|---|
| 153 |
f.write(fcontent) |
|---|
| 154 |
f.close() |
|---|
| 155 |
print "edit WCatalog/config.py" |
|---|
| 156 |
except Exception, e: |
|---|
| 157 |
print "\ncould not edit WCatalog/config.py because", str(e) |
|---|
| 158 |
print |
|---|
| 159 |
else: |
|---|
| 160 |
print "wcatalog website folder not found so config.py not updated for pictures" |
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
print """ |
|---|
| 165 |
DONE |
|---|
| 166 |
|
|---|
| 167 |
- open config.py from %s to finish up configuring the application, ex: set passwords, specify email address, |
|---|
| 168 |
specify a music collection folder and others |
|---|
| 169 |
- if you do specify other catalogs besides pictures (ex. a music collection), you will also need to configure apache |
|---|
| 170 |
httpd.conf for it |
|---|
| 171 |
|
|---|
| 172 |
- restart apache (double click the little apache icon on the right bottom side of your screen) |
|---|
| 173 |
|
|---|
| 174 |
- open your browser and go to http://localhost/media/ to test it |
|---|
| 175 |
|
|---|
| 176 |
""" |
|---|
| 177 |
|
|---|