link: add WriteFile method.
BUG=none
TEST=make test; make lint
Change-Id: Idc18639ea4a1ed89d862462490435ef80457fe3c
diff --git a/graphyte/link.py b/graphyte/link.py
index f6964c3..64b018c 100644
--- a/graphyte/link.py
+++ b/graphyte/link.py
@@ -7,6 +7,8 @@
import subprocess
import tempfile
+from . import utils
+
CalledProcessError = subprocess.CalledProcessError
MODULE_PATH_MAPPING = {
@@ -141,6 +143,18 @@
except CalledProcessError:
return None
+ def WriteFile(self, path, content):
+ """Writes some content into file on DUT.
+
+ Args:
+ path: A string for file path on DUT.
+ content: A string to be written into file.
+ """
+ with utils.UnopenedTemporaryFile() as temp_path:
+ with open(temp_path, 'w') as f:
+ f.write(content)
+ self.Push(temp_path, path)
+
def _GetLinkClass(class_name):
"""Loads and returns a class object specified from the arguments.