mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Added rename function
Wanted to move a file, but didn't want to use os.
This commit is contained in:
parent
aeefe2f894
commit
1e304d0b0a
@ -925,6 +925,22 @@ def symlink(src, link):
|
||||
raise CommandExecutionError('Could not create "{0}"'.format(link))
|
||||
return False
|
||||
|
||||
def rename(src, dst):
|
||||
'''
|
||||
Rename a file or directory
|
||||
CLI Example
|
||||
salt '*' file.rename /path/to/src /path/to/dst
|
||||
'''
|
||||
if not os.path.isabs(src):
|
||||
raise SaltInvocationError('File path must be absolute.')
|
||||
|
||||
try:
|
||||
os.rename(src, dst)
|
||||
return True
|
||||
except OSError:
|
||||
raise CommandExecutionError('Could not rename "{0}" to "{1}"'.format(src, dst))
|
||||
return False
|
||||
|
||||
def stats(path, hash_type='md5', follow_symlink=False):
|
||||
'''
|
||||
Return a dict containing the stats for a given file
|
||||
|
Loading…
Reference in New Issue
Block a user