NAME
FusionInventory::Agent::Tools - OS-independent generic functions
DESCRIPTION
This module provides some OS-independent generic functions.
FUNCTIONS
getFormatedLocalTime($time)
Returns a formated date from given Unix timestamp.
getFormatedGMTTime($time)
Returns a formated date from given Unix timestamp.
getFormatedDate($year, $month, $day, $hour, $min, $sec)
Returns a formated date from given date elements.
getCanonicalManufacturer($manufacturer)
Returns a normalized manufacturer value for given one.
getCanonicalSpeed($speed)
Returns a normalized speed value (in Mhz) for given one.
getCanonicalInterfaceSpeed($speed)
Returns a normalized network interface speed value (in Mb/s) for given one.
getCanonicalSize($size, $base)
Returns a normalized size value (in Mb) for given one.
getSanitizedString($string)
Returns the input stripped from any control character, properly encoded in UTF-8.
getUtf8String($string)
Returns the input properly encoded in UTF-8.
trimWhitespace($string)
Remove leading and trailing whitespace, and fold multiple whitespace characters into a single one.
compareVersion($major, $minor, $min_major, $min_minor)
Returns true if software with given major and minor version meet minimal version requirements.
getDirectoryHandle(%params)
Returns an open file handle on either a command output, or a file.
getFileHandle(%params)
Returns an open file handle on either a command output, a file, or a string.
- logger a logger object
- command the command to use
- file the file to use, as an alternative to the command
- string the string to use, as an alternative to the command
getFirstLine(%params)
Returns the first line of given command output or given file content, with end of line removed.
- logger a logger object
- command the exact command to use
- file the file to use, as an alternative to the command
getAllLines(%params)
Returns all the lines of given command output or given file content, as a list of strings with end of line removed in list context, as a single string otherwise.
- logger a logger object
- command the exact command to use
- file the file to use, as an alternative to the command
getFirstMatch(%params)
Returns the result of applying given pattern on the first matching line of given command output or given file content.
- pattern a regexp
- logger a logger object
- command the exact command to use
- file the file to use, as an alternative to the command
getLastLine(%params)
Returns the last line of given command output or given file content.
- logger a logger object
- command the exact command to use
- file the file to use, as an alternative to the command
getLinesCount(%params)
Returns the number of lines of given command output or given file content.
- logger a logger object
- command the exact command to use
- file the file to use, as an alternative to the command
canRun($binary)
Returns true if given binary can be executed.
canRead($file)
Returns true if given file can be read.
canLoad($module)
Returns true if given perl module can be loaded (and actually loads it).
hex2char($value)
Returns the value converted to a character if it starts with hexadecimal prefix, the unconverted value otherwise. Eg. 0x41 -> A, 41 -> 41.
hex2dec($value)
Returns the value converted to a decimal if it starts with hexadecimal prefix, the unconverted value otherwise. Eg. 0x41 -> 65, 41 -> 41.
dec2hex($value)
Returns the value converted to an hexadecimal if it doesn't start with hexadecimal prefix, the unconverted value otherwise. Eg. 65 -> 0x41, 0x41 -> 0x41.
any BLOCK LIST
Returns a true value if any item in LIST meets the criterion given through BLOCK.
first BLOCK LIST
Returns the first value from LIST meeting the criterion given through BLOCK or undef.
all BLOCK LIST
Returns a true value if all items in LIST meet the criterion given through BLOCK.
none BLOCK LIST
Returns a true value if no item in LIST meets the criterion given through BLOCK.
uniq BLOCK LIST
Returns a new list by stripping duplicate values in LIST.
file2module($string)
Converts a perl file name to a perl module name (Foo/Bar.pm -> Foo::Bar)
module2file($string)
Converts a perl module name to a perl file name ( Foo::Bar -> Foo/Bar.pm)
runFunction(%params)
Run a function whose name is computed at runtime and return its result.
- logger a logger object
- module the function namespace
- function the function name
- timeout timeout for function execution
- load enforce module loading first
delay($second)
Wait for $second. It uses sleep() or Win32::Sleep() depending on the Operating System.
slurp($file)
Return the content of a given file.
isParamArrayAndFilled($hash, $paramName)
Return if $hash has a key $paramName which value is a ARRAY ref not empty.