Commit 670e1fb8 authored by Robert Schmidt's avatar Robert Schmidt

CI: remove unknown imports and uses of names

pyflakes warns about various errors, addressed here. For cls_cluster.py,
remove (unknown) sys.exit and replace through Exception, as sys.exit()
has the unwanted effect that the CI script would stop.  Instead, raise
an Exception that would show the problem in the HTML, and ensures that
the script runs until the end.

These are the warnings flagged by pyflakes.

    cls_cluster.py:297:4: undefined name 'sys'

    cls_containerize.py:39:1: 'subprocess' imported but unused
    cls_containerize.py:41:1: 'threading' imported but unused
    cls_containerize.py:43:1: 'multiprocessing.Process' imported but unused
    cls_containerize.py:43:1: 'multiprocessing.Lock' imported but unused
    cls_containerize.py:43:1: 'multiprocessing.SimpleQueue' imported but unused
    cls_containerize.py:49:1: 'cls_cluster as OC' imported but unused
    cls_containerize.py:50:1: redefinition of unused 'cls_cmd' from line 42

    cls_module.py:28:1: 'os' imported but unused
    cls_module.py:29:1: 'sys' imported but unused
    cls_module.py:34:1: 'subprocess' imported but unused
    cls_module.py:35:1: 'datetime.datetime' imported but unused
    cls_module.py:211:11: undefined name 'sshconnection'

    cls_oaicitest.py:37:1: 'pexpect' imported but unused
    cls_oaicitest.py:47:1: 'cls_cluster as OC' imported but unused
    cls_oaicitest.py:54:1: 'matplotlib.pyplot as plt' imported but unused
    cls_oaicitest.py:55:1: 'numpy as np' imported but unused

    cls_oai_html.py:34:1: 'sys' imported but unused
    cls_oai_html.py:41:1: 'multiprocessing.Process' imported but unused
    cls_oai_html.py:41:1: 'multiprocessing.Lock' imported but unused
    cls_oai_html.py:41:1: 'multiprocessing.SimpleQueue' imported but unused

    cls_physim.py:37:1: 'multiprocessing.SimpleQueue' imported but unused

    cls_static_code_analysis.py:39:1: 'time' imported but unused
    cls_static_code_analysis.py:40:1: 'multiprocessing.Process' imported but unused
    cls_static_code_analysis.py:40:1: 'multiprocessing.Lock' imported but unused
    cls_static_code_analysis.py:40:1: 'multiprocessing.SimpleQueue' imported but unused

    epc.py:41:1: 'multiprocessing.Process' imported but unused
    epc.py:41:1: 'multiprocessing.Lock' imported but unused
    epc.py:41:1: 'multiprocessing.SimpleQueue' imported but unused

    main.py:60:1: 'pexpect' imported but unused
    main.py:66:1: 'datetime' imported but unused
    main.py:68:1: redefinition of unused 'subprocess' from line 63
    main.py:70:1: 'multiprocessing.Process' imported but unused
    main.py:70:1: 'multiprocessing.Lock' imported but unused
    main.py:70:1: 'multiprocessing.SimpleQueue' imported but unused

    provideUniqueImageTag.py:2:1: 'os' imported but unused
parent a736bec5
...@@ -50,9 +50,9 @@ CN_CONTAINERS = ["", "-c nrf", "-c amf", "-c smf", "-c upf", "-c ausf", "-c udm" ...@@ -50,9 +50,9 @@ CN_CONTAINERS = ["", "-c nrf", "-c amf", "-c smf", "-c upf", "-c ausf", "-c udm"
def OC_login(cmd, ocUserName, ocPassword, ocProjectName): def OC_login(cmd, ocUserName, ocPassword, ocProjectName):
if ocUserName == '' or ocPassword == '' or ocProjectName == '': if ocUserName == '' or ocPassword == '' or ocProjectName == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter: no OC Credentials') raise ValueError('Insufficient Parameter: no OC Credentials')
if OCRegistry.startswith("http") or OCRegistry.endswith("/"): if OCRegistry.startswith("http") or OCRegistry.endswith("/"):
sys.exit(f'ocRegistry {OCRegistry} should not start with http:// or https:// and not end on a slash /') raise ValueError(f'ocRegistry {OCRegistry} should not start with http:// or https:// and not end on a slash /')
ret = cmd.run(f'oc login -u {ocUserName} -p {ocPassword} --server {OCUrl}') ret = cmd.run(f'oc login -u {ocUserName} -p {ocPassword} --server {OCUrl}')
if ret.returncode != 0: if ret.returncode != 0:
logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m') logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m')
...@@ -244,7 +244,7 @@ class Cluster: ...@@ -244,7 +244,7 @@ class Cluster:
if self.testSvrId == None: self.testSvrId = self.eNBIPAddress if self.testSvrId == None: self.testSvrId = self.eNBIPAddress
if self.imageToPull == '': if self.imageToPull == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter') raise ValueError('Insufficient Parameter')
logging.debug(f'Pull OC image {self.imageToPull} to server {self.testSvrId}') logging.debug(f'Pull OC image {self.imageToPull} to server {self.testSvrId}')
self.testCase_id = HTML.testCase_id self.testCase_id = HTML.testCase_id
cmd = cls_cmd.getConnection(self.testSvrId) cmd = cls_cmd.getConnection(self.testSvrId)
...@@ -282,19 +282,19 @@ class Cluster: ...@@ -282,19 +282,19 @@ class Cluster:
def BuildClusterImage(self, HTML): def BuildClusterImage(self, HTML):
if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit(f'Insufficient Parameter: ranRepository {self.ranRepository} ranBranch {ranBranch} ranCommitID {self.ranCommitID}') raise ValueError(f'Insufficient Parameter: ranRepository {self.ranRepository} ranBranch {ranBranch} ranCommitID {self.ranCommitID}')
lIpAddr = self.eNBIPAddress lIpAddr = self.eNBIPAddress
lSourcePath = self.eNBSourceCodePath lSourcePath = self.eNBSourceCodePath
if lIpAddr == '' or lSourcePath == '': if lIpAddr == '' or lSourcePath == '':
sys.exit('Insufficient Parameter: eNBSourceCodePath missing') raise ValueError('Insufficient Parameter: eNBSourceCodePath missing')
ocUserName = self.OCUserName ocUserName = self.OCUserName
ocPassword = self.OCPassword ocPassword = self.OCPassword
ocProjectName = self.OCProjectName ocProjectName = self.OCProjectName
if ocUserName == '' or ocPassword == '' or ocProjectName == '': if ocUserName == '' or ocPassword == '' or ocProjectName == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter: no OC Credentials') raise ValueError('Insufficient Parameter: no OC Credentials')
if self.OCRegistry.startswith("http") or self.OCRegistry.endswith("/"): if self.OCRegistry.startswith("http") or self.OCRegistry.endswith("/"):
sys.exit(f'ocRegistry {self.OCRegistry} should not start with http:// or https:// and not end on a slash /') raise ValueError(f'ocRegistry {self.OCRegistry} should not start with http:// or https:// and not end on a slash /')
logging.debug(f'Building on cluster triggered from server: {lIpAddr}') logging.debug(f'Building on cluster triggered from server: {lIpAddr}')
self.cmd = cls_cmd.RemoteCmd(lIpAddr) self.cmd = cls_cmd.RemoteCmd(lIpAddr)
......
...@@ -31,7 +31,6 @@ import subprocess as sp ...@@ -31,7 +31,6 @@ import subprocess as sp
import os import os
import paramiko import paramiko
import uuid import uuid
import sys
import time import time
SSHTIMEOUT=7 SSHTIMEOUT=7
......
...@@ -36,17 +36,12 @@ import re # reg ...@@ -36,17 +36,12 @@ import re # reg
import logging import logging
import os import os
import shutil import shutil
import subprocess
import time import time
import threading
import cls_cmd
from multiprocessing import Process, Lock, SimpleQueue
from zipfile import ZipFile from zipfile import ZipFile
#----------------------------------------------------------- #-----------------------------------------------------------
# OAI Testing modules # OAI Testing modules
#----------------------------------------------------------- #-----------------------------------------------------------
import cls_cluster as OC
import cls_cmd import cls_cmd
import sshconnection as SSH import sshconnection as SSH
import helpreadme as HELP import helpreadme as HELP
......
...@@ -25,14 +25,10 @@ ...@@ -25,14 +25,10 @@
#--------------------------------------------------------------------- #---------------------------------------------------------------------
#to use isfile #to use isfile
import os
import sys
import logging import logging
#time.sleep #time.sleep
import time import time
import re import re
import subprocess
from datetime import datetime
import yaml import yaml
import cls_cmd import cls_cmd
...@@ -208,13 +204,6 @@ class Module_UE: ...@@ -208,13 +204,6 @@ class Module_UE:
def _enableTrace(self): def _enableTrace(self):
raise Exception("not implemented") raise Exception("not implemented")
mySSH = sshconnection.SSHConnection()
mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword)
#delete old artifacts
mySSH.command('echo ' + ' ' + ' | sudo -S rm -rf ci_qlog','\$',5)
#start Trace, artifact is created in home dir
mySSH.command('echo $USER; nohup sudo -E QLog/QLog -s ci_qlog -f NR5G.cfg > /dev/null 2>&1 &','\$', 5)
mySSH.close()
def _disableTrace(self): def _disableTrace(self):
raise Exception("not implemented") raise Exception("not implemented")
......
...@@ -31,14 +31,12 @@ ...@@ -31,14 +31,12 @@
#----------------------------------------------------------- #-----------------------------------------------------------
# Import # Import
#----------------------------------------------------------- #-----------------------------------------------------------
import sys # arg
import re # reg import re # reg
import fileinput import fileinput
import logging import logging
import os import os
import time import time
import subprocess import subprocess
from multiprocessing import Process, Lock, SimpleQueue
import constants as CONST import constants as CONST
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#----------------------------------------------------------- #-----------------------------------------------------------
import sys # arg import sys # arg
import re # reg import re # reg
import pexpect # pexpect
import time # sleep import time # sleep
import os import os
import logging import logging
...@@ -44,16 +43,11 @@ import json ...@@ -44,16 +43,11 @@ import json
#import our libs #import our libs
import helpreadme as HELP import helpreadme as HELP
import constants as CONST import constants as CONST
import cls_cluster as OC
import sshconnection import sshconnection
import cls_module import cls_module
import cls_cmd import cls_cmd
logging.getLogger("matplotlib").setLevel(logging.WARNING)
import matplotlib.pyplot as plt
import numpy as np
#----------------------------------------------------------- #-----------------------------------------------------------
# Helper functions used here and in other classes # Helper functions used here and in other classes
#----------------------------------------------------------- #-----------------------------------------------------------
......
...@@ -34,7 +34,6 @@ import sshconnection ...@@ -34,7 +34,6 @@ import sshconnection
#to update the HTML object #to update the HTML object
import cls_oai_html import cls_oai_html
import cls_cmd import cls_cmd
from multiprocessing import SimpleQueue
#for log folder maintenance #for log folder maintenance
import os import os
import re import re
......
...@@ -36,8 +36,6 @@ import re # reg ...@@ -36,8 +36,6 @@ import re # reg
import logging import logging
import os import os
from pathlib import Path from pathlib import Path
import time
from multiprocessing import Process, Lock, SimpleQueue
#----------------------------------------------------------- #-----------------------------------------------------------
# OAI Testing modules # OAI Testing modules
......
...@@ -38,8 +38,6 @@ import os ...@@ -38,8 +38,6 @@ import os
import time import time
import signal import signal
from multiprocessing import Process, Lock, SimpleQueue
#----------------------------------------------------------- #-----------------------------------------------------------
# OAI Testing modules # OAI Testing modules
#----------------------------------------------------------- #-----------------------------------------------------------
......
...@@ -57,17 +57,13 @@ import cls_oai_html ...@@ -57,17 +57,13 @@ import cls_oai_html
#----------------------------------------------------------- #-----------------------------------------------------------
import sys # arg import sys # arg
import re # reg import re # reg
import pexpect # pexpect
import time # sleep import time # sleep
import os import os
import subprocess import subprocess
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import logging import logging
import datetime
import signal import signal
import subprocess
import traceback import traceback
from multiprocessing import Process, Lock, SimpleQueue
logging.basicConfig( logging.basicConfig(
level=logging.DEBUG, level=logging.DEBUG,
stream=sys.stdout, stream=sys.stdout,
......
import argparse import argparse
import os
import re import re
import subprocess import subprocess
import sys import sys
......
...@@ -36,7 +36,6 @@ import re # reg ...@@ -36,7 +36,6 @@ import re # reg
import logging import logging
import os import os
import time import time
from multiprocessing import Process, Lock, SimpleQueue
import yaml import yaml
import cls_cmd import cls_cmd
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment