Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/cgi-bin/fetchFile.py
blob: 295d427704f7a14c468ca997065ad1e939f93098 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python
import os, sys, subprocess
import shutil
import cgi, cgitb
from BeautifulSoup import BeautifulSoup
from path import path
cgitb.enable(display=True)
print 'Content-Type:text/html\n\n'
log = open('/tmp/fetchlog','w')
form = cgi.FieldStorage()
f = form.getfirst('openfile', default='none given')
fpth = path(f)
print >> log, 'f=', fpth
srcpth = fpth.parent
print >> log, 'srcpth=', srcpth
fpth = srcpth / 'source.txt' 
print >> log, 'f=',fpth, srcpth, fpth
fin = open(fpth, 'r')
txt = fin.read()
fin.close()
print >> log, 'copy images'
#copy images to local store
dst = 'imgs'
shutil.rmtree(dst)
shutil.copytree(srcpth, dst)
print >> log, 'make soup', len(txt)
soup = BeautifulSoup(txt)
print soup.prettify()
print >> log, 'done'
log.close()