summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-20 11:57:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-02 08:24:01 +0100
commit3b3997174831931ea472167ba6cc854a4972ccce (patch)
tree861b0bcb54e70fbe59bf7920862954dcec40a1e8 /meta/lib/oeqa/utils
parent52c4b7f247618f185a11dfb1cf15d0490d074379 (diff)
downloadpoky-3b3997174831931ea472167ba6cc854a4972ccce.tar.gz
classes/lib: Complete transition to python3
This patch contains all the other misc pieces of the transition to python3 which didn't make sense to be broken into individual patches. (From OE-Core rev: fcd6b38bab8517d83e1ed48eef1bca9a9a190f57) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/commands.py4
-rw-r--r--meta/lib/oeqa/utils/decorators.py17
-rw-r--r--meta/lib/oeqa/utils/dump.py2
-rw-r--r--meta/lib/oeqa/utils/httpserver.py6
-rw-r--r--meta/lib/oeqa/utils/logparser.py2
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py22
-rw-r--r--meta/lib/oeqa/utils/qemutinyrunner.py2
-rw-r--r--meta/lib/oeqa/utils/targetbuild.py4
-rw-r--r--meta/lib/oeqa/utils/testexport.py2
9 files changed, 38 insertions, 23 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 9a7c1d1375..18fe39ecfe 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -41,7 +41,7 @@ class Command(object):
41 self.data = data 41 self.data = data
42 42
43 self.options = dict(self.defaultopts) 43 self.options = dict(self.defaultopts)
44 if isinstance(self.cmd, basestring): 44 if isinstance(self.cmd, str):
45 self.options["shell"] = True 45 self.options["shell"] = True
46 if self.data: 46 if self.data:
47 self.options['stdin'] = subprocess.PIPE 47 self.options['stdin'] = subprocess.PIPE
@@ -123,7 +123,7 @@ def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **optio
123 else: 123 else:
124 extra_args = "" 124 extra_args = ""
125 125
126 if isinstance(command, basestring): 126 if isinstance(command, str):
127 cmd = "bitbake " + extra_args + " " + command 127 cmd = "bitbake " + extra_args + " " + command
128 else: 128 else:
129 cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]] 129 cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]]
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index 6fb09db417..0b23565485 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -115,6 +115,8 @@ class NoParsingFilter(logging.Filter):
115 def filter(self, record): 115 def filter(self, record):
116 return record.levelno == 100 116 return record.levelno == 100
117 117
118import inspect
119
118def LogResults(original_class): 120def LogResults(original_class):
119 orig_method = original_class.run 121 orig_method = original_class.run
120 122
@@ -124,6 +126,19 @@ def LogResults(original_class):
124 logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log') 126 logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log')
125 linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log') 127 linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log')
126 128
129 def get_class_that_defined_method(meth):
130 if inspect.ismethod(meth):
131 for cls in inspect.getmro(meth.__self__.__class__):
132 if cls.__dict__.get(meth.__name__) is meth:
133 return cls
134 meth = meth.__func__ # fallback to __qualname__ parsing
135 if inspect.isfunction(meth):
136 cls = getattr(inspect.getmodule(meth),
137 meth.__qualname__.split('.<locals>', 1)[0].rsplit('.', 1)[0])
138 if isinstance(cls, type):
139 return cls
140 return None
141
127 #rewrite the run method of unittest.TestCase to add testcase logging 142 #rewrite the run method of unittest.TestCase to add testcase logging
128 def run(self, result, *args, **kws): 143 def run(self, result, *args, **kws):
129 orig_method(self, result, *args, **kws) 144 orig_method(self, result, *args, **kws)
@@ -135,7 +150,7 @@ def LogResults(original_class):
135 except AttributeError: 150 except AttributeError:
136 test_case = self._testMethodName 151 test_case = self._testMethodName
137 152
138 class_name = str(testMethod.im_class).split("'")[1] 153 class_name = str(get_class_that_defined_method(testMethod)).split("'")[1]
139 154
140 #create custom logging level for filtering. 155 #create custom logging level for filtering.
141 custom_log_level = 100 156 custom_log_level = 100
diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py
index 63a591d366..71422a9aea 100644
--- a/meta/lib/oeqa/utils/dump.py
+++ b/meta/lib/oeqa/utils/dump.py
@@ -3,7 +3,7 @@ import sys
3import errno 3import errno
4import datetime 4import datetime
5import itertools 5import itertools
6from commands import runCmd 6from .commands import runCmd
7 7
8def get_host_dumper(d): 8def get_host_dumper(d):
9 cmds = d.getVar("testimage_dump_host", True) 9 cmds = d.getVar("testimage_dump_host", True)
diff --git a/meta/lib/oeqa/utils/httpserver.py b/meta/lib/oeqa/utils/httpserver.py
index 76518d8ef9..bd76f36468 100644
--- a/meta/lib/oeqa/utils/httpserver.py
+++ b/meta/lib/oeqa/utils/httpserver.py
@@ -1,8 +1,8 @@
1import SimpleHTTPServer 1import http.server
2import multiprocessing 2import multiprocessing
3import os 3import os
4 4
5class HTTPServer(SimpleHTTPServer.BaseHTTPServer.HTTPServer): 5class HTTPServer(http.server.HTTPServer):
6 6
7 def server_start(self, root_dir): 7 def server_start(self, root_dir):
8 import signal 8 import signal
@@ -10,7 +10,7 @@ class HTTPServer(SimpleHTTPServer.BaseHTTPServer.HTTPServer):
10 os.chdir(root_dir) 10 os.chdir(root_dir)
11 self.serve_forever() 11 self.serve_forever()
12 12
13class HTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): 13class HTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
14 14
15 def log_message(self, format_str, *args): 15 def log_message(self, format_str, *args):
16 pass 16 pass
diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py
index 87b50354cd..b377dcd271 100644
--- a/meta/lib/oeqa/utils/logparser.py
+++ b/meta/lib/oeqa/utils/logparser.py
@@ -3,7 +3,7 @@
3import sys 3import sys
4import os 4import os
5import re 5import re
6import ftools 6from . import ftools
7 7
8 8
9# A parser that can be used to identify weather a line is a test result or a section statement. 9# A parser that can be used to identify weather a line is a test result or a section statement.
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 3d60433cae..e408fbbf3a 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -23,8 +23,8 @@ logger = logging.getLogger("BitBake.QemuRunner")
23 23
24# Get Unicode non printable control chars 24# Get Unicode non printable control chars
25control_range = list(range(0,32))+list(range(127,160)) 25control_range = list(range(0,32))+list(range(127,160))
26control_chars = [unichr(x) for x in control_range 26control_chars = [chr(x) for x in control_range
27 if unichr(x) not in string.printable] 27 if chr(x) not in string.printable]
28re_control_char = re.compile('[%s]' % re.escape("".join(control_chars))) 28re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
29 29
30class QemuRunner: 30class QemuRunner:
@@ -220,6 +220,7 @@ class QemuRunner:
220 stopread = False 220 stopread = False
221 qemusock = None 221 qemusock = None
222 bootlog = '' 222 bootlog = ''
223 data = b''
223 while time.time() < endtime and not stopread: 224 while time.time() < endtime and not stopread:
224 sread, swrite, serror = select.select(socklist, [], [], 5) 225 sread, swrite, serror = select.select(socklist, [], [], 5)
225 for sock in sread: 226 for sock in sread:
@@ -283,13 +284,14 @@ class QemuRunner:
283 if hasattr(self, "origchldhandler"): 284 if hasattr(self, "origchldhandler"):
284 signal.signal(signal.SIGCHLD, self.origchldhandler) 285 signal.signal(signal.SIGCHLD, self.origchldhandler)
285 if self.runqemu: 286 if self.runqemu:
286 os.kill(self.monitorpid, signal.SIGKILL) 287 if hasattr(self, "monitorpid"):
287 logger.info("Sending SIGTERM to runqemu") 288 os.kill(self.monitorpid, signal.SIGKILL)
288 try: 289 logger.info("Sending SIGTERM to runqemu")
289 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM) 290 try:
290 except OSError as e: 291 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM)
291 if e.errno != errno.ESRCH: 292 except OSError as e:
292 raise 293 if e.errno != errno.ESRCH:
294 raise
293 endtime = time.time() + self.runqemutime 295 endtime = time.time() + self.runqemutime
294 while self.runqemu.poll() is None and time.time() < endtime: 296 while self.runqemu.poll() is None and time.time() < endtime:
295 time.sleep(1) 297 time.sleep(1)
@@ -448,7 +450,7 @@ class LoggingThread(threading.Thread):
448 def stop(self): 450 def stop(self):
449 self.logger.info("Stopping logging thread") 451 self.logger.info("Stopping logging thread")
450 if self.running: 452 if self.running:
451 os.write(self.writepipe, "stop") 453 os.write(self.writepipe, bytes("stop", "utf-8"))
452 454
453 def teardown(self): 455 def teardown(self):
454 self.logger.info("Tearing down logging thread") 456 self.logger.info("Tearing down logging thread")
diff --git a/meta/lib/oeqa/utils/qemutinyrunner.py b/meta/lib/oeqa/utils/qemutinyrunner.py
index 054ab0ec5d..c823157ad6 100644
--- a/meta/lib/oeqa/utils/qemutinyrunner.py
+++ b/meta/lib/oeqa/utils/qemutinyrunner.py
@@ -13,7 +13,7 @@ import re
13import socket 13import socket
14import select 14import select
15import bb 15import bb
16from qemurunner import QemuRunner 16from .qemurunner import QemuRunner
17 17
18class QemuTinyRunner(QemuRunner): 18class QemuTinyRunner(QemuRunner):
19 19
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py
index f850d78df1..d538f6b65f 100644
--- a/meta/lib/oeqa/utils/targetbuild.py
+++ b/meta/lib/oeqa/utils/targetbuild.py
@@ -10,9 +10,7 @@ import bb.utils
10import subprocess 10import subprocess
11from abc import ABCMeta, abstractmethod 11from abc import ABCMeta, abstractmethod
12 12
13class BuildProject(): 13class BuildProject(metaclass=ABCMeta):
14
15 __metaclass__ = ABCMeta
16 14
17 def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"): 15 def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"):
18 self.d = d 16 self.d = d
diff --git a/meta/lib/oeqa/utils/testexport.py b/meta/lib/oeqa/utils/testexport.py
index 4fbf4bdcb3..57be2ca449 100644
--- a/meta/lib/oeqa/utils/testexport.py
+++ b/meta/lib/oeqa/utils/testexport.py
@@ -6,7 +6,7 @@
6 6
7import os, re, glob as g, shutil as sh,sys 7import os, re, glob as g, shutil as sh,sys
8from time import sleep 8from time import sleep
9from commands import runCmd 9from .commands import runCmd
10from difflib import SequenceMatcher as SM 10from difflib import SequenceMatcher as SM
11 11
12try: 12try: