summaryrefslogtreecommitdiff
path: root/azurelinuxagent/utils/fileutil.py
diff options
context:
space:
mode:
authorBen Howard <ben.howard@ubuntu.com>2016-02-08 16:33:07 -0700
committerusd-importer <ubuntu-server@lists.ubuntu.com>2016-02-09 00:59:05 +0000
commita00729ff7421b3661e8b1a1e0fa46393379f2e96 (patch)
tree4563b927e3a57446a4a928a72a92d72c9ad4f6e6 /azurelinuxagent/utils/fileutil.py
parent53f54030cae2de3d5fa474a61fe51f16c7a07c79 (diff)
downloadvyos-walinuxagent-a00729ff7421b3661e8b1a1e0fa46393379f2e96.tar.gz
vyos-walinuxagent-a00729ff7421b3661e8b1a1e0fa46393379f2e96.zip
Import patches-unapplied version 2.1.3-0ubuntu1 to ubuntu/xenial-proposed
Imported using git-ubuntu import. Changelog parent: 53f54030cae2de3d5fa474a61fe51f16c7a07c79 New changelog entries: * New upstream release (LP: #1543359): - Bug fixes for extension handling - Feature enablement for AzureStack.
Diffstat (limited to 'azurelinuxagent/utils/fileutil.py')
-rw-r--r--azurelinuxagent/utils/fileutil.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/azurelinuxagent/utils/fileutil.py b/azurelinuxagent/utils/fileutil.py
index 08592bc..5369a7c 100644
--- a/azurelinuxagent/utils/fileutil.py
+++ b/azurelinuxagent/utils/fileutil.py
@@ -27,7 +27,7 @@ import shutil
import pwd
import tempfile
import azurelinuxagent.logger as logger
-from azurelinuxagent.future import text
+from azurelinuxagent.future import ustr
import azurelinuxagent.utils.textutil as textutil
def read_file(filepath, asbin=False, remove_bom=False, encoding='utf-8'):
@@ -46,7 +46,7 @@ def read_file(filepath, asbin=False, remove_bom=False, encoding='utf-8'):
if remove_bom:
#Remove bom on bytes data before it is converted into string.
data = textutil.remove_bom(data)
- data = text(data, encoding=encoding)
+ data = ustr(data, encoding=encoding)
return data
def write_file(filepath, contents, asbin=False, encoding='utf-8', append=False):
@@ -100,6 +100,7 @@ def replace_file(filepath, contents):
return 1
return 0
+
def base_name(path):
head, tail = os.path.split(path)
return tail
@@ -151,7 +152,7 @@ def rm_dirs(*args):
def update_conf_file(path, line_start, val, chk_err=False):
conf = []
if not os.path.isfile(path) and chk_err:
- raise Exception("Can't find config file:{0}".format(path))
+ raise IOError("Can't find config file:{0}".format(path))
conf = read_file(path).split('\n')
conf = [x for x in conf if not x.startswith(line_start)]
conf.append(val)