Skip to content

Commit dcddd6e

Browse files
standardization encoding="UTF-8"
1 parent abedc7b commit dcddd6e

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

bibigrid/core/actions/create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def start_worker(self, worker, worker_count, configuration, provider): # pylint
264264
# for DNS resolution an entry in the hosts file is created
265265
with self.worker_thread_lock:
266266
self.permanents.append(name)
267-
with open(a_rp.HOSTS_FILE, mode="r", encoding="utf-8") as hosts_file:
267+
with open(a_rp.HOSTS_FILE, mode="r", encoding="UTF-8") as hosts_file:
268268
hosts = yaml.safe_load(hosts_file)
269269
if not hosts or "host_entries" not in hosts:
270270
self.log.warning("Hosts file is broken.")

bibigrid/core/startup_rest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def validation_exception_handler(request: Request, exc: RequestValidationE
7878

7979
@app.get("/bibigrid/requirements", response_model=RequirementsModel)
8080
async def get_requirements():
81-
with open(CLOUD_NODE_REQUIREMENTS_PATH, "r") as cloud_node_requirements_file:
81+
with open(CLOUD_NODE_REQUIREMENTS_PATH, "r", encoding="UTF-8") as cloud_node_requirements_file:
8282
cloud_node_requirements = yaml.safe_load(cloud_node_requirements_file)
8383
return JSONResponse(content={"cloud_node_requirements": cloud_node_requirements}, status_code=200)
8484

@@ -219,7 +219,7 @@ async def get_log(cluster_id: str, lines: int = None):
219219
file_name = os.path.join(LOG_FOLDER, f"{cluster_id}.log")
220220
if os.path.isfile(file_name):
221221
if not lines:
222-
with open(file_name, "r", encoding="utf8") as log_file:
222+
with open(file_name, "r", encoding="UTF-8") as log_file:
223223
response = log_file.read()
224224
else:
225225
response = tail(file_name, lines)

resources/playbook/roles/bibigrid/files/slurm/create_server.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ class ConfigurationException(Exception):
5858
worker_group_yaml_file = os.path.join(GROUP_VARS_PATH, filename)
5959
# checking if it is a file
6060
if os.path.isfile(worker_group_yaml_file):
61-
with open(worker_group_yaml_file, mode="r", encoding="utf-8") as worker_group_yaml:
61+
with open(worker_group_yaml_file, mode="r", encoding="UTF-8") as worker_group_yaml:
6262
worker_groups.append(yaml.safe_load(worker_group_yaml))
6363

6464
# read common configuration
65-
with open("/opt/playbook/vars/common_configuration.yaml", mode="r", encoding="utf-8") as common_configuration_file:
65+
with open("/opt/playbook/vars/common_configuration.yaml", mode="r", encoding="UTF-8") as common_configuration_file:
6666
common_config = yaml.safe_load(common_configuration_file)
6767
logging.info(f"Maximum 'is active' attempts: {common_config['cloud_scheduling']['sshTimeout']}")
6868
# read clouds.yaml
69-
with open("/etc/openstack/clouds.yaml", mode="r", encoding="utf-8") as clouds_file:
69+
with open("/etc/openstack/clouds.yaml", mode="r", encoding="UTF-8") as clouds_file:
7070
clouds = yaml.safe_load(clouds_file)["clouds"]
7171

7272
connections = {} # connections to cloud providers
@@ -107,7 +107,7 @@ def get_server_vars(name):
107107
server_vars = {"volumes": []}
108108
if os.path.isfile(host_vars_path):
109109
logging.info(f"Found host_vars file {host_vars_path}.")
110-
with open(host_vars_path, mode="r", encoding="utf-8") as host_vars_file:
110+
with open(host_vars_path, mode="r", encoding="UTF-8") as host_vars_file:
111111
server_vars = yaml.safe_load(host_vars_file)
112112
logging.info(f"Loaded Vars: {server_vars}")
113113
else:
@@ -171,7 +171,7 @@ def volumes_host_vars_update(connection, server, host_vars):
171171
logging.debug(f"Added Configuration: Instance {server['name']} has volume {volume['name']} "
172172
f"as device {volume['device']} that is going to be mounted to "
173173
f"{volume.get('mountPoint')}")
174-
with open(host_vars_path, mode="w+", encoding="utf-8") as host_vars_file:
174+
with open(host_vars_path, mode="w+", encoding="UTF-8") as host_vars_file:
175175
yaml.dump(host_vars, host_vars_file)
176176
logging.info(f"{host_vars_path}.lock released")
177177

@@ -219,7 +219,7 @@ def start_server(name, start_worker_group, start_data):
219219
userdata = ""
220220
userdata_file_path = f"/opt/slurm/userdata_{start_worker_group['cloud_identifier']}.txt"
221221
if os.path.isfile(userdata_file_path):
222-
with open(userdata_file_path, mode="r", encoding="utf-8") as userdata_file:
222+
with open(userdata_file_path, mode="r", encoding="UTF-8") as userdata_file:
223223
userdata = userdata_file.read()
224224
# create server and ...
225225
image = select_image(start_worker_group, connection)
@@ -301,15 +301,15 @@ def update_hosts(name, ip): # pylint: disable=invalid-name
301301
logging.info("Updating hosts.yaml")
302302
with FileLock("hosts.yaml.lock"):
303303
logging.info("Lock acquired")
304-
with open(HOSTS_FILE_PATH, mode="r", encoding="utf-8") as hosts_file:
304+
with open(HOSTS_FILE_PATH, mode="r", encoding="UTF-8") as hosts_file:
305305
hosts = yaml.safe_load(hosts_file)
306306
logging.info(f"Existing hosts {hosts}")
307307
if not hosts or "host_entries" not in hosts:
308308
logging.info(f"Resetting host entries because {'first run' if hosts else 'broken'}.")
309309
hosts = {"host_entries": {}}
310310
hosts["host_entries"][name] = ip
311311
logging.info(f"Added host {name} with ip {hosts['host_entries'][name]}")
312-
with open(HOSTS_FILE_PATH, mode="w", encoding="utf-8") as hosts_file:
312+
with open(HOSTS_FILE_PATH, mode="w", encoding="UTF-8") as hosts_file:
313313
yaml.dump(hosts, hosts_file)
314314
logging.info("Wrote hosts file. Released hosts.yaml.lock.")
315315

resources/playbook/roles/bibigrid/files/slurm/delete_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@
4444
f = os.path.join(GROUP_VARS_PATH, filename)
4545
# checking if it is a file
4646
if os.path.isfile(f):
47-
with open(f, mode="r", encoding="utf-8") as worker_group:
47+
with open(f, mode="r", encoding="UTF-8") as worker_group:
4848
worker_groups.append(yaml.safe_load(worker_group))
4949

5050
# read common configuration
51-
with open("/opt/playbook/vars/common_configuration.yaml", mode="r", encoding="utf-8") as common_configuration_file:
51+
with open("/opt/playbook/vars/common_configuration.yaml", mode="r", encoding="UTF-8") as common_configuration_file:
5252
common_config = yaml.safe_load(common_configuration_file)
5353

5454
# read clouds.yaml
55-
with open("/etc/openstack/clouds.yaml", mode="r", encoding="utf-8") as clouds_file:
55+
with open("/etc/openstack/clouds.yaml", mode="r", encoding="UTF-8") as clouds_file:
5656
clouds = yaml.safe_load(clouds_file)["clouds"]
5757

5858
connections = {} # connections to cloud providers

resources/playbook/tools/tee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def reader(pipe, queue):
3636
Thread(target=reader, args=[p.stdout, q]).start()
3737
Thread(target=reader, args=[p.stderr, q]).start()
3838

39-
with open(args.outfile, "w", encoding="utf-8") as outfile:
39+
with open(args.outfile, "w", encoding="UTF-8") as outfile:
4040
for line in iter(q.get, None):
4141
# print to stdout
4242
sys.stdout.write(line)

tests/integration/integration_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def start_cluster():
3232

3333
def read_cluster_info():
3434
"""Read last cluster information from bibigrid.mem file."""
35-
with open(MEM_FILE, "r", encoding="utf8") as f:
35+
with open(MEM_FILE, "r", encoding="UTF-8") as f:
3636
cluster_data = yaml.safe_load(f)
3737
return cluster_data["cluster_id"], cluster_data["floating_ip"], cluster_data["ssh_user"]
3838

tests/unit_tests/startup_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def suppress_stdout():
2222
Suppresses stdout within it
2323
@return:
2424
"""
25-
with open(os.devnull, "w", encoding="utf-8") as devnull:
25+
with open(os.devnull, "w", encoding="UTF-8") as devnull:
2626
old_stdout = sys.stdout
2727
sys.stdout = devnull
2828
try:

tests/unit_tests/test_validate_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TestValidateSchema(TestCase):
2121

2222
def test_validate_configurations(self):
2323
for bibigrid_configuration_name in glob.iglob(f'{TEST_CONFIGURATION_DIRECTORY}/*.yaml'):
24-
with open(bibigrid_configuration_name, mode="r", encoding="utf-8") as config_file:
24+
with open(bibigrid_configuration_name, mode="r", encoding="UTF-8") as config_file:
2525
config_yaml = yaml.safe_load(config_file)
2626
for cloud_config in config_yaml:
2727
cloud_config["cloud_identifier"] = "some"

0 commit comments

Comments
 (0)