Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-03-27 13:21:23 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-03-27 13:21:23 (GMT)
commit4cb54af5da75c008e172582a615a4c7fffaaf3f4 (patch)
treef3ce01d58b2c349edd2e094945370c73808da069
parent3cc961513e7d574eebfe69ded1b5063fa0af5fa5 (diff)
enable reloading of plugins
-rw-r--r--TurtleArt/tapalette.py2
-rw-r--r--TurtleArt/tawindow.py4
-rw-r--r--TurtleArtActivity.py47
3 files changed, 31 insertions, 22 deletions
diff --git a/TurtleArt/tapalette.py b/TurtleArt/tapalette.py
index da80386..27a3956 100644
--- a/TurtleArt/tapalette.py
+++ b/TurtleArt/tapalette.py
@@ -141,7 +141,6 @@ class Palette():
palette_blocks.insert(i, [])
block_colors.insert(i, self._colors)
else:
- # debug_output('Palette %s already defined' % (self._name))
return
# Special name entry is needed for help hover mechanism
@@ -236,6 +235,7 @@ class Palette():
block.set_hidden()
block.add_block()
+
def make_palette(palette_name, colors=None, help_string=None, position=None):
""" Palette helper function """
if colors is None:
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 0d0ce49..499eefb 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -301,13 +301,13 @@ class TurtleArtWindow():
try:
exec f in globals(), plugins
self._plugins.append(plugins.values()[0](self))
- debug_output('successfully importing %s' % (plugin_class),
+ debug_output('Successfully importing %s' % (plugin_class),
self.running_sugar)
# Add the icon dir to the icon_theme search path
self._add_plugin_icon_dir(os.path.join(self._get_plugin_home(),
plugin_dir))
except ImportError, e:
- debug_output('failed to import %s: %s' % (plugin_class, str(e)),
+ debug_output('Failed to import %s: %s' % (plugin_class, str(e)),
self.running_sugar)
def _add_plugin_icon_dir(self, dirname):
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index ae70206..e015389 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -211,11 +211,8 @@ class TurtleArtActivity(activity.Activity):
def _load_ta_plugin(self, dsobject):
''' Load a TA plugin from the datastore. '''
- try:
- _logger.debug('Opening %s ' % dsobject.file_path)
- self.read_file(dsobject.file_path, run_it=False, plugin=True)
- except:
- _logger.debug("Couldn't open %s" % dsobject.file_path)
+ _logger.debug('Opening %s ' % dsobject.file_path)
+ self.read_file(dsobject.file_path, run_it=False, plugin=True)
def do_load_python_cb(self, button):
''' Load Python code from the Journal. '''
@@ -854,22 +851,28 @@ class TurtleArtActivity(activity.Activity):
elif not file_info.has_option('Plugin', 'name'):
_logger.debug('Required open name not found in \
Plugin section of plugin.info file.')
- self.tw.showlabel('status',
- label=_('Plugin %s could not be installed.'))
+ self.tw.showlabel(
+ 'status', label=_('Plugin could not be installed.'))
else:
plugin_name = file_info.get('Plugin', 'name')
- _logger.debug(plugin_name)
+ _logger.debug('Plugin name: %s' % (plugin_name))
tmp_path = os.path.join(tmpdir, plugin_name)
plugin_path = os.path.join(activity.get_bundle_path(), 'plugins')
- status = subprocess.call(['mv', tmp_path, plugin_path + '/'])
+ status = subprocess.call(['cp', '-r', tmp_path, plugin_path + '/'])
if status == 0:
- _logger.debug('Plugin %s installed successfully.')
+ _logger.debug('Plugin installed successfully.')
if self.has_toolbarbox:
+ create_palette = False
+ if file_info.has_option('Plugin', 'palette'):
+ palette_name = file_info.get('Plugin', 'palette')
+ if not palette_name in palette_names:
+ create_palette = True
+ _logger.debug('Initializing plugin...')
self.tw.init_plugin(plugin_name)
self.tw._plugins[-1].setup()
self.tw.load_media_shapes()
- if file_info.has_option('Plugin', 'palette'):
- palette_name = file_info.get('Plugin', 'palette')
+ if create_palette:
+ _logger.debug('Creating plugin palette...')
i = palette_names.index('trash')
self.palette_buttons.insert(i - 1,
self._radio_button_factory(
@@ -882,18 +885,24 @@ Plugin section of plugin.info file.')
position=i - 1))
self.tw.palettes.insert(i - 1, [])
self.tw.palette_sprs.insert(i - 1, [None, None])
- # Finally, we need to change the index
- # associated with the Trash Palette
+ # We need to change the index associated with the
+ # Trash Palette Button.
i = palette_names.index('trash')
self.palette_buttons[i].connect(
'clicked', self.do_palette_buttons_cb, i)
else:
- self.tw.showlabel('status',
- label=_('Please restart Turtle Art \
-in order to use the plugin.'))
+ _logger.debug('Palette already exists... \
+skipping insert')
else:
- self.tw.showlabel(
- 'status', label=_('Plugin could not be installed.'))
+ self.tw.showlabel('status',
+ label=_('Please restart Turtle Art \
+in order to use the plugin.'))
+ else:
+ self.tw.showlabel(
+ 'status', label=_('Plugin could not be installed.'))
+ status = subprocess.call(['rm', '-r', tmp_path])
+ if status != 0:
+ _logger.debug('Problems cleaning up tmp_path.')
def read_file(self, file_path, run_it=True, plugin=False):
''' Open a project or plugin and then run it. '''