Greetings everybody
I have written this piece of code to help me with my job:
Before I started building this script, I tried every method on bench console and it worked.
Now when I build this standalone script, the frappe.get_list() gives an error:
Any help would be appreciated
When you use 'bench execute'
, your target is a function.
I was successfully able to run your code, as follows:
-
Created a new Python file/module named “test_this.py”
-
Wrapped your code inside a function named ‘foo’:
# frappe-bench/apps/my_app/my_app/my_module/test_this.py
import frappe
def foo():
apps = ''
apps = [ 'frappe', 'erpnext' ]
for _ in apps:
print(f"App: {_}\n", f"Modules:\n {frappe.get_module_list(_)}")
print('-'*109)
for i in frappe.get_list('DocType'):
print(i)
- Call bench execute like this:
$ bench execute my_app.my_module.test_this.foo
Thank you for your reply.
I forgot to comment that I managed to solve that issue by importing the script inside bench console.
By the way, your solution gives me:
NameError: name ‘gettin_em_all’ ia not defined
The script is located at frappe-bench/sites. I cd the path and applied the command there.
Same thing when put the script in app.module