Use Python 3.x compatible octal literals

Python 3.x deprecated octal literals in the form 0755.
Use the Python 2.x compatible version 0o755 instead.

Change-Id: I90ea601847752ae04d4e403ffa16a537efe442e2
This commit is contained in:
Dirk Mueller 2013-06-08 13:17:03 +02:00
parent f83931af80
commit 5324e2be69
11 changed files with 13 additions and 13 deletions

View File

@ -638,7 +638,7 @@ class DhcpLeaseRelay(object):
if os.path.exists(cfg.CONF.dhcp_lease_relay_socket):
raise
else:
os.makedirs(dirname, 0755)
os.makedirs(dirname, 0o755)
def _handler(self, client_sock, client_addr):
"""Handle incoming lease relay stream connection.

View File

@ -157,7 +157,7 @@ class DhcpLocalProcess(DhcpBase):
conf_dir = os.path.join(confs_dir, self.network.id)
if ensure_conf_dir:
if not os.path.isdir(conf_dir):
os.makedirs(conf_dir, 0755)
os.makedirs(conf_dir, 0o755)
return os.path.join(conf_dir, kind)

View File

@ -73,7 +73,7 @@ class ProcessManager(object):
"""Returns the file name for a given kind of config file."""
pids_dir = os.path.abspath(os.path.normpath(self.conf.external_pids))
if ensure_pids_dir and not os.path.isdir(pids_dir):
os.makedirs(pids_dir, 0755)
os.makedirs(pids_dir, 0o755)
return os.path.join(pids_dir, self.uuid + '.pid')

View File

@ -87,5 +87,5 @@ def replace_file(file_name, data):
tmp_file = tempfile.NamedTemporaryFile('w+', dir=base_dir, delete=False)
tmp_file.write(data)
tmp_file.close()
os.chmod(tmp_file.name, 0644)
os.chmod(tmp_file.name, 0o644)
os.rename(tmp_file.name, file_name)

View File

@ -220,7 +220,7 @@ class UnixDomainMetadataProxy(object):
if os.path.exists(cfg.CONF.metadata_proxy_socket):
raise
else:
os.makedirs(dirname, 0755)
os.makedirs(dirname, 0o755)
def run(self):
server = UnixDomainWSGIServer('quantum-metadata-agent')

View File

@ -150,7 +150,7 @@ class HaproxyNSDriver(object):
conf_dir = os.path.join(confs_dir, pool_id)
if ensure_state_dir:
if not os.path.isdir(conf_dir):
os.makedirs(conf_dir, 0755)
os.makedirs(conf_dir, 0o755)
return os.path.join(conf_dir, kind)
def _plug(self, namespace, port, reuse_existing=True):

View File

@ -40,11 +40,11 @@ class TestCiscoNexusPlugin(base.BaseTestCase):
super(TestCiscoNexusPlugin, self).setUp()
self.tenant_id = "test_tenant_cisco1"
self.net_name = "test_network_cisco1"
self.net_id = 000007
self.net_id = 7
self.vlan_name = "q-" + str(self.net_id) + "vlan"
self.vlan_id = 267
self.second_net_name = "test_network_cisco2"
self.second_net_id = 000005
self.second_net_id = 5
self.second_vlan_name = "q-" + str(self.second_net_id) + "vlan"
self.second_vlan_id = 265
self._nexus_switches = {

View File

@ -286,4 +286,4 @@ class TestHaproxyNSDriver(base.BaseTestCase):
with mock.patch('os.makedirs') as mkdir:
path = self.driver._get_state_file_path('pool_id', 'conf')
self.assertEqual('/the/path/pool_id/conf', path)
mkdir.assert_called_once_with('/the/path/pool_id', 0755)
mkdir.assert_called_once_with('/the/path/pool_id', 0o755)

View File

@ -88,5 +88,5 @@ class AgentUtilsReplaceFile(base.BaseTestCase):
mock.call().close()]
ntf.assert_has_calls(expected)
chmod.assert_called_once_with('/baz', 0644)
chmod.assert_called_once_with('/baz', 0o644)
rename.assert_called_once_with('/baz', '/foo')

View File

@ -134,7 +134,7 @@ class TestProcessManager(base.BaseTestCase):
manager = ep.ProcessManager(self.conf, 'uuid')
retval = manager.get_pid_file_name(ensure_pids_dir=True)
self.assertEqual(retval, '/var/path/uuid.pid')
makedirs.assert_called_once_with('/var/path', 0755)
makedirs.assert_called_once_with('/var/path', 0o755)
def test_get_pid_file_name_default(self):
with mock.patch.object(ep.os.path, 'isdir') as isdir:

View File

@ -308,7 +308,7 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
agent.UnixDomainMetadataProxy(mock.Mock())
isdir.assert_called_once_with('/the')
makedirs.assert_called_once_with('/the', 0755)
makedirs.assert_called_once_with('/the', 0o755)
def test_init_exists(self):
with mock.patch('os.path.isdir') as isdir:
@ -359,7 +359,7 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
p.run()
isdir.assert_called_once_with('/the')
makedirs.assert_called_once_with('/the', 0755)
makedirs.assert_called_once_with('/the', 0o755)
server.assert_has_calls([
mock.call('quantum-metadata-agent'),
mock.call().start(handler.return_value,