_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q242300
_add_filehandler
train
def _add_filehandler(logger, logpath, formatter=None, name="Bench"): """ Adds a FileHandler to logger. :param logger: Logger. :param logpath: Path to file. :param formatter: Formatter to be used :param name: Name for logger :return: Logger """ formatter = formatter if formatter else...
python
{ "resource": "" }
q242301
_get_basic_logger
train
def _get_basic_logger(loggername, log_to_file, logpath): """ Get a logger with our basic configuration done. :param loggername: Name of logger. :param log_to_file: Boolean, True if this logger should write a file. :return: Logger """ logger = logging.getLogger(loggername) logger.propaga...
python
{ "resource": "" }
q242302
get_resourceprovider_logger
train
def get_resourceprovider_logger(name=None, short_name=" ", log_to_file=True): """ Get a logger for ResourceProvider and it's components, such as Allocators. :param name: Name for logger :param short_name: Shorthand name for the logger :param log_to_file: Boolean, True if logger should log to a file...
python
{ "resource": "" }
q242303
get_external_logger
train
def get_external_logger(name=None, short_name=" ", log_to_file=True): """ Get a logger for external modules, whose logging should usually be on a less verbose level. :param name: Name for logger :param short_name: Shorthand name for logger :param log_to_file: Boolean, True if logger should log to a...
python
{ "resource": "" }
q242304
get_bench_logger
train
def get_bench_logger(name=None, short_name=" ", log_to_file=True): """ Return a logger instance for given name. The logger will be a child of the bench logger, so anything that is logged to it, will be also logged to bench logger. If a logger with the given name doesn't already exist, create it usi...
python
{ "resource": "" }
q242305
init_base_logging
train
def init_base_logging(directory="./log", verbose=0, silent=False, color=False, no_file=False, truncate=True, config_location=None): """ Initialize the Icetea logging by creating a directory to store logs for this run and initialize the console logger for Icetea itself. :param dire...
python
{ "resource": "" }
q242306
_read_config
train
def _read_config(config_location): """ Read configuration for logging from a json file. Merges the read dictionary to LOGGING_CONFIG. :param config_location: Location of file. :return: nothing. """ global LOGGING_CONFIG with open(config_location, "r") as config_loc: cfg_file = json....
python
{ "resource": "" }
q242307
BenchFormatterWithType.format
train
def format(self, record): """ Format record with formatter. :param record: Record to format :return: Formatted record """ if not hasattr(record, "type"): record.type = " " return self._formatter.format(record)
python
{ "resource": "" }
q242308
format_message
train
def format_message(msg): """ Formatting function for assert messages. Fetches the filename, function and line number of the code causing the fail and formats it into a three-line error message. Stack inspection is used to get the information. Originally done by BLE-team for their testcases. :pa...
python
{ "resource": "" }
q242309
assertTraceDoesNotContain
train
def assertTraceDoesNotContain(response, message): """ Raise TestStepFail if response.verify_trace finds message from response traces. :param response: Response. Must contain method verify_trace :param message: Message to look for :return: Nothing :raises: AttributeError if response does not con...
python
{ "resource": "" }
q242310
assertTraceContains
train
def assertTraceContains(response, message): """ Raise TestStepFail if response.verify_trace does not find message from response traces. :param response: Response. Must contain method verify_trace :param message: Message to look for :return: Nothing :raises: AttributeError if response does not c...
python
{ "resource": "" }
q242311
assertDutTraceDoesNotContain
train
def assertDutTraceDoesNotContain(dut, message, bench): """ Raise TestStepFail if bench.verify_trace does not find message from dut traces. :param dut: Dut object. :param message: Message to look for. :param: Bench, must contain verify_trace method. :raises: AttributeError if bench does not cont...
python
{ "resource": "" }
q242312
assertNone
train
def assertNone(expr, message=None): """ Assert that expr is None. :param expr: expression. :param message: Message set to raised Exception :raises: TestStepFail if expr is not None. """ if expr is not None: raise TestStepFail( format_message(message) if message is not No...
python
{ "resource": "" }
q242313
assertNotNone
train
def assertNotNone(expr, message=None): """ Assert that expr is not None. :param expr: expression. :param message: Message set to raised Exception :raises: TestStepFail if expr is None. """ if expr is None: raise TestStepFail( format_message(message) if message is not Non...
python
{ "resource": "" }
q242314
assertEqual
train
def assertEqual(first, second, message=None): """ Assert that first equals second. :param first: First part to evaluate :param second: Second part to evaluate :param message: Failure message :raises: TestStepFail if not first == second """ if not first == second: raise TestStepF...
python
{ "resource": "" }
q242315
assertNotEqual
train
def assertNotEqual(first, second, message=None): """ Assert that first does not equal second. :param first: First part to evaluate :param second: Second part to evaluate :param message: Failure message :raises: TestStepFail if not first != second """ if not first != second: rais...
python
{ "resource": "" }
q242316
assertJsonContains
train
def assertJsonContains(jsonStr=None, key=None, message=None): """ Assert that jsonStr contains key. :param jsonStr: Json as string :param key: Key to look for :param message: Failure message :raises: TestStepFail if key is not in jsonStr or if loading jsonStr to a dictionary fails or if jso...
python
{ "resource": "" }
q242317
get_path
train
def get_path(filename): """ Get absolute path for filename. :param filename: file :return: path """ path = abspath(filename) if os.path.isdir(filename) else dirname(abspath(filename)) return path
python
{ "resource": "" }
q242318
get_git_file_path
train
def get_git_file_path(filename): """ Get relative path for filename in git root. :param filename: File name :return: relative path or None """ git_root = get_git_root(filename) return relpath(filename, git_root).replace("\\", "/") if git_root else ''
python
{ "resource": "" }
q242319
get_git_info
train
def get_git_info(git_folder, verbose=False): """ Detect GIT information by folder. :param git_folder: Folder :param verbose: Verbosity, boolean, default is False :return: dict """ if verbose: print("detect GIT info by folder: '%s'" % git_folder) try: git_info = { ...
python
{ "resource": "" }
q242320
__get_git_bin
train
def __get_git_bin(): """ Get git binary location. :return: Check git location """ git = 'git' alternatives = [ '/usr/bin/git' ] for alt in alternatives: if os.path.exists(alt): git = alt break return git
python
{ "resource": "" }
q242321
Result.build
train
def build(self): """ get build name. :return: build name. None if not found """ # pylint: disable=len-as-condition if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None): return self.dutinformation.get(0).build.name return ...
python
{ "resource": "" }
q242322
Result.build_date
train
def build_date(self): """ get build date. :return: build date. None if not found """ # pylint: disable=len-as-condition if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None): return self.dutinformation.get(0).build.date re...
python
{ "resource": "" }
q242323
Result.build_sha1
train
def build_sha1(self): """ get sha1 hash of build. :return: build sha1 or None if not found """ # pylint: disable=len-as-condition if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None): return self.dutinformation.get(0).build.sha1 ...
python
{ "resource": "" }
q242324
Result.build_git_url
train
def build_git_url(self): """ get build git url. :return: build git url or None if not found """ # pylint: disable=len-as-condition if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None): return self.dutinformation.get(0).build.gitu...
python
{ "resource": "" }
q242325
Result.build_data
train
def build_data(self): """ get build data. :return: build data or None if not found """ # pylint: disable=len-as-condition if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None): return self.dutinformation.get(0).build.get_data() ...
python
{ "resource": "" }
q242326
Result.build_branch
train
def build_branch(self): """ get build branch. :return: build branch or None if not found """ # pylint: disable=len-as-condition if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None): return self.dutinformation.get(0).build.branch ...
python
{ "resource": "" }
q242327
Result.buildcommit
train
def buildcommit(self): """ get build commit id. :return: build commit id or None if not found """ # pylint: disable=len-as-condition if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None): return self.dutinformation.get(0).build.co...
python
{ "resource": "" }
q242328
Result.set_verdict
train
def set_verdict(self, verdict, retcode=-1, duration=-1): """ Set the final verdict for this Result. :param verdict: Verdict, must be from ['pass', 'fail', 'unknown', 'skip', 'inconclusive']' :param retcode: integer return code :param duration: test duration :return: Noth...
python
{ "resource": "" }
q242329
Result.build_result_metadata
train
def build_result_metadata(self, data=None, args=None): """ collect metadata into this object :param data: dict :param args: build from args instead of data """ data = data if data else self._build_result_metainfo(args) if data.get("build_branch"): sel...
python
{ "resource": "" }
q242330
Result._build_result_metainfo
train
def _build_result_metainfo(args): """ Internal helper for collecting metadata from args to results """ data = dict() if hasattr(args, "branch") and args.branch: data["build_branch"] = args.branch if hasattr(args, "commitId") and args.commitId: data...
python
{ "resource": "" }
q242331
Result.get_duration
train
def get_duration(self, seconds=False): """ Get test case duration. :param seconds: if set to True, return tc duration in seconds, otherwise as str( datetime.timedelta) :return: str(datetime.timedelta) or duration as string in seconds """ if seconds: r...
python
{ "resource": "" }
q242332
Result.has_logs
train
def has_logs(self): """ Check if log files are available and return file names if they exist. :return: list """ found_files = [] if self.logpath is None: return found_files if os.path.exists(self.logpath): for root, _, files in os.walk(os....
python
{ "resource": "" }
q242333
DutProcess.open_connection
train
def open_connection(self): """ Open connection by starting the process. :raises: DutConnectionError """ self.logger.debug("Open CLI Process '%s'", (self.comport), extra={'type': '<->'}) self.cmd = self.comport if isinstance(self.comport, list) e...
python
{ "resource": "" }
q242334
DutProcess.writeline
train
def writeline(self, data, crlf="\n"): # pylint: disable=arguments-differ """ Write data to process. :param data: data to write :param crlf: line end character :return: Nothing """ GenericProcess.writeline(self, data, crlf=crlf)
python
{ "resource": "" }
q242335
FileApiPlugin._jsonfileconstructor
train
def _jsonfileconstructor(self, filename=None, filepath=None, logger=None): """ Constructor method for the JsonFile object. :param filename: Name of the file :param filepath: Path to the file :param logger: Optional logger. :return: JsonFile """ if filepat...
python
{ "resource": "" }
q242336
NonBlockingStreamReader._get_sd
train
def _get_sd(file_descr): """ Get streamdescriptor matching file_descr fileno. :param file_descr: file object :return: StreamDescriptor or None """ for stream_descr in NonBlockingStreamReader._streams: if file_descr == stream_descr.stream.fileno(): ...
python
{ "resource": "" }
q242337
NonBlockingStreamReader._read_fd
train
def _read_fd(file_descr): """ Read incoming data from file handle. Then find the matching StreamDescriptor by file_descr value. :param file_descr: file object :return: Return number of bytes read """ try: line = os.read(file_descr, 1024 * 1024) ...
python
{ "resource": "" }
q242338
NonBlockingStreamReader._read_select_kqueue
train
def _read_select_kqueue(k_queue): """ Read PIPES using BSD Kqueue """ npipes = len(NonBlockingStreamReader._streams) # Create list of kevent objects # pylint: disable=no-member kevents = [select.kevent(s.stream.fileno(), filter=sel...
python
{ "resource": "" }
q242339
NonBlockingStreamReader.stop
train
def stop(self): """ Stop the reader """ # print('stopping NonBlockingStreamReader..') # print('acquire..') NonBlockingStreamReader._stream_mtx.acquire() # print('acquire..ok') NonBlockingStreamReader._streams.remove(self._descriptor) if not NonBloc...
python
{ "resource": "" }
q242340
GenericProcess.use_gdbs
train
def use_gdbs(self, gdbs=True, port=2345): """ Set gdbs use for process. :param gdbs: Boolean, default is True :param port: Port number for gdbserver """ self.gdbs = gdbs self.gdbs_port = port
python
{ "resource": "" }
q242341
GenericProcess.use_valgrind
train
def use_valgrind(self, tool, xml, console, track_origins, valgrind_extra_params): """ Use Valgrind. :param tool: Tool name, must be memcheck, callgrind or massif :param xml: Boolean output xml :param console: Dump output to console, Boolean :param track_origins: Boolean,...
python
{ "resource": "" }
q242342
GenericProcess.__get_valgrind_params
train
def __get_valgrind_params(self): """ Get Valgrind command as list. :return: list """ valgrind = [] if self.valgrind: valgrind.extend(['valgrind']) if self.valgrind == 'memcheck': valgrind.extend(['--tool=memcheck', '--leak-check=fu...
python
{ "resource": "" }
q242343
GenericProcess.writeline
train
def writeline(self, data, crlf="\r\n"): """ Writeline implementation. :param data: Data to write :param crlf: Line end characters, defailt is \r\n :return: Nothing :raises: RuntimeError if errors happen while writing to PIPE or process stops. """ if self....
python
{ "resource": "" }
q242344
SeedInteger.load
train
def load(filename): """ Load seed from a file. :param filename: Source file name :return: SeedInteger """ json_obj = Seed.load(filename) return SeedInteger(json_obj["seed_value"], json_obj["seed_id"], json_obj["date"])
python
{ "resource": "" }
q242345
EnhancedSerial.get_pyserial_version
train
def get_pyserial_version(self): """! Retrieve pyserial module version @return Returns float with pyserial module number """ pyserial_version = pkg_resources.require("pyserial")[0].version version = 3.0 match = self.re_float.search(pyserial_version) if match: ...
python
{ "resource": "" }
q242346
EnhancedSerial.readline
train
def readline(self, timeout=1): """ maxsize is ignored, timeout in seconds is the max time that is way for a complete line """ tries = 0 while 1: try: block = self.read(512) if isinstance(block, bytes): block = block....
python
{ "resource": "" }
q242347
EnhancedSerial.readlines
train
def readlines(self, timeout=1): """ read all lines that are available. abort after timeout when no more data arrives. """ lines = [] while 1: line = self.readline(timeout=timeout) if line: lines.append(line) if not line ...
python
{ "resource": "" }
q242348
ResourceRequirements.set
train
def set(self, key, value): """ Sets the value for a specific requirement. :param key: Name of requirement to be set :param value: Value to set for requirement key :return: Nothing, modifies requirement """ if key == "tags": self._set_tag(tags=value) ...
python
{ "resource": "" }
q242349
ResourceRequirements._set_tag
train
def _set_tag(self, tag=None, tags=None, value=True): """ Sets the value of a specific tag or merges existing tags with a dict of new tags. Either tag or tags must be None. :param tag: Tag which needs to be set. :param tags: Set of tags which needs to be merged with existing tags...
python
{ "resource": "" }
q242350
icetea_main
train
def icetea_main(): """ Main function for running Icetea. Calls sys.exit with the return code to exit. :return: Nothing. """ from icetea_lib import IceteaManager manager = IceteaManager.IceteaManager() return_code = manager.run() sys.exit(return_code)
python
{ "resource": "" }
q242351
build_docs
train
def build_docs(location="doc-source", target=None, library="icetea_lib"): """ Build documentation for Icetea. Start by autogenerating module documentation and finish by building html. :param location: Documentation source :param target: Documentation target path :param library: Library location...
python
{ "resource": "" }
q242352
find_next
train
def find_next(lines, find_str, start_index): """ Find the next instance of find_str from lines starting from start_index. :param lines: Lines to look through :param find_str: String or Invert to look for :param start_index: Index to start from :return: (boolean, index, line) """ mode = ...
python
{ "resource": "" }
q242353
verify_message
train
def verify_message(lines, expected_response): """ Looks for expectedResponse in lines. :param lines: a list of strings to look through :param expected_response: list or str to look for in lines. :return: True or False. :raises: TypeError if expectedResponse was not list or str. LookUpError ...
python
{ "resource": "" }
q242354
_cleanlogs
train
def _cleanlogs(silent=False, log_location="log"): """ Cleans up Mbed-test default log directory. :param silent: Defaults to False :param log_location: Location of log files, defaults to "log" :return: Nothing """ try: print("cleaning up Icetea log directory.") shutil.rmtree(...
python
{ "resource": "" }
q242355
IceteaManager.list_suites
train
def list_suites(suitedir="./testcases/suites", cloud=False): """ Static method for listing suites from both local source and cloud. Uses PrettyTable to generate the table. :param suitedir: Local directory for suites. :param cloud: cloud module :return: PrettyTable object...
python
{ "resource": "" }
q242356
IceteaManager._parse_arguments
train
def _parse_arguments(): """ Static method for paring arguments """ parser = get_base_arguments(get_parser()) parser = get_tc_arguments(parser) args, unknown = parser.parse_known_args() return args, unknown
python
{ "resource": "" }
q242357
IceteaManager.check_args
train
def check_args(self): """ Validates that a valid number of arguments were received and that all arguments were recognised. :return: True or False. """ parser = get_base_arguments(get_parser()) parser = get_tc_arguments(parser) # Disable "Do not use len(SE...
python
{ "resource": "" }
q242358
IceteaManager._init_pluginmanager
train
def _init_pluginmanager(self): """ Initialize PluginManager and load run wide plugins. """ self.pluginmanager = PluginManager(logger=self.logger) self.logger.debug("Registering execution wide plugins:") self.pluginmanager.load_default_run_plugins() self.pluginmana...
python
{ "resource": "" }
q242359
IceteaManager.run
train
def run(self, args=None): """ Runs the set of tests within the given path. """ # Disable "Too many branches" and "Too many return statemets" warnings # pylint: disable=R0912,R0911 retcodesummary = ExitCodes.EXIT_SUCCESS self.args = args if args else self.args ...
python
{ "resource": "" }
q242360
IceteaManager._cleanup_resourceprovider
train
def _cleanup_resourceprovider(self): """ Calls cleanup for ResourceProvider of this run. :return: Nothing """ # Disable too broad exception warning # pylint: disable=W0703 self.resourceprovider = ResourceProvider(self.args) try: self.resourcep...
python
{ "resource": "" }
q242361
IceteaManager._init_cloud
train
def _init_cloud(self, cloud_arg): """ Initializes Cloud module if cloud_arg is set. :param cloud_arg: taken from args.cloud :return: cloud module object instance """ # Disable too broad exception warning # pylint: disable=W0703 cloud = None if clo...
python
{ "resource": "" }
q242362
ReportHtml.generate
train
def generate(self, *args, **kwargs): """ Implementation for the generate method defined in ReportBase. Generates a html report and saves it. :param args: 1 argument, which is the filename :param kwargs: 3 keyword arguments with keys 'title', 'heads' and 'refresh' :return...
python
{ "resource": "" }
q242363
check_int
train
def check_int(integer): """ Check if number is integer or not. :param integer: Number as str :return: Boolean """ if not isinstance(integer, str): return False if integer[0] in ('-', '+'): return integer[1:].isdigit() return integer.isdigit()
python
{ "resource": "" }
q242364
_is_pid_running_on_unix
train
def _is_pid_running_on_unix(pid): """ Check if PID is running for Unix systems. """ try: os.kill(pid, 0) except OSError as err: # if error is ESRCH, it means the process doesn't exist return not err.errno == os.errno.ESRCH return True
python
{ "resource": "" }
q242365
_is_pid_running_on_windows
train
def _is_pid_running_on_windows(pid): """ Check if PID is running for Windows systems """ import ctypes.wintypes kernel32 = ctypes.windll.kernel32 handle = kernel32.OpenProcess(1, 0, pid) if handle == 0: return False exit_code = ctypes.wintypes.DWORD() ret = kernel32.GetExitC...
python
{ "resource": "" }
q242366
strip_escape
train
def strip_escape(string='', encoding="utf-8"): # pylint: disable=redefined-outer-name """ Strip escape characters from string. :param string: string to work on :param encoding: string name of the encoding used. :return: stripped string """ matches = [] try: if hasattr(string, "...
python
{ "resource": "" }
q242367
import_module
train
def import_module(modulename): """ Static method for importing module modulename. Can handle relative imports as well. :param modulename: Name of module to import. Can be relative :return: imported module instance. """ module = None try: module = importlib.import_module(modulename) ...
python
{ "resource": "" }
q242368
get_abs_path
train
def get_abs_path(relative_path): """ Get absolute path for relative path. :param relative_path: Relative path :return: absolute path """ abs_path = os.path.sep.join( os.path.abspath(sys.modules[__name__].__file__).split(os.path.sep)[:-1]) abs_path = os.path.abspath(abs_path + os.pat...
python
{ "resource": "" }
q242369
get_pkg_version
train
def get_pkg_version(pkg_name, parse=False): """ Verify and get installed python package version. :param pkg_name: python package name :param parse: parse version number with pkg_resourc.parse_version -function :return: None if pkg is not installed, otherwise version as a string or parsed ver...
python
{ "resource": "" }
q242370
generate_object_graphs_by_class
train
def generate_object_graphs_by_class(classlist): """ Generate reference and backreference graphs for objects of type class for each class given in classlist. Useful for debugging reference leaks in framework etc. Usage example to generate graphs for class "someclass": >>> import someclass >>...
python
{ "resource": "" }
q242371
remove_empty_from_dict
train
def remove_empty_from_dict(dictionary): """ Remove empty items from dictionary d :param dictionary: :return: """ if isinstance(dictionary, dict): return dict( (k, remove_empty_from_dict(v)) for k, v in iteritems( dictionary) if v and remove_empt...
python
{ "resource": "" }
q242372
set_or_delete
train
def set_or_delete(dictionary, key, value): """ Set value as value of dict key key. If value is None, delete key key from dict. :param dictionary: Dictionary to work on. :param key: Key to set or delete. If deleting and key does not exist in dict, nothing is done. :param value: Value to set. If valu...
python
{ "resource": "" }
q242373
initLogger
train
def initLogger(name): # pylint: disable=invalid-name ''' Initializes a basic logger. Can be replaced when constructing the HttpApi object or afterwards with setter ''' logger = logging.getLogger(name) logger.setLevel(logging.INFO) # Skip attaching StreamHandler if one is already attached to...
python
{ "resource": "" }
q242374
find_duplicate_keys
train
def find_duplicate_keys(data): """ Find duplicate keys in a layer of ordered pairs. Intended as the object_pairs_hook callable for json.load or loads. :param data: ordered pairs :return: Dictionary with no duplicate keys :raises ValueError if duplicate keys are found """ out_dict = {} ...
python
{ "resource": "" }
q242375
BuildFile._load
train
def _load(self): """ Function load. :return: file contents :raises: NotFoundError if file not found """ if self.is_exists(): return open(self._ref, "rb").read() raise NotFoundError("File %s not found" % self._ref)
python
{ "resource": "" }
q242376
BuildHttp.get_file
train
def get_file(self): """ Load data into a file and return file path. :return: path to file as string """ content = self._load() if not content: return None filename = "temporary_file.bin" with open(filename, "wb") as file_name: file...
python
{ "resource": "" }
q242377
DutInformation.as_dict
train
def as_dict(self): """ Generate a dictionary of the contents of this DutInformation object. :return: dict """ my_info = {} if self.platform: my_info["model"] = self.platform if self.resource_id: my_info["sn"] = self.resource_id if ...
python
{ "resource": "" }
q242378
DutInformationList.get_resource_ids
train
def get_resource_ids(self): """ Get resource ids as a list. :return: List of resource id:s or "unknown" """ resids = [] if self.dutinformations: for info in self.dutinformations: resids.append(info.resource_id) return resids ...
python
{ "resource": "" }
q242379
DutInformationList.push_resource_cache
train
def push_resource_cache(resourceid, info): """ Cache resource specific information :param resourceid: Resource id as string :param info: Dict to push :return: Nothing """ if not resourceid: raise ResourceInitError("Resource id missing") if not...
python
{ "resource": "" }
q242380
DutInformationList.get_resource_cache
train
def get_resource_cache(resourceid): """ Get a cached dictionary related to an individual resourceid. :param resourceid: String resource id. :return: dict """ if not resourceid: raise ResourceInitError("Resource id missing") if not DutInformationList._...
python
{ "resource": "" }
q242381
create_result_object
train
def create_result_object(result): """ Create cloud result object from Result. :param result: Result :return: dictionary """ _result = { 'tcid': result.get_tc_name(), 'campaign': result.campaign, 'cre': { 'user': result.tester }, 'job': { ...
python
{ "resource": "" }
q242382
append_logs_to_result_object
train
def append_logs_to_result_object(result_obj, result): """ Append log files to cloud result object from Result. :param result_obj: Target result object :param result: Result :return: Nothing, modifies result_obj in place. """ logs = result.has_logs() result_obj["exec"]["logs"] = [] i...
python
{ "resource": "" }
q242383
DutDetection.get_available_devices
train
def get_available_devices(self): """ Gets available devices using mbedls and self.available_edbg_ports. :return: List of connected devices as dictionaries. """ connected_devices = self.mbeds.list_mbeds() if self.mbeds else [] # Check non mbedOS supported devices. ...
python
{ "resource": "" }
q242384
DutDetection.available_edbg_ports
train
def available_edbg_ports(self): """ Finds available EDBG COM ports. :return: list of available ports """ ports_available = sorted(list(list_ports.comports())) edbg_ports = [] for iport in ports_available: port = iport[0] desc = iport[1] ...
python
{ "resource": "" }
q242385
Dut.store_traces
train
def store_traces(self, value): """ Setter for _store_traces. _store_traces controls in memory storing of received lines. Also logs the change for the user. :param value: Boolean :return: Nothing """ if not value: self.logger.debug("Stopping storing re...
python
{ "resource": "" }
q242386
Dut.init_wait_register
train
def init_wait_register(self): """ Initialize EventMatcher to wait for certain cli_ready_trigger to arrive from this Dut. :return: None """ app = self.config.get("application") if app: bef_init_cmds = app.get("cli_ready_trigger") if bef_init_cmds:...
python
{ "resource": "" }
q242387
Dut.wait_init
train
def wait_init(self): """ Block until init_done flag is set or until init_wait_timeout happens. :return: value of init_done """ init_done = self.init_done.wait(timeout=self.init_wait_timeout) if not init_done: if hasattr(self, "peek"): app = se...
python
{ "resource": "" }
q242388
Dut.init_cli_human
train
def init_cli_human(self): """ Send post_cli_cmds to dut :return: Nothing """ if self.post_cli_cmds is None: self.post_cli_cmds = self.set_default_init_cli_human_cmds() for cli_cmd in self.post_cli_cmds: try: if isinstance(cli_cmd, ...
python
{ "resource": "" }
q242389
Dut.set_time_function
train
def set_time_function(self, function): """ Set time function to be used. :param function: callable function :return: Nothing :raises: ValueError if function is not types.FunctionType. """ if isinstance(function, types.FunctionType): self.get_time = fu...
python
{ "resource": "" }
q242390
Dut.open_dut
train
def open_dut(self, port=None): """ Open connection to dut. :param port: com port to use. :return: """ if port is not None: self.comport = port try: self.open_connection() except (DutConnectionError, ValueError) as err: ...
python
{ "resource": "" }
q242391
Dut._wait_for_exec_ready
train
def _wait_for_exec_ready(self): """ Wait for response. :return: CliResponse object coming in :raises: TestStepTimeout, TestStepError """ while not self.response_received.wait(1) and self.query_timeout != 0: if self.query_timeout != 0 and self.query_timeout < ...
python
{ "resource": "" }
q242392
Dut.execute_command
train
def execute_command(self, req, **kwargs): """ Execute command and return CliResponse :param req: String, command to be executed in DUT, or CliRequest, command class which contains all configurations like timeout. :param kwargs: Configurations (wait, timeout) which will be used w...
python
{ "resource": "" }
q242393
Dut.close_dut
train
def close_dut(self, use_prepare=True): """ Close connection to dut. :param use_prepare: Boolean, default is True. Call prepare_connection_close before closing connection. :return: Nothing """ if not self.stopped: self.logger.debug("Close '%s' connecti...
python
{ "resource": "" }
q242394
Dut.process_dut
train
def process_dut(dut): """ Signal worker thread that specified Dut needs processing """ if dut.finished(): return Dut._signalled_duts.appendleft(dut) Dut._sem.release()
python
{ "resource": "" }
q242395
Dut.run
train
def run(): # pylint: disable=too-many-branches """ Main thread runner for all Duts. :return: Nothing """ Dut._logger.debug("Start DUT communication", extra={'type': '<->'}) while Dut._run: Dut._sem.acquire() try: dut = Dut._signal...
python
{ "resource": "" }
q242396
Dut._read_response
train
def _read_response(self): """ Internal response reader. :return: CliResponse or None """ try: line = self.readline() except RuntimeError: Dut._logger.warning("Failed to read PIPE", extra={'type': '!<-'}) return -1 if line: ...
python
{ "resource": "" }
q242397
Dut.check_retcode
train
def check_retcode(self, line): """ Look for retcode on line line and return return code if found. :param line: Line to search from :return: integer return code or -1 if "cmd tasklet init" is found. None if retcode or cmd tasklet init not found. """ retcode = None...
python
{ "resource": "" }
q242398
Dut.start_dut_thread
train
def start_dut_thread(self): # pylint: disable=no-self-use """ Start Dut thread. :return: Nothing """ if Dut._th is None: Dut._run = True Dut._sem = Semaphore(0) Dut._signalled_duts = deque() Dut._logger = LogManager.get_bench_logg...
python
{ "resource": "" }
q242399
EventMatcher._event_received
train
def _event_received(self, ref, data): """ Handle received event. :param ref: ref is the object that generated the event. :param data: event data. :return: Nothing. """ match = self._resolve_match_data(ref, data) if match: if self.flag_to_set: ...
python
{ "resource": "" }