ifw-core  5.0.0-pre2
Classes | Functions
utils.utils Namespace Reference

Classes

class  ConstantRegistry
 Class to handle conversion between state names and the corresponding numerical representation. More...
 
class  StopWatch
 Stopwatch class. More...
 

Functions

def exec_cmd (cmd)
 Execute a command and return tuple with (<exit code>, <stdout>, <stderr>). More...
 
def get_location (level=-3)
 Get location of the current position in a source file of the Python interpreter. More...
 
def get_module ()
 Get the name of the current module. More...
 
def get_ip_address ()
 Return IP address of execution node. More...
 
def get_iso_time ()
 Return ISO8601 time for the time at the invocation. More...
 
def gen_iso_time (secs_since_epoch)
 Generate ISO8601 timestamp from the seconds since epoch given. More...
 
def debug (msg)
 Print a debug log to stdout. More...
 
def revert_dic (dic)
 Revert a dictionary (making the values to keys and vice versa). More...
 
def key_in_dic (dic, key)
 Return True if the given key is in the dictionary. More...
 
def resolve_path (path)
 Resolve the given path. More...
 
def find_file (filename, root_dirs=["INTROOT", "CFGPATH", "DATAROOT"], resource_dirs=["config", "audio", "image", "model", "dictionary", "data"], exception=True)
 Search for a file with the given name in the locations specified. More...
 
def remove_file (filename)
 Remove a file. More...
 
def concat_elements (elements_list, concat_char=".")
 Concat the elements in the list, applying the "concat_char" as separator. More...
 
def rand_dbl (lower_limit, upper_limit)
 Generate a random number in the given interval. More...
 
def gen_cwd (module_path, test_dir)
 Generate the complete path based on the module name and the relative path in relation to the project root. More...
 

Function Documentation

◆ concat_elements()

def utils.utils.concat_elements (   elements_list,
  concat_char = "." 
)

Concat the elements in the list, applying the "concat_char" as separator.

◆ debug()

def utils.utils.debug (   msg)

Print a debug log to stdout.

◆ exec_cmd()

def utils.utils.exec_cmd (   cmd)

Execute a command and return tuple with (<exit code>, <stdout>, <stderr>).

◆ find_file()

def utils.utils.find_file (   filename,
  root_dirs = ["INTROOT", "CFGPATH", "DATAROOT"],
  resource_dirs = ["config", "audio", "image", "model", "dictionary", "data"],
  exception = True 
)

Search for a file with the given name in the locations specified.

First occurrence of the file is returned.

◆ gen_cwd()

def utils.utils.gen_cwd (   module_path,
  test_dir 
)

Generate the complete path based on the module name and the relative path in relation to the project root.

Example
gen_cwd("core/pyutils/opcuaGenProfile", "core/pyutils/opcuaGenProfile/test")
def gen_cwd(module_path, test_dir)
Generate the complete path based on the module name and the relative path in relation to the project ...
Definition: utils.py:255
-> "/home/user/ELT/ifw/core/pyutils/opcuaGenProfile/test".

◆ gen_iso_time()

def utils.utils.gen_iso_time (   secs_since_epoch)

Generate ISO8601 timestamp from the seconds since epoch given.

◆ get_ip_address()

def utils.utils.get_ip_address ( )

Return IP address of execution node.

◆ get_iso_time()

def utils.utils.get_iso_time ( )

Return ISO8601 time for the time at the invocation.

◆ get_location()

def utils.utils.get_location (   level = -3)

Get location of the current position in a source file of the Python interpreter.

level Level in the stack to use as location (integer).

Returns Location in the format: '<mod>:<method>:<ln no>' (string).

◆ get_module()

def utils.utils.get_module ( )

Get the name of the current module.

◆ key_in_dic()

def utils.utils.key_in_dic (   dic,
  key 
)

Return True if the given key is in the dictionary.

◆ rand_dbl()

def utils.utils.rand_dbl (   lower_limit,
  upper_limit 
)

Generate a random number in the given interval.

◆ remove_file()

def utils.utils.remove_file (   filename)

Remove a file.

Ignore silently if the file doesn't exist.

◆ resolve_path()

def utils.utils.resolve_path (   path)

Resolve the given path.

◆ revert_dic()

def utils.utils.revert_dic (   dic)

Revert a dictionary (making the values to keys and vice versa).