vladimirnani / DjangoCommands

ST2/ST3 plugin for managing django project
29 stars 14 forks source link

Tested it under Linux #1

Closed AdrianLC closed 9 years ago

AdrianLC commented 11 years ago

Hello there,

Nice plugin. You might not believe it but I actually had a project like this in my list of personal project ideas :D .

My distro is Fedora 19 x64. In case you're not familiar with the "linux distro world", it's not based on Ubuntu or Debian, is like the free-community version of Red Hat Enterprise Linux.

Well, here I leave my impressions after testing it for a while:

  1. There was no default nor user settings entry under Preferences -> Package Settings.
  2. So I had to edit the default settings via Browse Packages... to change the direction of the slashes in python_virtualenv_paths. I only use virtualenvwrapper but I left it like this:
{

// the other settings left untouched 

"python_virtualenv_paths": [
    "~/.virtualenvs",  // virtualenvwrapper
    "~/.venv"  // venv.bash https://github.com/wuub/venv
] 

}
  1. Afterwards, the set virtualenv command worked (or so it seems) fine.
  2. Next, I runned runserver and the server started. The main issue here is that I don't don't know how to stop/restart the server from sublime and even closing the whole editor won't end the process, so I had to kill it from bash command line. A command Stop runserver might be a good idea.
  3. Another problem is that I don't get output for any of the commands: runserver log with HTTP response codes, etc. Because of this, when I tried syncdb and migrate the logs say they have been executed, but since my DB was already fully synced, I'm not sure. After having a look at the code, my conclusion is that you're probably already aware of this (that there is no output) and is just something not yet implemented.
  4. Last, the custom commands seem broken. I've tried to run the tests with this list of inputs: test (app_name), "test (app_name)", test. The stacktrace is always:
Traceback (most recent call last):
  File "./django-commands.py", line 71, in on_input
  File "./django-commands.py", line 13, in log
TypeError: cannot concatenate 'str' and 'list' objects

I'll leave a log example as well:

 - Django: Python path is /home/adrian/.virtualenvs/clusters/bin/python
 - Django: Found manage.py in /home/adrian/cluster_site
 - Django: Command is : [u'/home/adrian/.virtualenvs/clusters/bin/python', u'/home/adrian/cluster_site/manage.py', 'runserver']

That was it. It might be finished by then, but in 4 to 6 months I might have a bit of spare time to contribute. Would have to study the plugin API first cause I haven't worked with it before.

Good luck with the project, Adrián

vladimirnani commented 11 years ago

Thanks a lot for the feedback. I will take a look asap on those points you have mentioned.

vladimirnani commented 11 years ago

@AdrianLC I have quite a dilemma here. In order to show some output from runserver I need to read asynchronously output of the process command is running in. That is tough one since you can only read output after subprocess is executed. Another approach would be to manually specify shell for each platform, for example "run cmd.exe" for Windows and "run bash" for Linux. So if you have any ideas about that it would help.

AdrianLC commented 11 years ago

Hello, I have to say I've never used it extensively but subprocess.Popen has some attributes for in/output redirection, pipes, etc. This article seems quite helpful. I just did a quick test:

import subprocess
import sys

top = subprocess.Popen(['top'], stdout=sys.stdout)

and it shows the output in real time, so runserver should be pretty straight forward. The parsing... well, that's likely to be the most difficult.

You could have a look at some other plugins that manage shells. I know there's this project SublimeREPL which does some impressive magic with the shells. The code might be too complex though, I didn't really understand much : /

vladimirnani commented 11 years ago

The thing is that with stdout=subprocess.PIPE it process will redirect output only after command is finished. But in the case of runserver you want to see it realtime.

AdrianLC commented 11 years ago

Like I said I don't really know much about subprocesses. But, the top command is a system resources monitor (CPU usage, memory, etc.) and it doesn't stop until you press 'q'. I got real time output with the code I wrote in my previous comment. Note that even if it works it might not be the best way to redirect stdout. I didn't do exhaustive research on the subject.

vladimirnani commented 10 years ago

Hi. Can you please check it on Fedora again. I have checked on Ubuntu and it seemed to work there.