Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1743 from jvlomax/octal_fix
Update octals for py3
  • Loading branch information
Mikhail Sobolev committed Jun 26, 2015
2 parents 8efed51 + 7ce5e42 commit 19bd871
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions slave/buildslave/commands/utils.py
Expand Up @@ -55,7 +55,7 @@ def rmdirRecursive(dir):
return

# Verify the directory is read/write/execute for the current user
os.chmod(dir, 0700)
os.chmod(dir, 0o700)

# os.listdir below only returns a list of unicode filenames if the parameter is unicode
# Thus, if a non-unicode-named dir contains a unicode filename, that filename will get garbled.
Expand Down Expand Up @@ -84,15 +84,15 @@ def rmdirRecursive(dir):
# I think this is now redundant, but I don't have an NT
# machine to test on, so I'm going to leave it in place
# -warner
os.chmod(full_name, 0600)
os.chmod(full_name, 0o600)

if os.path.islink(full_name):
os.remove(full_name) # as suggested in bug #792
elif os.path.isdir(full_name):
rmdirRecursive(full_name)
else:
if os.path.isfile(full_name):
os.chmod(full_name, 0700)
os.chmod(full_name, 0o700)
os.remove(full_name)
os.rmdir(dir)
else:
Expand Down
2 changes: 1 addition & 1 deletion slave/buildslave/scripts/create_slave.py
Expand Up @@ -132,7 +132,7 @@ def _makeBuildbotTac(basedir, tac_file_contents, quiet):
f = open(tacfile, "wt")
f.write(tac_file_contents)
f.close()
os.chmod(tacfile, 0600)
os.chmod(tacfile, 0o600)
except IOError as exception:
raise CreateSlaveError("could not write %s: %s" %
(tacfile, exception.strerror))
Expand Down
14 changes: 7 additions & 7 deletions slave/buildslave/test/unit/test_bot_BuildSlave.py
Expand Up @@ -111,12 +111,12 @@ def test_constructor_minimal(self):
def test_constructor_083_tac(self):
# invocation as made from default 083 tac files
bot.BuildSlave('mstr', 9010, 'me', 'pwd', '/s', 10, False,
umask=0123, maxdelay=10)
umask=0o123, maxdelay=10)

def test_constructor_full(self):
# invocation with all args
bot.BuildSlave('mstr', 9010, 'me', 'pwd', '/s', 10, False,
umask=0123, maxdelay=10, keepaliveTimeout=10,
umask=0o123, maxdelay=10, keepaliveTimeout=10,
unicode_encoding='utf8', allow_shutdown=True)

def test_buildslave_print(self):
Expand All @@ -133,7 +133,7 @@ def call_print(mind):
port = self.start_master(persp, on_attachment=call_print)
self.buildslave = bot.BuildSlave("127.0.0.1", port,
"testy", "westy", self.basedir,
keepalive=0, usePTY=False, umask=022)
keepalive=0, usePTY=False, umask=0o22)
self.buildslave.startService()

# and wait for the result of the print
Expand All @@ -144,7 +144,7 @@ def test_recordHostname_uname(self):

self.buildslave = bot.BuildSlave("127.0.0.1", 9999,
"testy", "westy", self.basedir,
keepalive=0, usePTY=False, umask=022)
keepalive=0, usePTY=False, umask=0o22)
self.buildslave.recordHostname(self.basedir)
self.assertEqual(open(os.path.join(self.basedir, "twistd.hostname")).read().strip(),
'test-hostname.domain.com')
Expand All @@ -157,7 +157,7 @@ def missing():

self.buildslave = bot.BuildSlave("127.0.0.1", 9999,
"testy", "westy", self.basedir,
keepalive=0, usePTY=False, umask=022)
keepalive=0, usePTY=False, umask=0o22)
self.buildslave.recordHostname(self.basedir)
self.assertEqual(open(os.path.join(self.basedir, "twistd.hostname")).read().strip(),
'test-hostname.domain.com')
Expand Down Expand Up @@ -188,7 +188,7 @@ def call_shutdown(mind):

self.buildslave = bot.BuildSlave("127.0.0.1", port,
"testy", "westy", self.basedir,
keepalive=0, usePTY=False, umask=022)
keepalive=0, usePTY=False, umask=0o22)

self.buildslave.startService()

Expand All @@ -204,7 +204,7 @@ def test_buildslave_shutdown(self):

buildslave = bot.BuildSlave("127.0.0.1", 1234,
"testy", "westy", self.basedir,
keepalive=0, usePTY=False, umask=022,
keepalive=0, usePTY=False, umask=0o22,
allow_shutdown='file')

# Mock out gracefulShutdown
Expand Down
12 changes: 6 additions & 6 deletions slave/buildslave/test/unit/test_commands_transfer.py
Expand Up @@ -407,7 +407,7 @@ def test_simple(self):
reader=FakeRemote(self.fakemaster),
maxsize=None,
blocksize=32,
mode=0777,
mode=0o777,
))

d = self.run_command()
Expand All @@ -421,7 +421,7 @@ def check(_):
self.assertTrue(os.path.exists(datafile))
self.assertEqual(open(datafile).read(), test_data)
if runtime.platformType != 'win32':
self.assertEqual(os.stat(datafile).st_mode & 0777, 0777)
self.assertEqual(os.stat(datafile).st_mode & 0o777, 0o777)
d.addCallback(check)
return d

Expand All @@ -434,7 +434,7 @@ def test_mkdir(self):
reader=FakeRemote(self.fakemaster),
maxsize=None,
blocksize=32,
mode=0777,
mode=0o777,
))

d = self.run_command()
Expand All @@ -460,7 +460,7 @@ def test_failure(self):
reader=FakeRemote(self.fakemaster),
maxsize=None,
blocksize=32,
mode=0777,
mode=0o777,
))

d = self.run_command()
Expand All @@ -484,7 +484,7 @@ def test_truncated(self):
reader=FakeRemote(self.fakemaster),
maxsize=50,
blocksize=32,
mode=0777,
mode=0o777,
))

d = self.run_command()
Expand Down Expand Up @@ -512,7 +512,7 @@ def test_interrupted(self):
reader=FakeRemote(self.fakemaster),
maxsize=100,
blocksize=2,
mode=0777,
mode=0o777,
))

d = self.run_command()
Expand Down
2 changes: 1 addition & 1 deletion slave/buildslave/test/unit/test_commands_utils.py
Expand Up @@ -132,7 +132,7 @@ def test_rmdirRecursive_symlink(self):
finally:
# even Twisted can't clean this up very well, so try hard to
# clean it up ourselves..
os.chmod("noperms/x", 0777)
os.chmod("noperms/x", 0o777)
os.unlink("noperms/x")
os.rmdir("noperms")

Expand Down
4 changes: 2 additions & 2 deletions slave/buildslave/test/unit/test_scripts_create_slave.py
Expand Up @@ -241,7 +241,7 @@ def checkDiffTacFile(self, quiet):
self.open.assert_has_calls([mock.call(tac_file_path, "rt"),
mock.call(tac_file_path + ".new", "wt")])
self.fileobj.write.assert_called_once_with("new-tac-contents")
self.chmod.assert_called_once_with(tac_file_path + ".new", 0600)
self.chmod.assert_called_once_with(tac_file_path + ".new", 0o600)

# check output to the log
if quiet:
Expand Down Expand Up @@ -279,7 +279,7 @@ def testNoTacFile(self):
tac_file_path = os.path.join("bdir", "buildbot.tac")
self.open.assert_called_once_with(tac_file_path, "wt")
self.fileobj.write.assert_called_once_with("test-tac-contents")
self.chmod.assert_called_once_with(tac_file_path, 0600)
self.chmod.assert_called_once_with(tac_file_path, 0o600)


class TestMakeInfoFiles(misc.LoggingMixin,
Expand Down

0 comments on commit 19bd871

Please sign in to comment.