lib.operating_system

class dt4test.lib.operating_system.OPSystem[source]
本地进程操作
append_to_environment_variable(name, *values, **config)[source]

追加环境变量

If the environment variable already exists, values are added after it, and otherwise a new environment variable is created.

append_to_file(path, content, encoding='UTF-8')[source]

追加内容到文件

copy_directory(source, destination)[source]

拷贝目录

copy_file(source, destination)[source]

拷贝文件

count_directories_in_directory(path, pattern=None)[source]

统计目录数

count_files_in_directory(path, pattern=None)[source]

统计文件数

count_items_in_directory(path, pattern=None)[source]

统计文件和目录数:

create_directory(path)[source]

创建目录

create_file(path, content='', encoding='UTF-8')[source]

创建文件,内容为content

empty_directory(path)[source]

清空目录

get_file(path, encoding='UTF-8', encoding_errors='strict')[source]

取得文件内容

get_modified_time(path, format='timestamp')[source]

取得修改时间

How time is returned is determined based on the given format string as follows. Note that all checks are case-insensitive. Returned time is also automatically logged.

  1. If format contains the word epoch, the time is returned in seconds after the UNIX epoch. The return value is always an integer.

  2. If format contains any of the words year, month, day, hour, min or sec, only the selected parts are returned. The order of the returned parts is always the one in the previous sentence and the order of the words in format is not significant. The parts are returned as zero-padded strings (e.g. May -> 05).

  3. Otherwise, and by default, the time is returned as a timestamp string in the format 2006-02-24 15:08:31.

remove_directory(path, recursive=False)[source]

删除目录

remove_environment_variable(*names)[source]

删除环境变量

remove_files(*paths)[source]

删除多个文件

set_environment_variable(name, value)[source]

设置环境变量

set_modified_time(path, mtime)[source]

设置修改时间

Changes the modification and access times of the given file to the value determined by mtime. The time can be given in different formats described below. Note that all checks involving strings are case-insensitive. Modified time can only be set to regular files.

  1. If mtime is a number, or a string that can be converted to a number, it is interpreted as seconds since the UNIX epoch (1970-01-01 00:00:00 UTC). This documentation was originally written about 1177654467 seconds after the epoch.

  2. If mtime is a timestamp, that time will be used. Valid timestamp formats are YYYY-MM-DD hh:mm:ss and YYYYMMDD hhmmss.

  3. If mtime is equal to NOW, the current local time is used.

  4. If mtime is equal to UTC, the current time in [http://en.wikipedia.org/wiki/Coordinated_Universal_Time|UTC] is used.

  5. If mtime is in the format like NOW - 1 day or UTC + 1 hour 30 min, the current local/UTC time plus/minus the time specified with the time string is used. The time string format is described in an appendix of Robot Framework User Guide.

zip_file(output_file, *input_files)[source]

将多个文件压缩成zip文件 :param output_file: zip 文件名 :param input_files: 输入文件列表 :return: