Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-11-02 17:49:21 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-11-02 17:49:21 (GMT)
commite00cecf9dc24f98b760c3e1a6e5122547dd994f9 (patch)
tree3d466db0637f36c6b322567a03d00d91c9639994
parentdeb4c05b15758d945de4f56d6ea5564597342060 (diff)
Add a script to setup the bundle.
Get the activity to work, it's not right yet, we are just showing a toplevel window.
-rwxr-xr-xTamTam.py36
-rwxr-xr-xsetup.py105
2 files changed, 111 insertions, 30 deletions
diff --git a/TamTam.py b/TamTam.py
index a3787cc..dc409cd 100755
--- a/TamTam.py
+++ b/TamTam.py
@@ -52,35 +52,11 @@ class TamTam(Activity):
def __init__(self):
Activity.__init__(self)
- def do_quit(event, param):
- CSoundClient.sendText('off()')
- print 'do_quit() waiting'
- #we know that quitting doesn't really work
- time.sleep(0.5)
- os.kill(pid, signal.SIGKILL)
- time.sleep(0.3)
- os.wait()
- print '... phew!'
-
- try :
- pid = os.fork()
-
- if pid > 0 :
- time.sleep(1)
- CSoundClient.initialize()
- tamtam = StandAlonePlayer()
- tamtam.connect('destroy', do_quit, pid)
- self.add(tamtam)
- tamtam.show()
-
- else:
- server = CsoundServerMult( ( CSoundConstants.SERVER_ADDRESS, CSoundConstants.SERVER_PORT ) )
- server.interpret()
-
- except OSError, e:
- print >>sys.stderr, "fork failed: %d (%s)" % (e.errno, e.strerror)
- sys.exit(1)
+ CSoundClient.initialize()
+ tamtam = StandAlonePlayer()
+ #tamtam.connect('destroy', self.do_quit)
+ #self.add(tamtam)
+ tamtam.show()
- def do_quit(self, event, app):
+ def do_quit(self):
del app
-
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..cc36d96
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,105 @@
+#!/usr/bin/python
+
+# Copyright (C) 2006, Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import sys
+import os
+import zipfile
+
+from sugar.activity.bundle import Bundle
+
+class SvnFileList(list):
+ def __init__(self):
+ f = os.popen('svn list -R')
+ for line in f.readlines():
+ filename = line.strip()
+ if os.path.isfile(filename):
+ self.append(filename)
+ f.close()
+
+class GitFileList(list):
+ def __init__(self):
+ f = os.popen('git-ls-files')
+ for line in f.readlines():
+ filename = line.strip()
+ if not filename.startswith('.'):
+ self.append(filename)
+ f.close()
+
+def get_source_path():
+ return os.path.dirname(os.path.abspath(__file__))
+
+def get_activities_path():
+ path = os.path.expanduser('~/Activities')
+ if not os.path.isdir(path):
+ os.mkdir(path)
+ return path
+
+def get_bundle_dir():
+ bundle_name = os.path.basename(get_source_path())
+ return bundle_name + '.activity'
+
+def get_bundle_path():
+ return os.path.join(get_activities_path(), get_bundle_dir())
+
+def print_help():
+ print 'Usage: \n\
+setup.py dev - setup for development \n\
+setup.py package - create a bundle package \n\
+setup.py help - print this message \n\
+'
+
+def setup_dev():
+ bundle_path = get_bundle_path()
+ try:
+ os.symlink(get_source_path(), bundle_path)
+ except OSError:
+ if os.path.islink(bundle_path):
+ print 'ERROR - The bundle has been already setup for development.'
+ else:
+ print 'ERROR - A bundle with the same name is already installed.'
+
+def build_package():
+ orig_path = os.getcwd()
+ os.chdir(get_source_path())
+
+ if os.path.isdir('.git'):
+ file_list = GitFileList()
+ elif os.path.isdir('.svn'):
+ file_list = SvnFileList()
+ else:
+ print 'ERROR - The command works only with git or svn repositories.'
+
+ bundle = Bundle(get_source_path())
+
+ zipname = '%s-%d.zip' % (bundle.get_name(), bundle.get_activity_version())
+ bundle_zip = zipfile.ZipFile(zipname, 'w')
+
+ for filename in file_list:
+ arcname = os.path.join(get_bundle_dir(), filename)
+ bundle_zip.write(filename, arcname)
+
+ bundle_zip.close()
+
+ os.chdir(orig_path)
+
+if len(sys.argv) < 2 or sys.argv[1] == 'help':
+ print_help()
+elif sys.argv[1] == 'dev':
+ setup_dev()
+elif sys.argv[1] == 'package':
+ build_package()