Exemple #1
0
 def __init__(self, actionlist, paths, settings, output=sys.stdout):
     self.verbose = settings['verbose'] or settings['interactive']
     self.settings = settings
     self.output = output
     self._pubsub()
     data, warning = api.open_actionlist(self.verify_actionlist(actionlist))
     if formField.get_safe():
         if warning:
             raise safe.UnsafeError(warning)
     else:
         self.show_message(warning)
     report = api.apply_actions_to_photos(data['actions'], settings, \
                                                         paths=paths)
Exemple #2
0
 def show_frame(self):
     #do all application initialisation
     self.report = []
     self.init()
     api.init()
     #create frame
     frame = Frame(self.filename, None, -1, CONTEXT['app_title'])
     frame.menu_tools.Check(frame.menu_tools_safe.GetId(),
                            formField.get_safe())
     frame.CentreOnScreen()
     frame.Show()
     self.SetTopWindow(frame)
     frame.enable_collapse_automatic(self.settings['collapse_automatic'])
Exemple #3
0
 def __init__(self, actionlist, paths, settings, output=sys.stdout):
     self.verbose = settings['verbose'] or settings['interactive']
     self.settings = settings
     self.output = output
     self._pubsub()
     data, warning = api.open_actionlist(
         self.verify_actionlist(actionlist))
     if formField.get_safe():
         if warning:
             raise safe.UnsafeError(warning)
     else:
         self.show_message(warning)
     report = api.apply_actions_to_photos(data['actions'], settings, \
                                                         paths=paths)
Exemple #4
0
 def show_frame(self):
     #do all application initialisation
     self.init()
     api.init()
     #create frame
     frame = Frame(self.filename, None, -1, ct.TITLE)
     frame.menu_tools.Check(frame.menu_tools_safe.GetId(),
         formField.get_safe())
     frame.CentreOnScreen()
     frame.Show()
     self.SetTopWindow(frame)
     frame.enable_collapse_automatic(self.settings['collapse_automatic'])
     #delete splash
     self.splash.Hide()
     self.splash.Destroy()
     del self.splash
Exemple #5
0
def check_actionlist(actions, settings):
    """Verifies action list before executing. It checks whether:

    * the action list is not empty
    * all actions are not disabled
    * if there is a save action at the end or only file actions
    * overwriting images is forced

    :param actions: actions of the action list
    :type actions: list of :class:`core.models.Action`
    :param settings: execution settings
    :type settings: dictionary

    >>> settings = {'no_save':False}
    >>> check_actionlist([], settings) is None
    True
    >>> from actions import canvas, save
    >>> canvas_action = canvas.Action()
    >>> save_action = save.Action()
    >>> check_actionlist([canvas_action,save_action],
    ... {'no_save':False}) is None
    False
    >>> check_actionlist([canvas_action], settings) is None
    True
    >>> settings = {'no_save':True}
    >>> check_actionlist([canvas_action], settings) is None
    False
    >>> settings['overwrite_existing_images_forced']
    False

    .. see also:: :func:`check_actionlist_file_only`
    """
    #Check if there is something to do
    if actions == []:
        send.frame_show_error('%s %s' % (_('Nothing to do.'),
            _('The action list is empty.')))
        return None
    #Check if the actionlist is safe
    if formField.get_safe():
        warnings = assert_safe(actions)
        if warnings:
            send.frame_show_error('%s\n\n%s\n%s' % (
                ERROR_UNSAFE_ACTIONLIST_INTRO, warnings,
                ERROR_UNSAFE_ACTIONLIST_DISABLE_SAFE))
            return None
    #Skip disabled actions
    actions = [action for action in actions if action.is_enabled()]
    if actions == []:
        send.frame_show_error('%s %s' % (_('Nothing to do.'),
            _('There is no action enabled.')))
        return None
    #Check if there is a save statement
    last_action = actions[-1]
    if not (last_action.valid_last or check_actionlist_file_only(actions)\
            or settings['no_save']):
        send.frame_append_save_action(actions)
        return None
    #Check if overwrite is forced
    settings['overwrite_existing_images_forced'] = \
        (not settings['no_save']) and \
        actions[-1].is_overwrite_existing_images_forced()
    return actions
Exemple #6
0
            data, warnings = api.open_actionlist(filename)
        except KeyError, details:
            self.show_error(ERROR_INSTALL_ACTION\
                % exception_to_unicode(details, WX_ENCODING))
            return
        except:
            self.show_error(api.ERROR_INCOMPATIBLE_ACTIONLIST % ct.INFO)
            return
        if data['invalid labels']:
            self.show_message('\n'.join([
            _('This action list was made by a different %(name)s version.')\
                % ct.INFO + '\n\n' + \
            WARNING_LOST_VALUES % ct.INFO + '\n',
            '\n'.join(data['invalid labels'])]))
        if warnings:
            if formField.get_safe():
                self.show_error('%s\n\n%s\n%s' % (
                    api.ERROR_UNSAFE_ACTIONLIST_INTRO, warnings,
                    api.ERROR_UNSAFE_ACTIONLIST_DISABLE_SAFE))
                return
            else:
                wx.CallAfter(self.show_error, '%s\n\n%s\n%s' % (
                    api.ERROR_UNSAFE_ACTIONLIST_INTRO, warnings,
                    api.ERROR_UNSAFE_ACTIONLIST_ACCEPT))
        return data

    #---notification
    def _execute(self, actionlist, **keyw):
        app = wx.GetApp()
        self.set_report([])
        api.apply_actions_to_photos(actionlist, app.settings,