From 4d4c6604b932b8d7be477a0151f651944e739c30 Mon Sep 17 00:00:00 2001 From: C. Scott Ananian Date: Wed, 19 Dec 2007 23:11:34 +0000 Subject: Add new p_a_extra_info magic; install activity.py helper when we run. Some activities want to put crazy custom stuff into their activity.info file; the new pippy_activity_extra_info() method gives them the backdoor they need to do this. I also renamed pippy_activity_extrafiles to pippy_activity_extra_files for consistency. Also, Pippy and Chat (and other activities that subclass ViewSourceActivity) want to have the stock pippy activity.py file available when they run, so that the imports work properly. Put it there when you click 'run'. --- (limited to 'pippy_app.py') diff --git a/pippy_app.py b/pippy_app.py index 7fdc1ff..1e7bc56 100644 --- a/pippy_app.py +++ b/pippy_app.py @@ -249,6 +249,7 @@ class PippyActivity(ViewSourceActivity): self._vte.feed("\x1B[H\x1B[J\x1B[0;39m") def gobutton_cb(self, button): + from shutil import copy2 self.stopbutton_cb(button) # try stopping old code first. self._reset_vte() @@ -257,6 +258,9 @@ class PippyActivity(ViewSourceActivity): pippy_app_name = '%s/tmp/pippy_app.py' % self.get_activity_root() self._write_text_buffer(pippy_app_name) + # write activity.py here too, to support pippy-based activities. + copy2('%s/activity.py' % get_bundle_path(), + '%s/tmp/activity.py' % self.get_activity_root()) self._pid = self._vte.fork_command \ (command="/bin/sh", @@ -597,6 +601,7 @@ icon = activity-icon activity_version = %(version)d mime_types = %(mime_types)s show_launcher = yes +%(extra_info)s """ PIPPY_ICON = \ @@ -632,7 +637,7 @@ PIPPY_DEFAULT_ICON = \ def pippy_activity_version(): """Returns the version number of the generated activity bundle.""" return 14 -def pippy_activity_extrafiles(): +def pippy_activity_extra_files(): """Returns a map of 'extra' files which should be included in the generated activity bundle.""" # Cheat here and generate the map from the fs contents. @@ -695,12 +700,13 @@ def main(): # things we look for: bundle_info = { 'version': 1, - 'extrafiles': {}, + 'extra_files': {}, 'news': 'No news.', 'icon': PIPPY_DEFAULT_ICON, 'class': 'activity.VteActivity', 'bundle_id': ('org.laptop.pippy.%s' % pytitle), 'mime_types': '', + 'extra_info': '', } # are any of these things in the module? try_import = False @@ -730,13 +736,13 @@ def main(): bundle_info['title'] = title bundle_info['pytitle'] = pytitle # put 'extra' files in place. - extrafiles = { + extra_files = { 'activity/activity.info': ACTIVITY_INFO_TEMPLATE % bundle_info, 'activity/activity-icon.svg': bundle_info['icon'], 'NEWS': bundle_info['news'], } - extrafiles.update(bundle_info['extrafiles']) - for path, contents in extrafiles.items(): + extra_files.update(bundle_info['extra_files']) + for path, contents in extra_files.items(): # safety first! assert '..' not in path dirname, filename = os.path.split(path) -- cgit v0.9.1