@ -903,7 +903,7 @@ class AnsibleModule(object):
return context
return context
def user_and_group ( self , path , expand = True ) :
def user_and_group ( self , path , expand = True ) :
b_path = to_bytes ( path , errors = ' surrogate_ then _strict' )
b_path = to_bytes ( path , errors = ' surrogate_ or _strict' )
if expand :
if expand :
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
st = os . lstat ( b_path )
st = os . lstat ( b_path )
@ -989,10 +989,10 @@ class AnsibleModule(object):
return changed
return changed
def set_owner_if_different ( self , path , owner , changed , diff = None , expand = True ) :
def set_owner_if_different ( self , path , owner , changed , diff = None , expand = True ) :
b_path = to_bytes ( path , errors = ' surrogate_ then _strict' )
b_path = to_bytes ( path , errors = ' surrogate_ or _strict' )
if expand :
if expand :
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
path = to_text ( b_path , errors = ' surrogate_ then _strict' )
path = to_text ( b_path , errors = ' surrogate_ or _strict' )
if owner is None :
if owner is None :
return changed
return changed
orig_uid , orig_gid = self . user_and_group ( path , expand )
orig_uid , orig_gid = self . user_and_group ( path , expand )
@ -1023,10 +1023,10 @@ class AnsibleModule(object):
return changed
return changed
def set_group_if_different ( self , path , group , changed , diff = None , expand = True ) :
def set_group_if_different ( self , path , group , changed , diff = None , expand = True ) :
b_path = to_bytes ( path , errors = ' surrogate_ then _strict' )
b_path = to_bytes ( path , errors = ' surrogate_ or _strict' )
if expand :
if expand :
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
path = to_text ( b_path , errors = ' surrogate_ then _strict' )
path = to_text ( b_path , errors = ' surrogate_ or _strict' )
if group is None :
if group is None :
return changed
return changed
orig_uid , orig_gid = self . user_and_group ( b_path , expand )
orig_uid , orig_gid = self . user_and_group ( b_path , expand )
@ -1057,10 +1057,10 @@ class AnsibleModule(object):
return changed
return changed
def set_mode_if_different ( self , path , mode , changed , diff = None , expand = True ) :
def set_mode_if_different ( self , path , mode , changed , diff = None , expand = True ) :
b_path = to_bytes ( path , errors = ' surrogate_ then _strict' )
b_path = to_bytes ( path , errors = ' surrogate_ or _strict' )
if expand :
if expand :
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
path = to_text ( b_path , errors = ' surrogate_ then _strict' )
path = to_text ( b_path , errors = ' surrogate_ or _strict' )
path_stat = os . lstat ( b_path )
path_stat = os . lstat ( b_path )
if mode is None :
if mode is None :
@ -1137,10 +1137,10 @@ class AnsibleModule(object):
if attributes is None :
if attributes is None :
return changed
return changed
b_path = to_bytes ( path , errors = ' surrogate_ then _strict' )
b_path = to_bytes ( path , errors = ' surrogate_ or _strict' )
if expand :
if expand :
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
b_path = os . path . expanduser ( os . path . expandvars ( b_path ) )
path = to_text ( b_path , errors = ' surrogate_ then _strict' )
path = to_text ( b_path , errors = ' surrogate_ or _strict' )
existing = self . get_file_attributes ( b_path )
existing = self . get_file_attributes ( b_path )