Utilities module¶
-
Utilities.
ConcatenateIntegers
(*Integers)[source]¶ Concatenate/Merge integers into one integer. E.g. 10 and 20 to 1020.
Example:
>>> ConcatenateIntegers(10, 20, 30) '102030'
Parameters: Integers (Integers) – Integers to be concatenated. Returns: Result: Concatenated integer. Return type: Integer
-
Utilities.
ConvertTimeStampToDateTime
(TimeStamp, TimeType=0, ReturnType=0)[source]¶ Convert a time stamp(seconds since epoch) to a Python datetime object.
Parameters: - TimeStamp (Number/String) – A time stamp(seconds since epoch).
- TimeType (Number) – Type 0 means the same time zone as current computer. Type 1 means UTC time.
- ReturnType (Number) – ReturnType 0 means datetime object. ReturnType 1 means time.struct_time object, which can be used like a tuple.
Returns: DateTimeObjcet/DateTimeObject.timetuple():
Return type: datetime object/time.struct_time object
-
Utilities.
GetHardDiskUsage
(Print=True)[source]¶ Use shutil to obtain hard disk usage.
Example:
>>> GetHardDiskUsage() CM.Utilities.GetHardDiskUsage() Total: 371 GB Used: 341 GB Free: 24 GB (399000969216, 366894043136, 26025852928)
Parameters: Print (Boolean) – Whether to use print function to print disk usage on the screen. Returns: DiskUsage: A tuple contains total, used and free disk space in bytes. Return type: Tuple
-
Utilities.
TimeElapsed
(Unit=True, LastTime=False)[source]¶ Return the time interval since first/last call of this function.
Example:
>>> TimeElapsed() '0.0 sec' >>> ...Some other operations >>> TimeElapsed() '4.70393395423889 sec'
Parameters: - Unit (Boolean/String) – Whether to append unit ‘ sec’(by default) or other unit when returned. If False, a float number will be returned.
- LastTime (Boolean) – If True return the time interval since the last call of this function, otherwise return the time interval since the first call of this function, e.g. since programming running.
Returns: TimeInterval: Time interval since last call of this function..
Return type: String/Float