提交 b908d3bd 编写于 作者: C cuixucui

Rectification specification scanning

上级 9a4eb383
......@@ -42,7 +42,7 @@ class Command:
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding='utf8')
encoding='utf-8')
(output, errors) = self.pipe.communicate()
if output:
#Strip new line character/s if any from the end of output string
......@@ -64,7 +64,7 @@ class Command:
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding='utf8')
encoding='utf-8')
def run(self, ignore_errors=False):
""" run the command
......@@ -92,6 +92,10 @@ class Command:
return
def print_output(self):
'''
结果显示
:return:
'''
if self.output:
for line in self.output:
sys.stdout.write(line)
......@@ -99,6 +103,10 @@ class Command:
sys.stdout.flush()
def print_errors(self):
'''
页面显示错误信息
:return:
'''
if self.errors:
for line in self.errors:
sys.stderr.write(line)
......@@ -106,14 +114,26 @@ class Command:
sys.stderr.flush()
def pid(self):
'''
获取管道pid值
:return:
'''
if self.pipe:
return self.pipe.pid
def readline(self):
'''
按行读取输出信息
:return
'''
if self.pipe:
return self.pipe.stdout.readline()
def read(self):
'''
执行命令,并读取结果
:return:
'''
self.pipe = subprocess.Popen(self.command, shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
......
......@@ -127,7 +127,7 @@ class EulerCertification():
cwd = os.getcwd()
os.chdir(os.path.dirname(doc_dir))
dir_name = "oech-" + datetime.datetime.now().strftime("%Y%m%d%H%M%S") + "-" + job.job_id
pack_name = dir_name +".tar"
pack_name = dir_name + ".tar"
cmd = Command("tar -cf %s %s" % (pack_name, dir_name))
try:
os.rename(job.job_id, dir_name)
......@@ -175,6 +175,11 @@ class EulerCertification():
return self.client.upload(path, server)
def get_tests(self, devices):
'''
获取测试项
:param devices:
:return:
'''
nodevice = ["cpufreq", "memory", "clock", "profiler", "system", "stress", "kdump", "perf", "acpi", "watchdog"]
ethernet = ["ethernet"]
infiniband = ["infiniband"]
......@@ -215,9 +220,9 @@ class EulerCertification():
empty_device = Device()
for device in devices:
if device.get_property("SUBSYSTEM") == "usb" and \
device.get_property("ID_VENDOR_FROM_DATABASE") == "Linux Foundation" and \
("2." in device.get_property("ID_MODEL_FROM_DATABASE") or \
"3." in device.get_property("ID_MODEL_FROM_DATABASE")):
device.get_property("ID_VENDOR_FROM_DATABASE") == "Linux Foundation" and \
("2." in device.get_property("ID_MODEL_FROM_DATABASE") or \
"3." in device.get_property("ID_MODEL_FROM_DATABASE")):
sort_devices["usb"] = [empty_device]
continue
if device.get_property("PCI_CLASS") == "30000" or device.get_property("PCI_CLASS") == "38000":
......@@ -230,7 +235,7 @@ class EulerCertification():
sort_devices["tape"] = [device]
continue
if (device.get_property("DEVTYPE") == "disk" and not device.get_property("ID_TYPE")) or \
device.get_property("ID_TYPE") == "disk":
device.get_property("ID_TYPE") == "disk":
if "nvme" in device.get_property("DEVPATH"):
sort_devices["disk"] = [empty_device]
try:
......@@ -268,7 +273,7 @@ class EulerCertification():
continue
if device.get_property("ID_CDROM") == "1":
types = ["DVD_RW", "DVD_PLUS_RW", "DVD_R", "DVD_PLUS_R", "DVD", \
"BD_RE", "BD_R", "BD", "CD_RW", "CD_R", "CD"]
"BD_RE", "BD_R", "BD", "CD_RW", "CD_R", "CD"]
for dev_type in types:
if device.get_property("ID_CDROM_" + dev_type) == "1":
try:
......@@ -318,11 +323,11 @@ class EulerCertification():
continue
if num > 0 and num <= len(self.test_factory):
self.test_factory[num-1]["run"] = not self.test_factory[num-1]["run"]
self.test_factory[num - 1]["run"] = not self.test_factory[num - 1]["run"]
continue
def show_tests(self):
print("\033[1;35m" + "No.".ljust(4) + "Run-Now?".ljust(10) \
print("\033[1;35m" + "No.".ljust(4) + "Run-Now?".ljust(10) \
+ "Status".ljust(8) + "Class".ljust(14) + "Device\033[0m")
num = 0
for test in self.test_factory:
......@@ -340,17 +345,17 @@ class EulerCertification():
num = num + 1
if status == "PASS":
print("%-6d"%num + run.ljust(8) + "\033[0;32mPASS \033[0m" \
+ name.ljust(14) + "%s"%device)
print("%-6d" % num + run.ljust(8) + "\033[0;32mPASS \033[0m" \
+ name.ljust(14) + "%s" % device)
elif status == "FAIL":
print("%-6d"%num + run.ljust(8) + "\033[0;31mFAIL \033[0m" \
+ name.ljust(14) + "%s"%device)
print("%-6d" % num + run.ljust(8) + "\033[0;31mFAIL \033[0m" \
+ name.ljust(14) + "%s" % device)
elif status == "Force":
print("%-6d"%num + run.ljust(8) + "\033[0;33mForce \033[0m" \
+ name.ljust(14) + "%s"%device)
print("%-6d" % num + run.ljust(8) + "\033[0;33mForce \033[0m" \
+ name.ljust(14) + "%s" % device)
else:
print("%-6d"%num + run.ljust(8) + "\033[0;34mNotRun \033[0m" \
+ name.ljust(14) + "%s"%device)
print("%-6d" % num + run.ljust(8) + "\033[0;34mNotRun \033[0m" \
+ name.ljust(14) + "%s" % device)
def choose_tests(self):
for test in self.test_factory:
......
......@@ -73,6 +73,14 @@ def get_results():
@app.route('/results/<host>/<oec_id>/<job>')
def get_job(host, oec_id, job):
'''
获取job信息
:param host:
:param oec_id:
:param job:
:return:
'''
dir_job = os.path.join(dir_results, host, oec_id, job)
json_info = os.path.join(dir_job, 'compatibility.json')
json_results = os.path.join(dir_job, 'factory.json')
......@@ -88,6 +96,14 @@ def get_job(host, oec_id, job):
@app.route('/results/<host>/<oec_id>/<job>/devices/<interface>')
def get_device(host, oec_id, job, interface):
'''
获取硬件设备信息
:param host:
:param oec_id:
:param job:
:param interface:
:return:
'''
dir_job = os.path.join(dir_results, host, oec_id, job)
json_results = os.path.join(dir_job, 'factory.json')
try:
......@@ -105,6 +121,13 @@ def get_device(host, oec_id, job, interface):
@app.route('/results/<host>/<oec_id>/<job>/devices')
def get_devices(host, oec_id, job):
'''
获取设备信息
:param host:
:param oec_id:
:param job:
:return:
'''
dir_job = os.path.join(dir_results, host, oec_id, job)
json_devices = os.path.join(dir_job, 'device.json')
try:
......@@ -117,6 +140,13 @@ def get_devices(host, oec_id, job):
@app.route('/results/<host>/<oec_id>/<job>/attachment')
def get_attachment(host, oec_id, job):
'''
发送结果附件
:param host:
:param oec_id:
:param job:
:return:
'''
dir_job = os.path.join(dir_results, host, oec_id, job)
attachment = dir_job + '.tar.gz'
filedir = os.path.dirname(attachment)
......@@ -126,6 +156,14 @@ def get_attachment(host, oec_id, job):
@app.route('/results/<host>/<oec_id>/<job>/logs/<name>')
def get_log(host, oec_id, job, name):
'''
获取日志
:param host:
:param oec_id:
:param job:
:param name:
:return:
'''
dir_job = os.path.join(dir_results, host, oec_id, job)
logpath = os.path.join(dir_job, name + '.log')
if not os.path.exists(logpath):
......@@ -140,6 +178,13 @@ def get_log(host, oec_id, job, name):
@app.route('/results/<host>/<oec_id>/<job>/submit')
def submit(host, oec_id, job):
'''
提交测试结果
:param host:
:param oec_id:
:param job:
:return:
'''
dir_job = os.path.join(dir_results, host, oec_id, job)
tar_job = dir_job + '.tar.gz'
json_cert = os.path.join(dir_job, 'compatibility.json')
......@@ -180,6 +225,10 @@ def submit(host, oec_id, job):
@app.route('/api/job/upload', methods=['GET', 'POST'])
def upload_job():
'''
上传job
:return:
'''
host = request.values.get('host', '').strip().replace(' ', '-')
oec_id = request.values.get('id', '').strip().replace(' ', '-')
job = request.values.get('job', '').strip().replace(' ', '-')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册