Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/cgi-bin/launch.py
blob: 05e7a8b6abbcf0d0e0160927fa7704080690f683 (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
#!/usr/bin/python

import sys
import cgi, cgitb
import subprocess
from sugar.activity import activity
from activities import copyFile

sys.stderr = sys.stdout
cgitb.enable(display=True)

print 'Content-Type:text/html\n\n'
log = open('/tmp/logl','w')
print >>log,'launch log opened'
bundle_dir = activity.get_bundle_path()
form = cgi.FieldStorage()
activity = form.getfirst('activity', default='')
print >> log, 'activity', len(activity), activity
if len(activity)>0:
    bundle = form.getfirst('bundle', default='')
    bundle_pth = bundle_dir + '/' + bundle
    #perform actions based on which activity 
    if activity == 'Wordsearch':
        copyFile(bundle_pth,'/home/olpc/Activities/Wordsearch.activity/wordlist/sample.txt')
        service_name = 'ch.tea.Wordsearch'
    print >>log,'launch', activity, bundle
    subprocess.call('sugar-launch '+service_name,shell=True)
    print >>log,'sugar-launch'
else:
    print >> log, 'no activity'
log.close()