Robot Framework Integrated Development Environment (RIDE)
runanything.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 import wx
17 
18 from ..controller.basecontroller import _BaseController
19 from ..pluginapi import Plugin
20 from ..action import ActionInfo, SeparatorInfo
21 from ..run.configmanagerui import ConfigManagerDialog
22 from ..run.ui import Runner
23 
24 
25 
31 
32  def __init__(self, app):
33  Plugin.__init__(self, app, default_settings={'configs': []})
34  self._configs_configs = RunConfigs(self.configs)
35 
36  def enable(self):
37  self._create_menu_create_menu(self._configs_configs)
38 
39  def OnManageConfigurations(self, event):
40  dlg = ConfigManagerDialog(self._configs_configs, self)
41  if dlg.ShowModal() == wx.ID_OK:
42  self._configs_configs.update(dlg.get_data())
43  self.save_settingsave_setting('configs', self._configs_configs.data_to_save())
44  self._create_menu_create_menu(self._configs_configs)
45  self._configs_configs = RunConfigs(self.configs)
46  dlg.Destroy()
47 
48  def _create_menu(self, configs):
49  self.unregister_actionsunregister_actions()
50  self.register_actionregister_action(ActionInfo('Macros', 'Manage Run Configurations',
51  self.OnManageConfigurationsOnManageConfigurations))
52  self.register_actionregister_action(SeparatorInfo('Macros'))
53  for index, cfg in enumerate(configs):
54  self._add_config_to_menu_add_config_to_menu(cfg, index+1)
55 
56  def _add_config_to_menu(self, config, index):
57  def run(event):
58  Runner(config, self.notebooknotebook).run()
59  info = ActionInfo('Macros', name='%d: %s' % (index, config.name),
60  doc=config.help, action=run)
61  self.register_actionregister_action(info)
62 
63 
65 
66  def __init__(self, saved_data):
67  self._configs_configs = []
68  for item in saved_data:
69  self.addadd(item[0], item[1], item[2])
70 
71  def __iter__(self):
72  return iter(self._configs_configs)
73 
74  def __len__(self):
75  return len(self._configs_configs)
76 
77  def __getitem__(self, index):
78  return self._configs_configs[index]
79 
80  def add(self, name, command, doc):
81  config = RunConfig(name, command, doc)
82  self._configs_configs.append(config)
83  return config
84 
85  def update(self, data):
86  for index, datum in enumerate(data):
87  self.editedit(index, *datum)
88 
89  def move_up(self, index):
90  self._swap_swap(index-1, index)
91 
92  def move_down(self, index):
93  self._swap_swap(index, index+1)
94 
95  def _swap(self, index1, index2):
96  self._configs_configs[index1], self._configs_configs[index2] = \
97  self._configs_configs[index2], self._configs_configs[index1]
98 
99  def edit(self, index, name, command, doc):
100  config = self._configs_configs[index]
101  config.name, config.command, config.doc = name, command, doc
102 
103  def delete(self, index):
104  if index < len(self._configs_configs):
105  self._configs_configs.pop(index)
106 
107  def data_to_save(self):
108  return [ (c.name, c.command, c.doc) for c in self._configs_configs ]
109 
110 
111 class RunConfig():
112  help = property(lambda self: '%s (%s)' % (self.docdoc, self.commandcommand))
113 
114  def __init__(self, name, command, doc):
115  self.namename = name
116  self.commandcommand = command
117  self.docdoc = doc
118  self._finished_finished = False
119  self._error_error = False
120 
Used to create menu entries, keyboard shortcuts and/or toolbar buttons.
Definition: actioninfo.py:176
Used to create separators to menus.
Definition: actioninfo.py:262
Entry point to RIDE plugin API – all plugins must extend this class.
Definition: plugin.py:50
def register_action(self, action_info)
Registers a menu entry and optionally a shortcut and a toolbar icon.
Definition: plugin.py:205
def unregister_actions(self)
Unregisters all actions registered by this plugin.
Definition: plugin.py:230
def save_setting(self, name, value, override=True, delay=0)
Saves the specified setting into the RIDE configuration file.
Definition: plugin.py:148
A plugin for executing commands on the system.
Definition: runanything.py:30
def enable(self)
This method is called by RIDE when the plugin is enabled.
Definition: runanything.py:36
def OnManageConfigurations(self, event)
Definition: runanything.py:39
def _add_config_to_menu(self, config, index)
Definition: runanything.py:56
def __init__(self, name, command, doc)
Definition: runanything.py:114
def __init__(self, saved_data)
Definition: runanything.py:66
def add(self, name, command, doc)
Definition: runanything.py:80
def edit(self, index, name, command, doc)
Definition: runanything.py:99
def _swap(self, index1, index2)
Definition: runanything.py:95
def run(*tests, **options)
Programmatic entry point for running tests.
Definition: run.py:546