Wednesday, May 5, 2010
Monday, April 26, 2010
Thursday, April 8, 2010
Django + Eclipse + PyDev + Aptana
For those who likes Django, which IDE do you like the most for development? Of course this is subjective thing, and it's always interesting to see different answers to that question. Some people says vim, notepad++, some other likes commercial IDEs.
In this case, I prefer eclipse with pydev and aptana plugins.
Once you have Python, Django, and Eclipse installed in your system, it is time to install the necessary plugins.
First is to install PyDev plugin. Install new software in eclipse using this url http://pydev.org/updates.
Then of course configure PyDev to use the appropriate python interpreter that you already have. To do that go to eclipse preferences.
Next is to install Aptana Studio, using this url http://update.aptana.com/install/studio.
Now, you can create django project, either using eclipse's wizard, or using django-admin.py script and import it in your eclipse project.
If you use django orm you will notice that 'DoesNotExist' keyword is not recognized. To solve this matter, do the following:
go to eclipse preferences -> pydev -> editor -> code analysis -> Consider the following names as globals --> add 'DoesNotExist'
Then it is time to configure your project so you can run and debug it in eclipse.
To do that, you need to perform the following:
go to project properties -> run/debug settings -> new (python run)
In main tab:
set the project, choose by clicking the browse button.
set main module, choose by clicking the browse button and select the project's manage.py. When you are doen, it would show something like the following:
${workspace_loc:project/app/path/manage.py}
This step is important, if you are using Aptana Studio plugin. By default django will user port 8000 for it's web server, which conflicts with Aptana Studio plugin service. So it is better to use some other port for django web server.
Again, go to project properties -> run/debug settings.
In arguments tab:
runserver 8080 --noreload
Notice that I am using port 8080 for the web server.
In environment tab:
add new variable:
variable: DJANGO_SETTINGS_MODULE
value: settings
At this point you can test running your django project by using the run setting that configured previously. Enjoy debugging your django project in eclipse.
In this case, I prefer eclipse with pydev and aptana plugins.
Once you have Python, Django, and Eclipse installed in your system, it is time to install the necessary plugins.
First is to install PyDev plugin. Install new software in eclipse using this url http://pydev.org/updates.
Then of course configure PyDev to use the appropriate python interpreter that you already have. To do that go to eclipse preferences.
Next is to install Aptana Studio, using this url http://update.aptana.com/install/studio.
Now, you can create django project, either using eclipse's wizard, or using django-admin.py script and import it in your eclipse project.
If you use django orm you will notice that 'DoesNotExist' keyword is not recognized. To solve this matter, do the following:
go to eclipse preferences -> pydev -> editor -> code analysis -> Consider the following names as globals --> add 'DoesNotExist'
Then it is time to configure your project so you can run and debug it in eclipse.
To do that, you need to perform the following:
go to project properties -> run/debug settings -> new (python run)
In main tab:
set the project, choose by clicking the browse button.
set main module, choose by clicking the browse button and select the project's manage.py. When you are doen, it would show something like the following:
${workspace_loc:project/app/path/manage.py}
This step is important, if you are using Aptana Studio plugin. By default django will user port 8000 for it's web server, which conflicts with Aptana Studio plugin service. So it is better to use some other port for django web server.
Again, go to project properties -> run/debug settings.
In arguments tab:
runserver 8080 --noreload
Notice that I am using port 8080 for the web server.
In environment tab:
add new variable:
variable: DJANGO_SETTINGS_MODULE
value: settings
At this point you can test running your django project by using the run setting that configured previously. Enjoy debugging your django project in eclipse.
Monday, March 22, 2010
Text Processing and Data Extraction using sed and awk
Some weeks ago, my friend contacted me for a help. He needs to extract some data from a text file. I am familiar with this stuff, since in my old job I do this quite often. Like usual, the data was just a colon (:) separated file. He needs to extract all fields that starts or contains a particular text. It can appear in different column of the row.
So, I played around using awk, and got something like the following:
Since not long before he asked, I had played around much with regex grouping in python. I just needed to translate the my python regex knowledge in sed. Not much work, of course. So, I came up with the following method, using sed:
Notes: "CSP" is the text that needed to be extracted from the text file, along with some other number(s) after that.
Lots of stuff can be done by regex.
Thanks to Dr.Bunker who taught me so much about regex.
So, I played around using awk, and got something like the following:
awk -F\: '/CSP/ { for(i=1;i<=NF;i++) { if($i ~ "CSP") print $i } }' raw_text_file.txt
Since not long before he asked, I had played around much with regex grouping in python. I just needed to translate the my python regex knowledge in sed. Not much work, of course. So, I came up with the following method, using sed:
sed -r 's/.*(CSP,[0-9]+[:;]).*/\1/g' raw_text_file.txt
Notes: "CSP" is the text that needed to be extracted from the text file, along with some other number(s) after that.
Lots of stuff can be done by regex.
Thanks to Dr.Bunker who taught me so much about regex.
Sunday, March 14, 2010
Friday, March 12, 2010
Automatic Display Manager Login using nodm
My posting @ https://answers.launchpad.net/ubuntu/+question/101990
I tried your method and it worked. I have been playing around to get such result for two days. Well, actually there is a little bit of story before I get the result that I wanted. So, I tried some other similar method to Curtis', in my VirtualBox Ubuntu Guest OS. The strange thing is I kept getting problems. The X did not start, and the virtual console resolution got big and too wide.
I had a feeling that I might get different result in "real" system. So, I installed ubuntu 9.10 and applied Curtis' method. It worked. I am glad. What I noticed is that the X is running in virtual terminal #9 (instead of #7). No issue.
I have another method though. During my search, someone mentioned about 'nodm' for automatic display manager. Neat! Yesterday I tried it on VirtualBox with no success. Today I tested it in "real" system and all is well. I really recommend this method.
During 'nodm' installation, I had to remove existing display manager(s) first. Then, set the proper configuration in /etc/default/nodm. Enjoy!
I tried your method and it worked. I have been playing around to get such result for two days. Well, actually there is a little bit of story before I get the result that I wanted. So, I tried some other similar method to Curtis', in my VirtualBox Ubuntu Guest OS. The strange thing is I kept getting problems. The X did not start, and the virtual console resolution got big and too wide.
I had a feeling that I might get different result in "real" system. So, I installed ubuntu 9.10 and applied Curtis' method. It worked. I am glad. What I noticed is that the X is running in virtual terminal #9 (instead of #7). No issue.
I have another method though. During my search, someone mentioned about 'nodm' for automatic display manager. Neat! Yesterday I tried it on VirtualBox with no success. Today I tested it in "real" system and all is well. I really recommend this method.
During 'nodm' installation, I had to remove existing display manager(s) first. Then, set the proper configuration in /etc/default/nodm. Enjoy!
Subscribe to:
Posts (Atom)
