[Python 3]: New octal syntax.
This commit is contained in:
parent
b1e235d820
commit
86fe372a2c
|
@ -346,9 +346,9 @@ class PKey (object):
|
|||
|
||||
@raise IOError: if there was an error writing the file.
|
||||
"""
|
||||
f = open(filename, 'w', 0600)
|
||||
f = open(filename, 'w', 0o600)
|
||||
# grrr... the mode doesn't always take hold
|
||||
os.chmod(filename, 0600)
|
||||
os.chmod(filename, 0o600)
|
||||
self._write_private_key(tag, f, data, password)
|
||||
f.close()
|
||||
|
||||
|
|
|
@ -194,8 +194,8 @@ class SFTPAttributes (object):
|
|||
ks = 's'
|
||||
else:
|
||||
ks = '?'
|
||||
ks += self._rwx((self.st_mode & 0700) >> 6, self.st_mode & stat.S_ISUID)
|
||||
ks += self._rwx((self.st_mode & 070) >> 3, self.st_mode & stat.S_ISGID)
|
||||
ks += self._rwx((self.st_mode & 0o700) >> 6, self.st_mode & stat.S_ISUID)
|
||||
ks += self._rwx((self.st_mode & 0o70) >> 3, self.st_mode & stat.S_ISGID)
|
||||
ks += self._rwx(self.st_mode & 7, self.st_mode & stat.S_ISVTX, True)
|
||||
else:
|
||||
ks = '?---------'
|
||||
|
|
|
@ -285,10 +285,10 @@ class SFTPClient (BaseSFTP):
|
|||
self._log(DEBUG, 'rename(%r, %r)' % (oldpath, newpath))
|
||||
self._request(CMD_RENAME, oldpath, newpath)
|
||||
|
||||
def mkdir(self, path, mode=0777):
|
||||
def mkdir(self, path, mode= 0o777):
|
||||
"""
|
||||
Create a folder (directory) named C{path} with numeric mode C{mode}.
|
||||
The default mode is 0777 (octal). On some systems, mode is ignored.
|
||||
The default mode is 0o777 (octal). On some systems, mode is ignored.
|
||||
Where it is used, the current umask value is first masked out.
|
||||
|
||||
@param path: name of the folder to create
|
||||
|
|
|
@ -95,9 +95,9 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
if mode is not None:
|
||||
fd = os.open(path, flags, mode)
|
||||
else:
|
||||
# os.open() defaults to 0777 which is
|
||||
# os.open() defaults to 0o777 which is
|
||||
# an odd default mode for files
|
||||
fd = os.open(path, flags, 0666)
|
||||
fd = os.open(path, flags, 0o666)
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
if (flags & os.O_CREAT) and (attr is not None):
|
||||
|
|
|
@ -300,16 +300,16 @@ class SFTPTest (unittest.TestCase):
|
|||
f.close()
|
||||
|
||||
stat = sftp.stat(FOLDER + '/special')
|
||||
sftp.chmod(FOLDER + '/special', (stat.st_mode & ~0777) | 0600)
|
||||
sftp.chmod(FOLDER + '/special', (stat.st_mode & ~0o777) | 0o600)
|
||||
stat = sftp.stat(FOLDER + '/special')
|
||||
expected_mode = 0600
|
||||
expected_mode = 0o600
|
||||
if sys.platform == 'win32':
|
||||
# chmod not really functional on windows
|
||||
expected_mode = 0666
|
||||
expected_mode = 0o666
|
||||
if sys.platform == 'cygwin':
|
||||
# even worse.
|
||||
expected_mode = 0644
|
||||
self.assertEqual(stat.st_mode & 0777, expected_mode)
|
||||
expected_mode = 0o644
|
||||
self.assertEqual(stat.st_mode & 0o777, expected_mode)
|
||||
self.assertEqual(stat.st_size, 1024)
|
||||
|
||||
mtime = stat.st_mtime - 3600
|
||||
|
@ -340,17 +340,17 @@ class SFTPTest (unittest.TestCase):
|
|||
|
||||
f = sftp.open(FOLDER + '/special', 'r+')
|
||||
stat = f.stat()
|
||||
f.chmod((stat.st_mode & ~0777) | 0600)
|
||||
f.chmod((stat.st_mode & ~0o777) | 0o600)
|
||||
stat = f.stat()
|
||||
|
||||
expected_mode = 0600
|
||||
expected_mode = 0o600
|
||||
if sys.platform == 'win32':
|
||||
# chmod not really functional on windows
|
||||
expected_mode = 0666
|
||||
expected_mode = 0o666
|
||||
if sys.platform == 'cygwin':
|
||||
# even worse.
|
||||
expected_mode = 0644
|
||||
self.assertEqual(stat.st_mode & 0777, expected_mode)
|
||||
expected_mode = 0o644
|
||||
self.assertEqual(stat.st_mode & 0o777, expected_mode)
|
||||
self.assertEqual(stat.st_size, 1024)
|
||||
|
||||
mtime = stat.st_mtime - 3600
|
||||
|
|
|
@ -68,7 +68,7 @@ class BigSFTPTest (unittest.TestCase):
|
|||
f = sftp.open('%s/file%d.txt' % (FOLDER, i), 'w', 1)
|
||||
f.write('this is file #%d.\n' % i)
|
||||
f.close()
|
||||
sftp.chmod('%s/file%d.txt' % (FOLDER, i), 0660)
|
||||
sftp.chmod('%s/file%d.txt' % (FOLDER, i), 0o660)
|
||||
|
||||
# now make sure every file is there, by creating a list of filenmes
|
||||
# and reading them in random order.
|
||||
|
|
Loading…
Reference in New Issue