Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/cgi-bin/setUpSubject.py
blob: edfb649e2bb1070c08d1dbd96a69d7215876eec2 (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
31
32
33
34
#!/usr/bin/python
import os, sys, subprocess
import cgi, cgitb
from path import path
from activities import getFile

log = open('/tmp/logsetup','w')
basepth = path('content')
cgitb.enable(display=True)
print 'Content-Type:text/html\n\n'
pth = basepth / 'subjects.js'
fin = open(pth,'r')
txt = fin.read()
fin.close()
lines = txt.split('\n')
for line in lines:
    try:
        entry = eval(line)[0]
    except:
        continue
    print >> log, line, len(entry)
    print >> log, entry[0],entry[1],entry[2]
    subject = entry[1]
    tgtpth = basepth / subject
    print >> log, 'tgtpth', tgtpth
    if not tgtpth.exists():
        subprocess.call('mkdir ' + tgtpth,shell=True)
        result = getFile(tgtpth, '*.js')
        result = getFile(tgtpth, '*.html')
        result = getFile(tgtpth,'*.png')
        result = getFile(tgtpth,'*.gif')
        print >> log, 'loaded',tgtpth
print >> log, 'done'
log.close()