xnt.tasks

Common Tasks Module

Defines a set of operations that are common enough but also are tedious to define

xnt.tasks.call(command, stdout=None, stderr=None)

Execute the given command, redirecting stdout and stderr to optionally given files

Param :command - list of command and arguments
Param :stdout - file to redirect standard output to, if given
Param :stderr - file to redirect standard error to, if given
Returns:the error code of the subbed out call, $?
xnt.tasks.cp(src='', dst='', files=None)

Copy src to dst or copy files to dst

Copy a file or folder to a different file/folder If no src file is specified, will attempt to copy files to dst

Notice, elements of files will not be expanded before copying.

Parameters:
  • src – source directory or file
  • dst – destination file or folder (in the case of files)
  • files – list of files (strings) to copy to src
xnt.tasks.create_zip(directory, zipfilename)

Compress (Zip) folder

Zip the specified directory into the zip file named zipfilename

Parameters:
  • directory – Directory to zip
  • zipfilename – Name of resulting compression
xnt.tasks.echo(msg, tofile)

Write a string to file

Write the given msg to a file named tofile

Notice, echo will overwrite the file if it already exists

Parameters:
  • msg – Message to write to file
  • tofile – file to which the message is written
xnt.tasks.expandpath(path_pattern)

Return a glob expansion generator of path_pattern

Parameters:path_pattern – pattern to expand
Return type:generator of strings
Returns:List of paths and/ or files
xnt.tasks.in_path(program)

Return boolean result if program is in PATH environment variable

Parameters:program – Program name to search for in PATH
Returns:Return the PATH of program or None
xnt.tasks.log(msg='', lvl=20)

Log msg using tasks global logger

Emit the message (msg) to the xnt.tasks logger using either the default log level (INFO) or any valid specified value of logging module

Parameters:
  • msg – Message to log
  • lvl – Log Level of message. Default INFO
xnt.tasks.mkdir(directory, mode=511)

Make a directory with mode

Create a directory specified by dir with default mode (where supported) or with the specified mode

Notice, if the directory already exists, mkdir will log a warning and return

Parameters:
  • directory – New directory to create
  • mode – Mode to create the directory (where supported). Default: 777
xnt.tasks.mv(src, dst)

Move src to dst

Move (copy and remove) the source file or directory (src) to the destination file or directory (dst)

Parameters:
  • src – Source file or folder to move
  • dst – Destination file or folder
xnt.tasks.rm(*fileset)

Remove a set of files

Attempt to remove all the directories given by the fileset. Before rm tries to delete each element of fileset, it attempts to expand it first using glob expansion (xnt.tasks.expandpath()), thus allowing the passing of glob elements

Parameters:fileset – List of files to remove
xnt.tasks.setup(commands, directory='')

Invoke the setup.py file in the current or specified directory

Param :commands - list of commands and options to run/ append
Param :dir - (optional) directory to run from
Returns:the error code of the execution, $?
xnt.tasks.which(program)

Similar to Linux/Unix which: return (first) path of executable

Parameters:program – program name to search for in PATH
Returns:Return the PATH of program or None
xnt.tasks.xntcall(buildfile, targets=None, props=None)

Invoke xnt on another build file in a different directory

Param :path - to the build file (including build file)
Param :targets - list of targets to execute
Param :props - dictionary of properties to pass to the build module

Previous topic

xnt.build.tex

Next topic

xnt.vcs.cvs

This Page