Skip to content

Commit 64ef567

Browse files
authored
Merge pull request #1481 from flxzt/shelldriver-remove-mktemp
driver: remove `mktemp` tool dependency in `ShellDriver`
2 parents b0ec4d1 + 1501b58 commit 64ef567

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

labgrid/driver/shelldriver.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
import shlex
77
import ipaddress
8+
from uuid import uuid4
89

910
import attr
1011
from pexpect import TIMEOUT
@@ -372,10 +373,16 @@ def _target_cleanup(tmpfile):
372373
stream = io.BytesIO(buf)
373374

374375
# We first write to a temp file, which we'll `dd` onto the destination file later
375-
tmpfile = self._run_check('mktemp')
376+
try:
377+
tmpfile = self._run_check('mktemp')
378+
tmpfile = tmpfile[0]
379+
except ExecutionError:
380+
self.logger.info("Unable to execute 'mktemp', falling back to create temporary file with touch")
381+
tmpfile = f'/tmp/tmp-{uuid4()}'
382+
self._run_check(f'touch {tmpfile}')
383+
376384
if not tmpfile:
377385
raise ExecutionError('Could not make temporary file on target')
378-
tmpfile = tmpfile[0]
379386

380387
try:
381388
rx_cmd = self._get_xmodem_rx_cmd(tmpfile)

0 commit comments

Comments
 (0)