Run a script on the specified flows. The script is configured with the current options and all lifecycle events for each flow are simulated. Note that the load event is not invoked.
(self, flows: Sequence[flow.Flow], path: mtypes.Path)
| 167 | |
| 168 | @command.command("script.run") |
| 169 | def script_run(self, flows: Sequence[flow.Flow], path: mtypes.Path) -> None: |
| 170 | """ |
| 171 | Run a script on the specified flows. The script is configured with |
| 172 | the current options and all lifecycle events for each flow are |
| 173 | simulated. Note that the load event is not invoked. |
| 174 | """ |
| 175 | if not os.path.isfile(path): |
| 176 | logger.error("No such script: %s" % path) |
| 177 | return |
| 178 | mod = load_script(path) |
| 179 | if mod: |
| 180 | with addonmanager.safecall(): |
| 181 | ctx.master.addons.invoke_addon_sync( |
| 182 | mod, |
| 183 | hooks.ConfigureHook(ctx.options.keys()), |
| 184 | ) |
| 185 | ctx.master.addons.invoke_addon_sync(mod, hooks.RunningHook()) |
| 186 | for f in flows: |
| 187 | for evt in eventsequence.iterate(f): |
| 188 | ctx.master.addons.invoke_addon_sync(mod, evt) |
| 189 | |
| 190 | def configure(self, updated): |
| 191 | if "scripts" in updated: |