API Reference

class cerda.farm_watcher.FarmWatcher(username, password, rel_src_dir, rel_tar_dir, host='tete', notify=None, client=None, custom_extensions=[])

Core class of the command line application. Handles or the file input output operations.

__init__(username, password, rel_src_dir, rel_tar_dir, host='tete', notify=None, client=None, custom_extensions=[])

Farm watcher constructor initializes a state parsed from arguments.

Parameters:
  • username (str) – local machine username. The i number, i.e. i7243466
  • password (str) – password used to connect to the renderfarm server
  • rel_src_dir (str) – renderfarm directory where frames will be dropped. It needs to be relative to the home folder.
  • rel_tar_dir (str) – target directory where to place the rendered images. It needs to be relative to the home folder. If dropbox option is passed it will go to that folder from the dropbox root.
  • host (str) – host direction to connect to using sftp
  • notify (tuple) – tuple (str, int) containing the email address to send the email to and the number of frames that need to be picked up before sending it.
  • client (obj) – the Dropbox client instance used to upload the files to the account. It has been initialized already. It is ready to go.
  • custom_extensions (list) – list of string in the form of [‘.png’, ‘.jpeg’] that will be intercepted by cerda and sent to the desired location.
default_extensions = ['.png', '.exr', '.jpg', '.jpeg', '.obj', '.bgeo', '.bgeo.sc', '.tiff']
process_item(sftp, item)

Performs all the I/O and logic operations on the current item.

Parameters:
  • sftp (obj) – sftp connection object.
  • item (str) – filename. The newly rendered file.
run(delay_seconds)

Runs the watcher in a demonized fashion. When there is a new file it triggers a file processor.

Parameters:delay_seconds (int) – after checking if there is new files it will sleep this amount of seconds before checking again.
exception cerda.errors.CerdaError(message)

Prints out an error to the logger and exits the application.

cerda.helpers.dropbox_setup()

Sets up a Dropbox client object that will be used to put the files on the Dropbox account.

The first time it is run it will ask the user to allow this app through the browser. The user will paste the authorization code and a token will get generated. I am storing it under ~/.cerda/dbox_token.txt. This does not contain any username or passwords, so the user is safe.

Returns:Initialized Dropbox client object
Return type:obj
cerda.helpers.email_sender(email_address, wd, processed_items, attach_previews=False)

Given an email and the list of rendered items it sends an email using Google’s SMTP servers. The email will come from cerdancca@gmail.com.

Parameters:
  • email_address (str) – address to send the email to.
  • wd (str) – working directory
  • processed_items (list) – list of rendered item file names.
  • attach_previews (bool) – if need to attach preview images
cerda.helpers.get_abs_form_rel(rel_dir, username)

Given a relative folder it expands the current user home folder thus constructing an absolute path.

Parameters:
  • rel_dir (str) – relative path.
  • username (str) – self explanatory.
Returns:

Absolute path.

Return type:

str

cerda.helpers.is_render_finished(sftp, item)

Checks if the render has been finished by checking if there is a file with the same name with .mantra_checkpoint appended to it.

Parameters:
  • sftp (obj) – sftp connection object.
  • item (str) – name of file
Returns:

Whether render is completed or not

Return type:

bool

cerda.helpers.parse_args(args)

Parsing and validation of all the user supplied arguments.

It will make sure that if user passes email or count passes both, as both are needed. Also will validate the time delay for checking for new frames as it cannot be negative, and same for the count value, it doesn’t make sense values of 0 or lower.

Parameters:args (list) – list containing a representation of the command typed by the user.
Returns:a tuple with the parsed username (string), password (string), relative source and target paths (string), email, count (int), client (dropbox.client.DropboxClient), every (int).
Return type:tuple
cerda.helpers.validate_path(path)

Validates the input path for source or targets given a relative path string.

Parameters:path (string) – relative path
Returns:success.
Return type:bool