mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-23 04:11:54 +01:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f525374fbb | ||
|
42e62aed57 | ||
|
f5cfcafb08 | ||
|
7853d2c85c | ||
|
a9fcc75f60 | ||
|
cd8720b901 | ||
|
03569fb01f |
@@ -1,5 +1,3 @@
|
|||||||
#!__DEVLIB_SHELL__
|
|
||||||
|
|
||||||
CMD=$1
|
CMD=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
@@ -202,10 +202,10 @@ class DmesgCollector(CollectorBase):
|
|||||||
try:
|
try:
|
||||||
entry = self.entries[0]
|
entry = self.entries[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
i = 0
|
return ''
|
||||||
else:
|
else:
|
||||||
i = entry.line_nr
|
i = entry.line_nr
|
||||||
return '\n'.join(out.splitlines()[i:])
|
return '\n'.join(out.splitlines()[i:])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def entries(self):
|
def entries(self):
|
||||||
@@ -278,5 +278,5 @@ class DmesgCollector(CollectorBase):
|
|||||||
if self.output_path is None:
|
if self.output_path is None:
|
||||||
raise RuntimeError("Output path was not set.")
|
raise RuntimeError("Output path was not set.")
|
||||||
with open(self.output_path, 'wt') as f:
|
with open(self.output_path, 'wt') as f:
|
||||||
f.write(self.dmesg_out + '\n')
|
f.write((self.dmesg_out or '') + '\n')
|
||||||
return CollectorOutput([CollectorOutputEntry(self.output_path, 'file')])
|
return CollectorOutput([CollectorOutputEntry(self.output_path, 'file')])
|
||||||
|
@@ -17,6 +17,8 @@ import logging
|
|||||||
import re
|
import re
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from shlex import quote
|
from shlex import quote
|
||||||
|
import itertools
|
||||||
|
import warnings
|
||||||
|
|
||||||
from devlib.module import Module
|
from devlib.module import Module
|
||||||
from devlib.exception import TargetStableError
|
from devlib.exception import TargetStableError
|
||||||
@@ -123,9 +125,20 @@ class Controller(object):
|
|||||||
return cgroups
|
return cgroups
|
||||||
|
|
||||||
def move_tasks(self, source, dest, exclude=None):
|
def move_tasks(self, source, dest, exclude=None):
|
||||||
|
if isinstance(exclude, str):
|
||||||
|
warnings.warn("Controller.move_tasks() takes needs a _list_ of exclude patterns, not a string", DeprecationWarning)
|
||||||
|
exclude = [exclude]
|
||||||
|
|
||||||
if exclude is None:
|
if exclude is None:
|
||||||
exclude = []
|
exclude = []
|
||||||
|
|
||||||
|
exclude = ' '.join(
|
||||||
|
itertools.chain.from_iterable(
|
||||||
|
('-e', quote(pattern))
|
||||||
|
for pattern in exclude
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
srcg = self.cgroup(source)
|
srcg = self.cgroup(source)
|
||||||
dstg = self.cgroup(dest)
|
dstg = self.cgroup(dest)
|
||||||
|
|
||||||
@@ -133,7 +146,7 @@ class Controller(object):
|
|||||||
'cgroups_tasks_move {src} {dst} {exclude}'.format(
|
'cgroups_tasks_move {src} {dst} {exclude}'.format(
|
||||||
src=quote(srcg.directory),
|
src=quote(srcg.directory),
|
||||||
dst=quote(dstg.directory),
|
dst=quote(dstg.directory),
|
||||||
exclude=' '.join(map(quote, exclude))
|
exclude=exclude,
|
||||||
),
|
),
|
||||||
as_root=True,
|
as_root=True,
|
||||||
)
|
)
|
||||||
@@ -165,18 +178,11 @@ class Controller(object):
|
|||||||
self.logger.debug('Moving all tasks into %s', dest)
|
self.logger.debug('Moving all tasks into %s', dest)
|
||||||
|
|
||||||
# Build list of tasks to exclude
|
# Build list of tasks to exclude
|
||||||
grep_filters = ' '.join(
|
self.logger.debug(' using grep filter: %s', exclude)
|
||||||
'-e {}'.format(comm)
|
|
||||||
for comm in exclude
|
|
||||||
)
|
|
||||||
self.logger.debug(' using grep filter: %s', grep_filters)
|
|
||||||
if grep_filters != '':
|
|
||||||
self.logger.debug(' excluding tasks which name matches:')
|
|
||||||
self.logger.debug(' %s', ', '.join(exclude))
|
|
||||||
|
|
||||||
for cgroup in self.list_all():
|
for cgroup in self.list_all():
|
||||||
if cgroup != dest:
|
if cgroup != dest:
|
||||||
self.move_tasks(cgroup, dest, grep_filters)
|
self.move_tasks(cgroup, dest, exclude)
|
||||||
|
|
||||||
# pylint: disable=too-many-locals
|
# pylint: disable=too-many-locals
|
||||||
def tasks(self, cgroup,
|
def tasks(self, cgroup,
|
||||||
|
@@ -1202,14 +1202,10 @@ fi
|
|||||||
shutils_ifile = os.path.join(PACKAGE_BIN_DIRECTORY, 'scripts', 'shutils.in')
|
shutils_ifile = os.path.join(PACKAGE_BIN_DIRECTORY, 'scripts', 'shutils.in')
|
||||||
tmp_dir = tempfile.mkdtemp()
|
tmp_dir = tempfile.mkdtemp()
|
||||||
shutils_ofile = os.path.join(tmp_dir, 'shutils')
|
shutils_ofile = os.path.join(tmp_dir, 'shutils')
|
||||||
shell_path = '/bin/sh'
|
|
||||||
if self.os == 'android':
|
|
||||||
shell_path = '/system/bin/sh'
|
|
||||||
with open(shutils_ifile) as fh:
|
with open(shutils_ifile) as fh:
|
||||||
lines = fh.readlines()
|
lines = fh.readlines()
|
||||||
with open(shutils_ofile, 'w') as ofile:
|
with open(shutils_ofile, 'w') as ofile:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = line.replace("__DEVLIB_SHELL__", shell_path)
|
|
||||||
line = line.replace("__DEVLIB_BUSYBOX__", self.busybox)
|
line = line.replace("__DEVLIB_BUSYBOX__", self.busybox)
|
||||||
ofile.write(line)
|
ofile.write(line)
|
||||||
self._shutils = self.install(shutils_ofile)
|
self._shutils = self.install(shutils_ofile)
|
||||||
@@ -1218,7 +1214,7 @@ fi
|
|||||||
|
|
||||||
@call_conn
|
@call_conn
|
||||||
def _execute_util(self, command, timeout=None, check_exit_code=True, as_root=False):
|
def _execute_util(self, command, timeout=None, check_exit_code=True, as_root=False):
|
||||||
command = '{} {}'.format(self.shutils, command)
|
command = '{} sh {} {}'.format(quote(self.busybox), quote(self.shutils), command)
|
||||||
return self.conn.execute(command, timeout, check_exit_code, as_root)
|
return self.conn.execute(command, timeout, check_exit_code, as_root)
|
||||||
|
|
||||||
def _extract_archive(self, path, cmd, dest=None):
|
def _extract_archive(self, path, cmd, dest=None):
|
||||||
@@ -1576,8 +1572,23 @@ class AndroidTarget(Target):
|
|||||||
conn_cls=conn_cls,
|
conn_cls=conn_cls,
|
||||||
is_container=is_container)
|
is_container=is_container)
|
||||||
self.package_data_directory = package_data_directory
|
self.package_data_directory = package_data_directory
|
||||||
|
self._init_logcat_lock()
|
||||||
|
|
||||||
|
def _init_logcat_lock(self):
|
||||||
self.clear_logcat_lock = threading.Lock()
|
self.clear_logcat_lock = threading.Lock()
|
||||||
|
|
||||||
|
def __getstate__(self):
|
||||||
|
dct = super().__getstate__()
|
||||||
|
return {
|
||||||
|
k: v
|
||||||
|
for k, v in dct.items()
|
||||||
|
if k not in ('clear_logcat_lock',)
|
||||||
|
}
|
||||||
|
|
||||||
|
def __setstate__(self, dct):
|
||||||
|
self.__dict__.update(dct)
|
||||||
|
self._init_logcat_lock()
|
||||||
|
|
||||||
def reset(self, fastboot=False): # pylint: disable=arguments-differ
|
def reset(self, fastboot=False): # pylint: disable=arguments-differ
|
||||||
try:
|
try:
|
||||||
self.execute('reboot {}'.format(fastboot and 'fastboot' or ''),
|
self.execute('reboot {}'.format(fastboot and 'fastboot' or ''),
|
||||||
|
@@ -21,7 +21,7 @@ from subprocess import Popen, PIPE
|
|||||||
|
|
||||||
VersionTuple = namedtuple('Version', ['major', 'minor', 'revision', 'dev'])
|
VersionTuple = namedtuple('Version', ['major', 'minor', 'revision', 'dev'])
|
||||||
|
|
||||||
version = VersionTuple(1, 3, 3, '')
|
version = VersionTuple(1, 3, 4, '')
|
||||||
|
|
||||||
|
|
||||||
def get_devlib_version():
|
def get_devlib_version():
|
||||||
|
Reference in New Issue
Block a user