Task Reference

Xnt has a number of built in tasks to aid you in writing a simple build file.

File Tasks

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.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.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.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.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

Archive Tasks

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

Miscellaneous Tasks

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.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.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.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

Compile Tasks

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, $?

SCM Tasks

Mercurial Tasks

xnt.vcs.hg.hgclone(url, dest=None, rev=None, branch=None)

Clone a Mercurial Repository

Parameters:
  • url – URI of repository to clone
  • dest – Directory or name of cloned repository
  • rev – Revision to clone
  • branch – Branch to clone
xnt.vcs.hg.hgfetch(path, source='default')

Pull and Update an already cloned Mercurial Repository

Parameters:
  • path – Directory to the repository for which to pull changes
  • source – Repository’s upstream source

Git Tasks

xnt.vcs.git.gitclone(url, dest=None, branch=None)

Clone a repository

Parameters:
  • url – URI of the repository to clone
  • dest – Destination directory or name of the cloned repository
  • branch – Branch to clone
xnt.vcs.git.gitpull(path, source='origin', branch='master')

Pull/Update a cloned repository

Parameters:
  • path – Directory of the repository for which to pull and update
  • source – Repository’s upstream source
  • branch – Repository’s upstream branch to pull from

CVS Tasks

xnt.vcs.cvs.cvsco(module, rev='', dest='')

Run CVS Checkout

Parameters:
  • module – CVS Module name to checkout
  • rev – Revision to checkout
  • dest – Destination directory or name of checked out module
xnt.vcs.cvs.cvsupdate(path)

Run CVS Update

Parameters:path – Directory path to module to update

Table Of Contents

Previous topic

First Build File

Next topic

Build Reference

This Page