1. My First Python Project
Neetu Jain
Software Engineer
Softlayer, IBM
nutshi@gmail.com, njain@softlayer.com
2. What’s Ahead?
What to expect when diving into python:
Bird’s eye view of “getting started into python”
How to start your first python project:
some kind of a skeleton , resources, pointers
Help you realise that some comics hit close to home:
Thanks to xkcd.com
*** if you already know python, you might not get much out of this talk :)***
3. First Stop:Install
Python Version:
Python 2.x or Python 3.x
Python IDE:
Pycharm, pythonwin, sublime ...e.t.c
version control:
git, svn...e.t.c
14. Tests:made easy
$python unittest_simple.py
$ python unittest_simple.py -v
test (__main__.SimplisticTest) ... ok
------------------------------------
Ran 1 test in 0.000s
OK/FAIL/ERROR
unittest_simple.py
import unittest
class FixturesTest(unittest.TestCase):
def test(self):
print 'in test()'
self.failIf(True, 'failure message goes here')
if __name__ == '__main__':
unittest.main()
15. Python: you can do a lot!
Process mgmt: supervisor
Deployment mgmt :fabric Database: sqllite
Web framework:flask Messaging: pika(amqp)
16.
17. Virtual environment
$ [sudo] pip install virtualenv
$ cd ~/code/myproject/
$ virtualenv env
New python executable in env/bin/python
Installing setuptools............done.
Installing pip...............done.
$ ls env
bin include lib
$ which python
/usr/bin/python
$ source env/bin/activate
$ which python
/Users/name/code/myproject/env/bin/python
20. vagrant VM manager
$ vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
$ mkdir my_vagrant_test
$ cd my_vagrant_test
$ vagrant init lucid32
$ vim Vagrantfile
$ vagrant up
$ vagrant ssh
$ vagrant status
$ vagrant reload
$ vagrant destroy
21. Supervisor: A Process Control System
vagrant@buzz:~$ supervisord -c /vagrant/scripts/supervisord.conf
vagrant@buzz:~$ sudo supervisorctl -c /vagrant/scripts/supervisord.conf
apnsfb RUNNING pid 5671, uptime 0:02:17
buzz RUNNING pid 5673, uptime 0:02:17
flask RUNNING pid 5672, uptime 0:02:17
vagrant@buzz:~$ cat /tmp/supervisord.log
2014-09-12 18:31:22,001 CRIT Supervisor running as root (no user in config
file)
2014-09-12 18:31:22,017 INFO RPC interface 'supervisor' initialized
22. My First Python Project
Neetu Jain
Software Engineer
Softlayer, IBM
nutshi@gmail.com, njain@softlayer.com
Editor's Notes
Vagrant, an open-source product released in 2010, is best described as a VM manager. It allows you to script and package the VM config and the provisioning setup. It is designed to run on top of almost any VM tool – VirtualBox, VMWare, AWS, etc.