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

temp = open('/tmp/logx','w')
print >> temp,'launch entered'
temp.close()

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

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

print 'Content-Type:text/html\n\n'
log = open('/tmp/logl','w')
try:
    print >>log,'launch log opened'
    bundle_dir = activity.get_bundle_path()
    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
        print >>log,'launch', activity, bundle_dir, bundle, bundle_pth
        fout = open('/tmp/'+activity,'w')
        fout.write(bundle_pth)
        fout.close()
        try:
            subprocess.call('sugar-launch '+activity,shell=True)
        except:
            print >> log, 'sugar launch failed',sys.exc_info()[:2]
    else:
        print >> log, 'no activity'
    print >>log,'sugar activity launched', activity
except:
    print >>log, 'launch.py failed', sys.exc_info()[:2]
log.close()