From 2e51e2efc292870479a7b972c7ebc9ceac85da6f Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 27 Aug 2012 20:51:00 -0700 Subject: For the userdata 'post-filtering' add in a new folder that can contain filters that serve this purpose only and add in the initial launch-index filter and replace the code in the datasource class that previously did this. --- cloudinit/util.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cloudinit/util.py') diff --git a/cloudinit/util.py b/cloudinit/util.py index 6872cc31..33da73eb 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1285,12 +1285,15 @@ def ensure_file(path, mode=0644): write_file(path, content='', omode="ab", mode=mode) -def chmod(path, mode): - real_mode = None +def safe_int(possible_int): try: - real_mode = int(mode) + return int(possible_int) except (ValueError, TypeError): - pass + return None + + +def chmod(path, mode): + real_mode = safe_int(mode) if path and real_mode: with SeLinuxGuard(path): os.chmod(path, real_mode) -- cgit v1.2.3