translate mode param

This commit is contained in:
agnewee 2017-12-23 17:29:53 +08:00
parent 092ea180a2
commit 354b2af680
1 changed files with 5 additions and 1 deletions

View File

@ -257,12 +257,16 @@ else:
raise OSError('Link {} to {} error'.format(dst, src)) raise OSError('Link {} to {} error'.format(dst, src))
def chmod(path, mode=0o755): def chmod(path, mode):
""" """
Change the access permissions of a file or directory Change the access permissions of a file or directory
If path is not exists, throw OSError If path is not exists, throw OSError
>>> chmod('/opt/sometest', 755)
>>> oct(os.stat('/opt/sometest').st_mode)[-3:]
755
""" """
mode = int('0o%d' % mode, 8)
if not os.path.exists(path): if not os.path.exists(path):
raise OSError('%s is not exists' % path) raise OSError('%s is not exists' % path)