tweak autoinstall command lists
allow commands to be lists or strings consider errors to be failures (except in error-commands)
This commit is contained in:
parent
91a79037a9
commit
03661dabec
|
@ -1,7 +1,7 @@
|
||||||
version: 1
|
version: 1
|
||||||
early-commands:
|
early-commands:
|
||||||
- echo a
|
- echo a
|
||||||
- sleep 1
|
- ["sleep", "1"]
|
||||||
- echo a
|
- echo a
|
||||||
late-commands:
|
late-commands:
|
||||||
- echo a
|
- echo a
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import asyncio
|
from subiquitycore.utils import arun_command
|
||||||
|
|
||||||
from subiquity.controller import NoUIController
|
from subiquity.controller import NoUIController
|
||||||
|
|
||||||
|
@ -23,9 +23,13 @@ class CmdListController(NoUIController):
|
||||||
autoinstall_default = []
|
autoinstall_default = []
|
||||||
autoinstall_schema = {
|
autoinstall_schema = {
|
||||||
'type': 'array',
|
'type': 'array',
|
||||||
'items': {'type': 'string'},
|
'items': {
|
||||||
|
'type': ['string', 'array'],
|
||||||
|
'items': {'type': 'string'},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
cmds = ()
|
cmds = ()
|
||||||
|
cmd_check = True
|
||||||
|
|
||||||
def load_autoinstall_data(self, data):
|
def load_autoinstall_data(self, data):
|
||||||
self.cmds = data
|
self.cmds = data
|
||||||
|
@ -33,8 +37,12 @@ class CmdListController(NoUIController):
|
||||||
async def run(self):
|
async def run(self):
|
||||||
for i, cmd in enumerate(self.cmds):
|
for i, cmd in enumerate(self.cmds):
|
||||||
with self.context.child("command_{}".format(i), cmd):
|
with self.context.child("command_{}".format(i), cmd):
|
||||||
proc = await asyncio.create_subprocess_shell(cmd)
|
if isinstance(cmd, str):
|
||||||
await proc.communicate()
|
cmd = ['sh', '-c', cmd]
|
||||||
|
await arun_command(
|
||||||
|
cmd,
|
||||||
|
stdin=None, stdout=None, stderr=None,
|
||||||
|
check=self.cmd_check)
|
||||||
|
|
||||||
|
|
||||||
class EarlyController(CmdListController):
|
class EarlyController(CmdListController):
|
||||||
|
|
|
@ -326,6 +326,7 @@ class ErrorReport(metaclass=urwid.MetaSignals):
|
||||||
class ErrorController(CmdListController):
|
class ErrorController(CmdListController):
|
||||||
|
|
||||||
autoinstall_key = 'error-commands'
|
autoinstall_key = 'error-commands'
|
||||||
|
cmd_check = False
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
|
|
Loading…
Reference in New Issue