Question and help about Python script development methodology

Status
Not open for further replies.

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,458
I am trying to develop some scripts in Python to run on my FreeNAS box, but the methodology I am using to develop and debug them is not practical.

Here is my setup:

FreeNAS box:

- It has a dataset for my Python scripts.
- The dataset is mounted as a share over SMB.

PC:

- I am using Eclipse with PyDev plug-in.
- The Eclipse workspace is local to my PC but the Python scripts are defined as links to the share.
- SSH session to the FreeNAS box to execute the scripts.

How things work with the above setup:

- I develop the script on Eclipse then save the file on the SMB share.
- I connect to my FreeNAS box over SSH and execute the script using: python my-script.py

Everything is fine thus far, until comes the time for debugging.
With Eclipse running locally on my PC, I can't use its debug capability because the script is run directly within the FreeNAS box.

What are my options:

1) Is it possible to let Eclipse execute the scripts remotely while providing debugging capability?
2) If Eclipse is not able to execute and debug the script remotely over SSH, is there a way to run the script locally on my PC and pass some of the FreeNAS specific commands over SSH within the script itself?

The real issue is to be able to call FreeNAS/ZFS/FreeBSD commands within the script as they have to be run natively on the FreeNAS box.

If none of the above works, what would be my alternatives?

Thanks,
 
Last edited by a moderator:

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
How complex are the scripts? You can get a lot done with an interactive python session running on the server via SSH.
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,458
How complex are the scripts? You can get a lot done with an interactive python session running on the server via SSH.
As I am not an expert with Python scripting it is somewhat more complex to deal with my issues.
The scripts I am working on involve list manipulation (Python terminology).
Without debugging, I don't have visibility within the list or a simple loop function.
When a Python script error occurs, it is not trivial resolving the issue. For that I am adding within the script itself other function such as print statements, that will give me some insight where parts of the script is being executed, but it is overloading the script, making it more difficult to read and understand.
This would have been handled more gracefully with the use of breakpoints and looking at the variables and list contents.
I am not sure the interactive python session would work well because the lists are significantly large.
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
I've always debugged these sort of things the old fashioned way... Ie print statements.

Dang fancy interactive debuggers.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
pdb is what your want to use in your script. It just use print () and print the lists and variables.

Sent from my Nexus 5X using Tapatalk
 
Status
Not open for further replies.
Top