Skip to content

Commit

Permalink
fix py312 escape
Browse files Browse the repository at this point in the history
Change-Id: Ic675ac97aed4ac53b3aeca83a9fe04877f097430
  • Loading branch information
ader1990 committed Nov 8, 2023
1 parent fe601a0 commit 5d68214
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cloudbaseinit/osutils/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ def _check_server_level(self, server_level):
try:
with winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows NT\\CurrentVersion\\Server\\"
'Software\\Microsoft\\Windows NT\\CurrentVersion\\Server\\'
"ServerLevels") as key:
return winreg.QueryValueEx(key, server_level)[0] == 1
except WindowsError as ex:
Expand Down
17 changes: 17 additions & 0 deletions cloudbaseinit/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Copyright 2023 Cloudbase Solutions Srl
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
# https://github.com/python/cpython/blob/3.10/LICENSE
# _dot_lookup, _importer, _get_target

from unittest import mock

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_remove_azure_dirs(self, mock_os_getenv,

def test_set_registry_vm_type(self):
vm_type = mock.sentinel.vm
key_name = "SOFTWARE\\Microsoft\\Windows Azure"
key_name = 'SOFTWARE\\Microsoft\\Windows Azure'

self._azureagentplugin._set_registry_vm_type(vm_type)
key = self._winreg_mock.CreateKey.return_value.__enter__.return_value
Expand Down
4 changes: 2 additions & 2 deletions cloudbaseinit/tests/utils/windows/test_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,12 @@ def test_partitions(self, mock_get_layout, mock_get_partition_indexes,
indexes = [0, 1, 2]
mock_get_layout.return_value = layout
mock_get_partition_indexes.return_value = indexes
self._disk_class._path = r"\\?\GLOBALROOT\Device\Harddisk0"
self._disk_class._path = r'\\?\GLOBALROOT\Device\Harddisk0'

response = self._disk_class.partitions()
mock_get_layout.assert_called_once_with()
mock_get_partition_indexes.assert_called_once_with(layout)
paths = [r"\\?\GLOBALROOT\Device\Harddisk{}\Partition{}".format(
paths = [r'\\?\GLOBALROOT\Device\Harddisk{}\Partition{}'.format(
0, idx + 1) for idx in indexes]
calls = [mock.call(path, size) for path in paths]
mock_partition.assert_has_calls(calls)
Expand Down
2 changes: 1 addition & 1 deletion cloudbaseinit/utils/windows/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from cloudbaseinit.utils.windows import privilege


REG_TIME_ZONES = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"
REG_TIME_ZONES = 'Software\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones'
NOT_FOUND = 2
kernel32 = ctypes.windll.kernel32

Expand Down

0 comments on commit 5d68214

Please sign in to comment.