Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
tools::utils Namespace Reference
Data Structures | |
| class | ToolException |
| class | NotSupportedException |
Functions | |
| def | compile_worker |
| def | cmd |
| def | run_cmd |
| def | run_cmd_ext |
| def | is_cmd_valid |
| def | is_exec |
| def | find_cmd_abspath |
| def | mkdir |
| def | write_json_to_file |
| def | copy_file |
| def | delete_dir_files |
| def | get_caller_name |
| def | error |
| def | rel_path |
| def | split_path |
| def | get_path_depth |
| def | args_error |
| def | construct_enum |
| def | check_required_modules |
| def | json_file_to_dict |
| def | argparse_force_type |
| def | argparse_many |
| def | argparse_filestring_type |
| def | argparse_profile_filestring_type |
| def | columnate |
| def | argparse_dir_not_parent |
| def | argparse_deprecate |
| def | print_large_string |
| def | intelhex_offset |
| def | integer |
Detailed Description
mbed SDK Copyright (c) 2011-2013 ARM Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Function Documentation
| def tools::utils::argparse_deprecate | ( | replacement_message ) |
fail if argument is provided with deprecation warning
Definition at line 506 of file tools/utils.py.
| def tools::utils::argparse_dir_not_parent | ( | other ) |
fail if argument provided is a parent of the specified directory
Definition at line 492 of file tools/utils.py.
| def tools::utils::argparse_filestring_type | ( | string ) |
An argument parser that verifies that a string passed in corresponds to a file
Definition at line 445 of file tools/utils.py.
| def tools::utils::argparse_force_type | ( | case ) |
validate that an argument passed in (as string) is a member of the list of possible arguments after converting it's case.
Definition at line 411 of file tools/utils.py.
| def tools::utils::argparse_many | ( | func ) |
An argument parser combinator that takes in an argument parser and creates a new parser that accepts a comma separated list of the same thing.
Definition at line 436 of file tools/utils.py.
| def tools::utils::argparse_profile_filestring_type | ( | string ) |
An argument parser that verifies that a string passed in is either absolute path or a file name (expanded to mbed-os/tools/profiles/<fname>.json) of a existing file
Definition at line 454 of file tools/utils.py.
| def tools::utils::args_error | ( | parser, | |
| message | |||
| ) |
Abort with an error that was generated by the arguments to a CLI program Positional arguments: parser - the ArgumentParser object that parsed the command line message - what went wrong
Definition at line 311 of file tools/utils.py.
| def tools::utils::check_required_modules | ( | required_modules, | |
verbose = True |
|||
| ) |
Function checks for Python modules which should be "importable"
before test suite can be used.
@return returns True if all modules are installed already
Definition at line 331 of file tools/utils.py.
| def tools::utils::cmd | ( | command, | |
check = True, |
|||
verbose = False, |
|||
shell = False, |
|||
cwd = None |
|||
| ) |
A wrapper to run a command as a blocking job
Definition at line 71 of file tools/utils.py.
| def tools::utils::columnate | ( | strings, | |
separator = ", |
|||
chars = 80 |
|||
| ) |
render a list of strings as a in a bunch of columns Positional arguments: strings - the strings to columnate Keyword arguments; separator - the separation between the columns chars - the maximum with of a row
Definition at line 467 of file tools/utils.py.
| def tools::utils::compile_worker | ( | job ) |
Standard task runner used for compiling
Positional argumets:
job - a dict containing a list of commands and the remaining arguments
to run_cmd
Definition at line 43 of file tools/utils.py.
| def tools::utils::construct_enum | ( | enums ) |
Create your own pseudo-enums Keyword arguments: * - a member of the Enum you are creating and it's value
Definition at line 322 of file tools/utils.py.
| def tools::utils::copy_file | ( | src, | |
| dst | |||
| ) |
Implement the behaviour of "shutil.copy(src, dst)" without copying the permissions (this was causing errors with directories mounted with samba) Positional arguments: src - the source of the copy operation dst - the destination of the copy operation
Definition at line 203 of file tools/utils.py.
| def tools::utils::delete_dir_files | ( | directory ) |
A function that does rm -rf Positional arguments: directory - the directory to remove
Definition at line 217 of file tools/utils.py.
| def tools::utils::error | ( | msg ) |
Fatal error, abort hard Positional arguments: msg - the message to print before crashing
Definition at line 243 of file tools/utils.py.
| def tools::utils::find_cmd_abspath | ( | command ) |
Returns the absolute path to a command.
None is returned if no absolute path was found.
Positional arguhments:
command - the command to find the path of
Definition at line 152 of file tools/utils.py.
| def tools::utils::get_caller_name | ( | steps = 2 ) |
When called inside a function, it returns the name of the caller of that function. Keyword arguments: steps - the number of steps up the stack the calling function is
Definition at line 232 of file tools/utils.py.
| def tools::utils::get_path_depth | ( | path ) |
Given a path, return the number of directory levels present.
This roughly translates to the number of path separators (os.sep) + 1.
Ex. Given "path/to/dir", this would return 3
Special cases: "." and "/" return 0
Positional arguments:
path - the path to calculate the depth of
Definition at line 291 of file tools/utils.py.
| def tools::utils::integer | ( | maybe_string, | |
| base | |||
| ) |
Make an integer of a number or a string
Definition at line 547 of file tools/utils.py.
| def tools::utils::intelhex_offset | ( | filename, | |
| offset | |||
| ) |
Load a hex or bin file at a particular offset
Definition at line 534 of file tools/utils.py.
| def tools::utils::is_cmd_valid | ( | command ) |
Verify that a command exists and is executable Positional arguments: command - the command to check
Definition at line 127 of file tools/utils.py.
| def tools::utils::is_exec | ( | path ) |
A simple check to verify that a path to an executable exists Positional arguments: path - the executable
Definition at line 143 of file tools/utils.py.
| def tools::utils::json_file_to_dict | ( | fname ) |
Read a JSON file and return its Python representation, transforming all the strings from Unicode to ASCII. The order of keys in the JSON file is preserved. Positional arguments: fname - the name of the file to parse
Definition at line 361 of file tools/utils.py.
| def tools::utils::mkdir | ( | path ) |
a wrapped makedirs that only tries to create a directory if it does not exist already Positional arguments: path - the path to maybe create
Definition at line 171 of file tools/utils.py.
| def tools::utils::print_large_string | ( | large_string ) |
Breaks a string up into smaller pieces before print them This is a limitation within Windows, as detailed here: https://bugs.python.org/issue11395 Positional arguments: large_string - the large string to print
Definition at line 513 of file tools/utils.py.
| def tools::utils::rel_path | ( | path, | |
| base, | |||
dot = False |
|||
| ) |
Relative path calculation that optionaly always starts with a dot Positional arguments: path - the path to make relative base - what to make the path relative to Keyword arguments: dot - if True, the path will always start with a './'
Definition at line 253 of file tools/utils.py.
| def tools::utils::run_cmd | ( | command, | |
work_dir = None, |
|||
chroot = None, |
|||
redirect = False |
|||
| ) |
Run a command in the foreground Positional arguments: command - the command to run Keyword arguments: work_dir - the working directory to run the command in chroot - the chroot to run the command in redirect - redirect the stderr to a pipe to be used later
Definition at line 81 of file tools/utils.py.
| def tools::utils::run_cmd_ext | ( | command ) |
A version of run command that checks if the command exists befor running Positional arguments: command - the command line you are trying to invoke
Definition at line 115 of file tools/utils.py.
| def tools::utils::split_path | ( | path ) |
spilt a file name into it's directory name, base name, and extension Positional arguments: path - the file name to split
Definition at line 280 of file tools/utils.py.
| def tools::utils::write_json_to_file | ( | json_data, | |
| file_name | |||
| ) |
Write json content in file :param json_data: :param file_name: :return:
Definition at line 182 of file tools/utils.py.
Generated on Tue Aug 9 2022 00:37:40 by
1.7.2