Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@laptop.org>2008-10-31 22:47:10 (GMT)
committer C. Scott Ananian <cscott@laptop.org>2008-11-03 22:14:10 (GMT)
commitc120c235d06b123a3e9aeff0c4d55d23e2d01b44 (patch)
treef486434829a3c825723274405de133ead64210f0 /activity.py
parentc7e4ad54d85de7c9b24238b452d0092eaa35c683 (diff)
Support directly launching activity from the command-line.
Diffstat (limited to 'activity.py')
-rwxr-xr-x[-rw-r--r--]activity.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/activity.py b/activity.py
index ff728cc..9e740b1 100644..100755
--- a/activity.py
+++ b/activity.py
@@ -1,4 +1,6 @@
-# Copyright 2007 One Laptop per Child Association, Inc.
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# Copyright 2007-8 One Laptop per Child Association, Inc.
# Written by C. Scott Ananian <cscott@laptop.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -174,3 +176,26 @@ class PyGameActivity(ViewSourceActivity):
# hide the buttons we don't use.
toolbar.share.hide() # this should share bundle.
toolbar.keep.hide()
+
+def _main():
+ """Launch this activity from the command line."""
+ from sugar.activity import activityfactory
+ from sugar.activity.registry import ActivityInfo
+ from sugar.bundle.activitybundle import ActivityBundle
+ import os, os.path
+ ab = ActivityBundle(os.path.dirname(__file__) or '.')
+ ai = ActivityInfo(name=ab.get_name(),
+ icon=None,
+ bundle_id=ab.get_bundle_id(),
+ version=ab.get_activity_version(),
+ path=ab.get_path(),
+ show_launcher=ab.get_show_launcher(),
+ command=ab.get_command(),
+ favorite=True,
+ installation_time=ab.get_installation_time(),
+ position_x=0, position_y=0)
+ env = activityfactory.get_environment(ai)
+ cmd_args = activityfactory.get_command(ai)
+ os.execvpe(cmd_args[0], cmd_args, env)
+
+if __name__=='__main__': _main()