How to call a whitelisted function from a Packaged app in v14


I’ve created a Package in Frappe v14.26

It contains a Module (mOctopus), which contains a DocType (dOctopus) and an associated Client Script (csOctopus).

frappe.ui.form.on('dOctopus', {
	refresh(frm) {
		cur_frm.add_custom_button(__("Custom Form Button"), function() {'').then(r => {
				console.log(String.fromCharCode.apply(null, r.message));

This Client Script calls a whitelisted function (pwd) which I’ve placed in …/packages/pnOctopus/moctopus/doctype/doctopus/

import frappe
import subprocess
def pwd():
    pwd =["pwd", "/dev/null"], capture_output=True).stdout
    return pwd

My problem is that I do not know what the dotted path to the pwd function is? :frowning_face:

The dotted path to the pwd method should be


In Frappe, the dotted path for a whitelisted method is the full path of the Python function, starting from the name of the Frappe application, followed by the name of the Frappe module, and then the name of the doctype, and finally the name of the Python function.

In your case, the name of the Frappe application is “pnOctopus”, the name of the Frappe module is “mOctopus”, the name of the doctype is “dOctopus”, and the name of the Python function is “pwd”. Therefore, the dotted path to the pwd method is


Thanks so much @belur02

I’ve tried that but get this error:

App pnOctopus is not installed

Failed to get method for command pnOctopus.mOctopus.doctype.dOctopus.pwd with App pnOctopus is not installed

The actual File System directory names are without the capital O for the module and doctype : pnOctopus/moctopus/doctype/doctopus/

Normally you would also include the file name without it’s .py extension, but even that does not work.

The best solution / workaround I can come up with is to place the function in a file, and to place the file in $MY_BENCH/apps/frappe/frappe/

The dotted path is then


This is hardly a solution, as it’s not upgrade safe and the code is not bundled with the Package.

You can’t have unsafe modules (like subprocess) in Server Scripts. Also, you can’t ship Python modules in a Frappe Package. A solution that requires making changes in Frappe’s editable install is far from ideal.

What you’re trying to achieve is best done through a separate Frappe App. Primarily because of the subprocess requirement - else you could achieve the same with a package.

Thanks @gavindsouza

So, I suspected that I’d have to make use of a conventional custom app, not a packaged custom app.

However, for clarification, please confirm that it’s not possible at all to define/call a whitelisted function within a packaged custom app, irrespective of whether it uses python modules, such as subprocess, or not?