new `slapos console script.py`style invocation
To execute a slapconsole script, we could only do:
slapos console < script.py
but this does not stop in case of error
echo 'execfile("script.py")' | slapos console
but this is too complicated.
Extend this API so that we can simply use
slapos console script.py
The changes were merged into master. The source branch has been removed.
174 def tearDown(self): 175 self.mock_request.stop() 176 self.config_file.close() 177 178 def test_console_interactive(self): 179 app = slapos.cli.entry.SlapOSApp() 180 saved_stdin = sys.stdin 181 saved_stdout = sys.stdout 182 try: 183 sys.stdin = app_stdin = StringIO.StringIO( 184 """print request('software_release', 'instance').getInstanceParameterDict()['parameter_name']\n""") 185 sys.stdout = app_stdout = StringIO.StringIO() 186 app.run(('console', '--cfg', self.config_file.name)) 187 finally: 188 sys.sdin = saved_stdin 189 sys.stdout = saved_stdout
I'm not 100% sure saving and restoring stdin and stdout like this is OK, it passes the test and does not seem to have side effects on other tests (but I was running these tests inside a webrunner and lots of them were failing)
I'm not user of slapos console... but it seems nice to have this feature.
Go ahead to merge...
I also like the feature, it will be useful.
Thanks, I'm merging
Status changed to mergedToggle commit list