Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting based on pylint report #643

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/csm_testing/tests/check_ncn_uan_ip_dns/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ def __call__(self, method, route, **kwargs):
def token():
# setup kubernetes client
config.load_kube_config()
v1 = client.CoreV1Api()
k8s_v1 = client.CoreV1Api()

# get kubernetes admin secret
secret = v1.read_namespaced_secret("admin-client-auth", "default").data
secret = k8s_v1.read_namespaced_secret("admin-client-auth", "default").data

# decode the base64 secret
token = base64.b64decode(secret['client-secret']).decode('utf-8')
decoded_token = base64.b64decode(secret['client-secret']).decode('utf-8')

# create post data to keycloak istio ingress
token_data = {
'grant_type': 'client_credentials',
'client_id': 'admin-client',
'client_secret': token
'client_secret': decoded_token
}

# query keycloack
Expand Down Expand Up @@ -175,16 +175,16 @@ def main(): # pylint: disable=missing-function-docstring
continue
ip_addresses = smd_entry['IPAddresses']
for ips in ip_addresses:
ip = ips['IPAddress']
# print (ip)
if ip == '':
ipa = ips['IPAddress']
# print (ipa)
if ipa == '':
continue
if ip not in ip_set:
ip_set.add(ip)
if ipa not in ip_set:
ip_set.add(ipa)
continue
log.error('Error: found duplicate IP: %s', ip)
log.error('Error: found duplicate IP: %s', ipa)
error_found = True
nslookup_cmd = subprocess.Popen(('nslookup', ip),
nslookup_cmd = subprocess.Popen(('nslookup', ipa),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, _ = nslookup_cmd.communicate()
Expand Down
1 change: 1 addition & 0 deletions src/csm_testing/tests/compare_k8s_ncns/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def check_k8s_node_info(k8s_node_info: K8sNodeInfo) -> bool:
print_err(f"Not all Kubernetes NCNs have the same {field}")
print(f"{node_info_values[field]}\n")
passed = False
return passed


def main() -> None: # pylint: disable=missing-function-docstring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,32 @@ def main() -> int: # pylint: disable=missing-function-docstring
level=L_LVL)
logging.info("%s Starting up", now())

fileDir = "/etc/dnsmasq.d/"
fileNames = ['CAN', 'NMN', 'HMN', 'mtl']
file_dir = "/etc/dnsmasq.d/"
file_names = ['CAN', 'NMN', 'HMN', 'mtl']
#contents = []

# Iterate over the list of filenames and try to open the file
for fileName in fileNames:
for file_name in file_names:
# clear the start and end strings
logging.info("%s Checking %s%s.", now(), fileDir, fileName)
logging.info("%s Checking %s%s.", now(), file_dir, file_name)
start = end = ''
try:
with open(fileDir + fileName + ".conf", 'r') as f:
with open(file_dir + file_name + ".conf", 'r') as file:
#contents = f.read().split('\n')
file_lines = f.readlines()
file_lines = file.readlines()
except Exception:
logging.critical("%s Couldn't open %s%s.conf.", now(), fileDir,
fileName)
print("Unable to open file: " + fileName + ".conf")
logging.critical("%s Couldn't open %s%s.conf.", now(), file_dir,
file_name)
print("Unable to open file: " + file_name + ".conf")
return 1

# if the contents of the file !NULL - read the file line-by-line
# and check if the line contains 'dhcp-range'
# it's a really good bet that the format of that line will not change

for line in file_lines:
logging.debug("%s line from %s: %s", now(), fileName, line.strip())
logging.debug("%s line from %s: %s", now(), file_name,
line.strip())
# If the line continas 'dhcp-range' extract the start and end addresses
if 'dhcp-range' in line:
start = line.split(',')[1]
Expand All @@ -105,8 +106,8 @@ def main() -> int: # pylint: disable=missing-function-docstring
return 0
logging.error(
"%s The file %s%s.conf failed. Start IP (%s) >= End IP (%s).",
now(), fileDir, fileName, start, end)
print("FAIL for file:" + fileDir + fileName + ".conf")
now(), file_dir, file_name, start, end)
print("FAIL for file:" + file_dir + file_name + ".conf")
return 3
print("FAIL - no starting IP address found")
return 4
Expand Down
4 changes: 2 additions & 2 deletions src/csm_testing/tools/print_goss_json_results/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def parse_args() -> Dict[str, StringList]:
if is_url(source):
sources["url"].append(source)
continue
elif source == "stdin" or source[:6] == "stdin:":
if source == "stdin" or source[:6] == "stdin:":
# Only allow a maximum of one stdin source
if sources["stdin"]:
stderr_print(
Expand All @@ -591,7 +591,7 @@ def parse_args() -> Dict[str, StringList]:
sys.exit(RC_USAGE)
sources["stdin"].append(source)
continue
elif is_suite_test_file(source):
if is_suite_test_file(source):
source_path = f"{goss_base()}/{source}"
sources["goss_file"].append(source_path)
else:
Expand Down
Loading