diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-11-07 10:23:32 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-11-07 10:23:32 -0500 |
commit | 8ada8c1f625be5365a5116c458476c7deeae8818 (patch) | |
tree | a2f3b4c968a3fd4cbc76ad59ce70563485ea8171 /cloudinit/util.py | |
parent | 0da58fe113726c7654bca54b365d95044b44ef87 (diff) | |
parent | ce5a554672f4ffbc383af08a35d22a1dd89ce41f (diff) | |
download | vyos-cloud-init-8ada8c1f625be5365a5116c458476c7deeae8818.tar.gz vyos-cloud-init-8ada8c1f625be5365a5116c458476c7deeae8818.zip |
merge from trunk
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index f5a7ac12..7890a3d6 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -983,6 +983,12 @@ def find_devs_with(criteria=None, oformat='device', return entries +def peek_file(fname, max_bytes): + LOG.debug("Peeking at %s (max_bytes=%s)", fname, max_bytes) + with open(fname, 'rb') as ifh: + return ifh.read(max_bytes) + + def load_file(fname, read_cb=None, quiet=False): LOG.debug("Reading from %s (quiet=%s)", fname, quiet) ofh = StringIO() @@ -1328,6 +1334,10 @@ def uptime(): return uptime_str +def append_file(path, content): + write_file(path, content, omode="ab", mode=None) + + def ensure_file(path, mode=0644): write_file(path, content='', omode="ab", mode=mode) |