The convert_to_bytes() function converts byte string value notation, containing a size specification, to an integer or float value, using base-2 computation.
numericValue = convert_to_bytes(byteValue)
|
byteValue |
String |
Byte string value with one of the following unit specifications:
Format specification examples:
10MB Note: The value may not contain a thousands separator comma, and uses a period (.) to denote decimal.
Examples: |
|
Integer/Float |
Integer or float representation of byteValue . |
|
ValueError |
'unrecognized units: %s' % units |
|
ValueError |
'cannot convert to bytes: %s' % byteValue |
from splunk.appserver.mrsparkle.lib import util
byteVal = '10000PB'
try:
bytes = util.convert_to_bytes(byteVal)
except:
pass