Skip to content

Commit 03ef04d

Browse files
author
Axel Dahlberg
authored
Merge pull request #1 from SoftwareQuTech/Develop
Updated how the paths to the CQC and APP files are read
2 parents 04534d1 + a71e77b commit 03ef04d

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

cqc/pythonLib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import socket
3636
import warnings
3737

38-
from cqc.settings import CQC_CONF_CQC_FILE, CQC_CONF_APP_FILE
38+
from cqc.settings import get_cqc_file, get_app_file
3939
from cqc.cqcHeader import (
4040
Header,
4141
CQCCmdHeader,
@@ -237,7 +237,7 @@ def __init__(self, name, socket_address=None, cqcFile=None, appFile=None, appID=
237237
if socket_address is None:
238238
# This file defines the network of CQC servers interfacing to virtual quantum nodes
239239
if cqcFile is None:
240-
self.cqcFile = CQC_CONF_CQC_FILE
240+
self.cqcFile = get_cqc_file()
241241
else:
242242
self.cqcFile = cqcFile
243243

@@ -290,7 +290,7 @@ def __init__(self, name, socket_address=None, cqcFile=None, appFile=None, appID=
290290

291291
# This file defines the application network
292292
if appFile is None:
293-
self.appFile = CQC_CONF_APP_FILE
293+
self.appFile = get_app_file()
294294
else:
295295
self.appFile = appFile
296296

cqc/settings.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,29 @@ def set_config(config):
5454
with open(settings_file, 'w') as f:
5555
config.write(f)
5656

57+
def get_cqc_file():
58+
"""
59+
Gets the path to the CQC file used
60+
:return: str
61+
"""
62+
config = get_config()
63+
try:
64+
file_path = config['FILEPATHS']['cqc_file']
65+
except KeyError:
66+
return None
67+
68+
return file_path
5769

58-
############################
59-
# CONFIGURATION FILE FOR CQC
60-
############################
61-
config = get_config()
6270

63-
# The path to the file specifying the addresses and ports of the CQC nodes
64-
# and the APP nodes.
65-
# If using SimulaQron, this will be set by SimulaQron.
66-
# Otherwise, specify the path to the files in the file settings.ini
67-
CQC_CONF_CQC_FILE = config['FILEPATHS']['cqc_file']
68-
CQC_CONF_APP_FILE = config['FILEPATHS']['app_file']
71+
def get_app_file():
72+
"""
73+
Gets the path to the APP file used
74+
:return: str
75+
"""
76+
config = get_config()
77+
try:
78+
file_path = config['FILEPATHS']['app_file']
79+
except KeyError:
80+
return None
81+
82+
return file_path

0 commit comments

Comments
 (0)