Python Scripts - Suggested Workflow?



  • Hi Onioneers,

    I would like to be able to use a modern IDE or Text Editor to write Python scripts instead of hacking through the console.

    I'm thinking I could setup an FTP and use something like Notepad++ to "live edit" files on the Omega, then execute the scripts via the Console. I'm wondering if there is a better way, or a better tool?

    It's almost like I want to Cross-Compile, but more that I want to Cross-Script if that makes sense.

    I would appreciate anyone's tips and workflows for working with Embedded Python.

    Here is hoping I don't have to become a console ninja w/ VIM or EMACs to put together Python projects.

    Thanks!
    Chris

    Twitter: @idleChris
    Blog: idlelogiclabs.com
    Side-Project: BetterSnipper



  • Why don't you use ssh to access you omega? What i do is that, edit the python files with nano, and run them on command line. Simple and effective.



  • @Chris-Zeh Hi, there are several ways you can do something like this depending upon what sort of system you access your Omega from.
    Things I use on a regular basis:

    • From Linux (I use Kubuntu-14.04), with your Omega turned on and accessible from your host system, in Dolphin File Manager go to Network and Add Network Folder to create an FTP connection Network Folder - then you can access all your files on the Omega via the connection you create - including editing them
    • From Windows, install WinSCP (http://winscp.net/eng/index.php) and create an SCP connection to your Omega. Then when you connect to your Omega using WinSCP you can access all files including editing them. You will need to setup the editor you want to use on WinSCP by going to Preferences->Editors
    • Finally, and though this may be a bit more than you need, I use NetBeans 8.1 for editing and developing both C/C++ and Java to run on the Omega - see https://community.onion.io/topic/125/using-netbeans-to-compile-c-c-code-for-omega/10 - this includes getting NetBeans to automatically transfer the built code to the Omega


  • @Pedro-Baco said:

    Why don't you use ssh to access you omega? What i do is that, edit the python files with nano, and run them on command line. Simple and effective.

    I agree SSH and VI or Nano to create .py files.



  • Personally - I like PyCharm to do this. I created a video which shows you how to develop with PyCharm and deploy to the Onion Omega.

    https://www.youtube.com/watch?v=CQELgysBgQs

    The deployment feature is only available in the professional edition - but I feel that their tools are so reasonably priced for the feature set they provide, as a professional, it is worth the money.

    This is my preferred workflow and so far it has worked great. The only thing you have to keep in mind is that you are using a far less powerful version of python so you might have to deploy and test to make sure the packages are available to you on the Omega.

    I also believe PyCharm can use a remote environment on the Omega so you can be sure it works on the deployed platform - however - this is something I have not tried yet.



  • @Chris-Zeh the easiest way might be to use the editor app in the Console. It uses the ACE editor, which is pretty similar to most of the other editors in terms of the UI. You can now directly save and edit files on the Omega. We are still adding new features to the Editor app. You should give it a try and give us some feature suggestions!



  • You can always use Sublime Text with SFTP/FTP plugin to connect through ssh and sync files while editing them (you set it up to upload your file every time you press save)



  • @Chris-Zeh

    This is a good question. In fact, I asked myself the same question last week.

    When I work headless with my Raspberry Pi or Intel Edison, I can work fine by using SSH and a full install of vim. On the Omega, vi seems to be installed by default but I really prefer vim (syntax highlighting and the way it behaves). The vi installed on the Omega does not even have visual mode installed, to select multiples lines. It is possible to install vim with opkg, but it fills the limited memory pretty quickly.

    PyCharm looks great but IMHO is overkill and it seems like you have to pay an annual fee to use it.
    Sublime Text is goot too but a license must be purchased for "continued use" at 70$. Also the SFTP plugin is 30$. I'm not really happy using a trial or evaluation version.

    On Windows I use Notepad++ a lot, it's free and includes by default a really great plugin called NppFTP. Granted you installed sftp on your Omega (opkg install openssh-sftp-server) you can use NppFTP in SFTP mode to open your files on the Omega and when you save them, they are automatically updated. You can open an SSH session with putty and run your code from there, using Notepadd++ to manage your files.

    Use what suits you the best, but I personnally prefer Notepad++ as it is free and you won't be harassed by pop-ups prompting you to buy the software. (and you won't need to get the software illegally)



  • I like using Notepad++ also. To transfer the Python file, I use WinSCP and then use a putty session to test.

    I hope the Console will be as good as Adafruit's Raspberry Pi WebIDE.

    Russ



  • From a linux computer you can mount the omega via sshfs -- this needs openssh-sftp-server to be installed on the omega.
    Then you can work with your preferred editor of your choice on the mounted files.



  • Thanks for all the great feedback everyone!!

    In summary it looks like the three main options are:

    • Become a command line ninja - SSH w/ VI/Nano. (Not ideal for big projects IMHO)
    • FTP/SFTP to push the files, SSH to execute. (Several different approaches for this, Notepad++ w/ NppFTP, NetBeans, Python IDE + FTP Client, etc).
    • ACE Web Editor in Console

    I like the idea of doing the development locally, so I have a perpetual copy that I won't accidentally nuke when I do an Omega upgrade (plus I can use tools like GitHub Desktop and an IDE to manage larger projects.)

    It looks like the best option is to use a text editor/IDE that will automatically do the FTP push when the file is edited... but I had another idea. Does OpenWRT Linux have any support for DropBox or similiar services? In this way we can use any editor/IDE and the DropBox like service will take care of syncing the files back and forth. Thoughts?



  • @Johannes-Zellner I just saw your post after I was done composing my last one. I'm currently using Windows, buy maybe there is a similar tool to mount in a similar way... would be much more simple than the Dropbox approach I proposed above.





  • @Fred-Blais PyCharm does have a free community version, of course you will still need to (s)ftp the files to the Omega outside of PyCharm. As for over-kill, I think this depends upon your application and whether you can or want to write and debug with a modern IDE or just use print statement.

    While I have not tried it yet, PyCharm does allow for remote debugging of applications which can very powerful. Imagine running your app on the Omega, but debugging on your Mac/PC. It also lets you setup a Remote Python Interpreter - which again I have not tried. These are likely professional features which does have a license fee. $89/ 1st year, $71 2nd year, $53 after that. And really - if you are a professional making your living writing software these are amazing tools for that price, IMHO.

    Disclaimer: I am not affiliated with Jetbrains in anyway. I'm just a super happy customer of their products.



  • @Chris Zeh if you're using github to store your code, a good workflow seems to me to be:

    • Write code on your dev environment
    • Push to github
    • git pull on the Omega
    • Run the code on the Omega

    You could just leave a single ssh window open into the Omega for this and even have a small shell script to do the pull and run if you wanted.



  • @fader, thanks for the idea. I think this would be too cumbersome. I typically wouldn't commit a change until I've tested it on the Omega, so I imagine this solution would have a huge amount of "test" commits.



  • Write your code on your native platform once complete or ready for test merely launch MobaXterm hook up a session of your choice ftp or sftp then drag and drop to your Omega directory. Simple and fast.Mobaxterm.png


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.