Boston Python Workshop/Friday handout: Difference between revisions

From OpenHatch wiki
Content added Content deleted
imported>Jesstess
imported>Brittag
(removing spam)
 
(72 intermediate revisions by 8 users not shown)
Line 1: Line 1:
Welcome to Friday setup! Setup hours are from 5pm-8pm. Come any time within that block. Expect standard setup to take an hour, and the optional web app setup to take an additional hour.
==Objective==


The goals for this evening are to make sure you have a working environment for writing and running Python code and for writing ColorWall effects. There are also setup instructions and support for a second, optional project: a web app.
After going through this setup document, you will have a Python, git,
and Django environment that lets you write Python code locally. You
will be able to use Github.com and git to track changes to the code
you write.


== Site information ==
This document is available on the web; if you have a printed copy, you can see the URL on the last page. You can always refer back to it, or
show it to other people.


* Friday setup and the Saturday workshop are both happening at [http://microsoftcambridge.com/ Microsoft NERD], which is at One Memorial Drive in Cambridge, in the Thomas Paul room on the 1st floor.
* To access the wireless network, connect to the Cambridge network and open a browser. You should be redirected to a login page, which will prompt you for a wireless code. The code is: pw304.


== Section 1: Accounts on the web ==
== Setting up Python ==


This section has instructions for installing Python and running Python from a terminal prompt.
Time: 15 minutes, hopefully.


# [[Python on Windows|Windows]]
You're going to need accounts on:
# [[Python on OSX|OS X]]
# [[Python on Linux|Linux]]


* Alwaysdata.com: This is a French web hosting company. Their free account level has Django support, so you'll use it to run your code and let other people access it over the web.
In addition to being able to run Python, you should pick the text editor you'll use for writing and saving Python code during the workshop.


* On Windows, you might use NotePad. To start NotePad: click Start, point to Programs, point to Accessories, and then click Notepad.
* Github.com: This is the most popular hosting company for ''git'', a popular version control system. You will use them to store versions of your code.
* On OS X, you might use TextEdit. To start TextEdit: search for TextEdit from Spotlight, or navigate to Applications/TextEdit.
* On Linux, you might use GEdit. To start GEdit: click Applications, point to Accessories, and click Text Editor or you can start it from a terminal with:
gedit


== How to get to a Python prompt ==
=== Alwaysdata account ===


Often in these directions, you'll need to type things at Python prompt. To get one:
Alwaysdata.com lets you create a free hosting account. You'll give
them your name and email address and set a password that you'll use to
log into the account.


* On Windows: Start -> Run -> cmd.exe
* [http://alwaysdata.com/ Go to alwaysdata.com]
** Type this, and press enter:
* Click '''Sign up now'''
** \python27\python
* Choose the "Pack gratuit (10 Mo)". It means "Free account (10 megabytes of storage)".
* On Linux or Mac OS:
* Choose the '''monthly''' payment plan.
** Open a Terminal, and type 'python'


== Intro to Programming stream: Setting up for the ColorWall ==
'''Note''': They will send you your password by email. If you feel
queasy about receiving your password by email, then use one that you
don't mind receiving.


The ColorWall is a framework for writing effects for a wall of pixels. During the Saturday workshop, you will write your own effects for the ColorWall. (see it [http://vimeo.com/16522975 in action])
On the back of this piece of paper, take a moment to write down the
username, email address, and maybe password that you used to sign up
for the Alwaydata.com account.


<gallery widths="100px" heights="100px" perrow="3">
=== Github.com ===
File:Colorwall_rainbow.png
File:Colorwall_matrix.png
File:Colorwall_twinkle.png
</gallery>


===Get project files===
Github.com is the most popular git-based service you can use to store files.
* Create a folder on your desktop called colorwall</li>
* Download the ColorWall project from http://mit.edu/jesstess/www/BostonPythonWorkshop into that folder
** Windows users, try http://mit.edu/jesstess/www/BostonPythonWorkshop/ColorWall.zip first, and download it to your colorwall folder. The file should automatically get uncompressed when you download it.
** OS X and Linux users can get .tar.gz file through Terminal
cd Desktop/colorwall
wget http://mit.edu/jesstess/www/BostonPythonWorkshop/ColorWall.tar.gz
# unpack the tarball
tar -xvf ColorWall.tar.gz


===Install Tkinter===
Go to http://github.com/ and create an account. You can choose whatever username you want. Once it is configured, you can continue on through these setup instructions.
The ColorWall project depends on Tkinter which is pre-installed on some Windows, OS X, and Linux* distributions. To check if you have Tkinter installed, open your Terminal/cmd window and start your Python prompt:
python
>>> import Tkinter


If that command results in an <code>ImportError</code> try following the [http://tkinter.unpythonic.net/wiki/How_to_install_Tkinter instructions for installing Tkinter here] and if you have problems let a staff member know and we'll help you. (*On some Debian installation, when you <code>import Tkinter</code> it will tell you that you need to install the <code>python-tk</code> package, which you should do). After you are done at the Python prompt, exit to the regular terminal by typing <code>exit()</code> and hitting enter.
=== Testing ===


=== Run the ColorWall ===
You might be itching to make sure you created these accounts properly. We'll test that later.
Run the example effects:


* On Windows, assuming the ColorWall software was downloaded to C:\Users\yourusername\Desktop\ColorWall
== Section 2: Installing software ==
run \Python27\python.exe "C:\Users\yourusername\Desktop\colorwall\ColorWall\run.py"
* On OS X, assuming the ColorWall software was downloaded to ~/Desktop/colorwall/ColorWall run
python ~/Desktop/colorwall/ColorWall/run.py
* On Linux, assuming the ColorWall software was downloaded to ~/Desktop/colorwall/ColorWall run
python ~/Desktop/colorwall/ColorWall/run.py


Now we're going to install Django, Python, git, and a text editor.
=== Open run.py in text editor ===
Make sure you can open Python files in a text editor. Test this by running the text editor, navigating to your ColorWall directory, and opening
# Linux
gedit run.py


# Mac/Windows right-click on run.py and "open with" your text editor of choice
Click the '''link that matches your operating system'''.


==== Programmer: You're ready for Saturday! ====
* [[Boston Python Workshop/Friday handout/OS X 10.6 or 10.5|OS X 10.6 or 10.5]] (Snow Leopard or Leopard). [http://www.wiki.devchix.com/index.php?title=Determining_your_OS_X_version Click here if you're not sure what version of OS X you have].
If you're doing the programming section of the workshop tomorrow and you got this far, you're ready to go. Show an instructor your run.py working and also opened in a text editor, get your sticker and go have a good sleep.
* [[/Windows|Windows]] (XP, Vista, or 7)
* [[/Ubuntu and Debian|Ubuntu and Debian]]


== Intro to Web App stream: Setting up Django ==
== Section 3: ColorWall Setup==


If you want to make a web app on Saturday, you'll need to install some additional packages. The web app is an example of an integrated Python-based application. It uses the [http://www.djangoproject.com/ Django] web framework. Because the setup for this project is somewhat involved, this project and its setup are optional. If you run into trouble, get the help of an instructor. '''Instructions''': [[Setting up the web app]]
The ColorWall project has no dependencies beyond Python on common, modern Linux, OS X, and Windows distributions. To confirm that you have no dependencies to install, get to a Python prompt, then run:


==== Web Developer: You're ready for Saturday!====
<code>import Tkinter</code>


If you're doing the web app stream of the workshop tomorrow and you got this far, you're ready to go. Show an instructor that your welcome page on alwaysdata.net is working, get your sticker and go have a good sleep.
at a Python prompt. If that command results in an <code>ImportError</code>, let a staff member know and we'll help get your dependencies set up.

== Section 4: Configuring your accounts on the web ==

=== Alwaysdata: Enable SSH ===

* Log into your Alwaysdata account at https://admin.alwaysdata.com/
* In the left-hand side, underneath '''Remote access''', click '''SSH'''
* Click the gear icon for your user
* Click the "Enabled" checkbox to enable ssh access.
* Click ''Submit''!

=== Put your SSH key on Github ===

Follow Github's instructions:

* Go to http://help.github.com/key-setup-redirect
* Go to https://github.com/account (log in if you have to), click the "SSH Public Keys" tab, and click "Add another public key"
* Follow ''just'' that section.

If you need help finding your SSH key, ask a volunteer. You're looking for a file called '''id_rsa.pub'''.

=== Make sure Git and Github are working together ===

* First, load https://github.com/ in a new tab.

* Then, open up http://help.github.com/create-a-repo/ and follow the instructions to create a repository.
** On Mac OS or a GNU/Linux system, open a Terminal. On Windows, use GitBash.

Follow the instructions carefully; for example, do call your repository ''Hello World'' as they suggest.

If it worked, you'll see a new repository listed in your Github.com account, and it will have a README file explaining what it is.

== Section 5: Deploying your first web application ==

Remember how you made a Django site earlier in the directions? The volunteers made a site like, too, and we added some special configuration to make it work well with Alwaysdata.com.

You're going to '''fork''' this git repository so that when make your own changes to it, you can push those changes to your personal Github account. (You have to fork the repository because otherwise Github won't let you make changes to "my" project!)

=== Fork our project on Github ===

* Go to https://github.com/paulproteus/workshop_mysite
* Click the "Fork" icon
* Go to your personal fork of the project.

=== Clone it to alwaysdata.com ===

* Copy the "Git Read-Only" version of the repository URL to the clipboard
* In your SSH client (PuTTY or ssh), connect to this host:

your_alwaysdata_username@ssh.alwaysdata.com

* Enter this command into the terminal, but don't press '''enter''' yet:

git clone

* Now '''paste''' in the repository URL, and hit '''enter'''.

=== Configure alwaysdata.com to serve your site ===

This is the '''last''' step: Tell alwaysdata.com how to serve up your site to the world.

* Go to the Alwaysdata.com '''Domains''' administration page: https://admin.alwaysdata.com/domain/
* Find your domain, and click the gear to '''edit'''.
* Enter this into the form as the '''Root directory''':

/workshop_mysite/public/

== That's it! Friday is over ==

Chat with us! Ask questions! Go home!

Love,

Boston Python Workshop staff.

Latest revision as of 07:58, 18 August 2013

Welcome to Friday setup! Setup hours are from 5pm-8pm. Come any time within that block. Expect standard setup to take an hour, and the optional web app setup to take an additional hour.

The goals for this evening are to make sure you have a working environment for writing and running Python code and for writing ColorWall effects. There are also setup instructions and support for a second, optional project: a web app.

Site information

  • Friday setup and the Saturday workshop are both happening at Microsoft NERD, which is at One Memorial Drive in Cambridge, in the Thomas Paul room on the 1st floor.
  • To access the wireless network, connect to the Cambridge network and open a browser. You should be redirected to a login page, which will prompt you for a wireless code. The code is: pw304.

Setting up Python

This section has instructions for installing Python and running Python from a terminal prompt.

  1. Windows
  2. OS X
  3. Linux

In addition to being able to run Python, you should pick the text editor you'll use for writing and saving Python code during the workshop.

  • On Windows, you might use NotePad. To start NotePad: click Start, point to Programs, point to Accessories, and then click Notepad.
  • On OS X, you might use TextEdit. To start TextEdit: search for TextEdit from Spotlight, or navigate to Applications/TextEdit.
  • On Linux, you might use GEdit. To start GEdit: click Applications, point to Accessories, and click Text Editor or you can start it from a terminal with:
gedit

How to get to a Python prompt

Often in these directions, you'll need to type things at Python prompt. To get one:

  • On Windows: Start -> Run -> cmd.exe
    • Type this, and press enter:
    • \python27\python
  • On Linux or Mac OS:
    • Open a Terminal, and type 'python'

Intro to Programming stream: Setting up for the ColorWall

The ColorWall is a framework for writing effects for a wall of pixels. During the Saturday workshop, you will write your own effects for the ColorWall. (see it in action)

Get project files

cd Desktop/colorwall
wget http://mit.edu/jesstess/www/BostonPythonWorkshop/ColorWall.tar.gz
# unpack the tarball
tar -xvf ColorWall.tar.gz

Install Tkinter

The ColorWall project depends on Tkinter which is pre-installed on some Windows, OS X, and Linux* distributions. To check if you have Tkinter installed, open your Terminal/cmd window and start your Python prompt:

python
>>> import Tkinter

If that command results in an ImportError try following the instructions for installing Tkinter here and if you have problems let a staff member know and we'll help you. (*On some Debian installation, when you import Tkinter it will tell you that you need to install the python-tk package, which you should do). After you are done at the Python prompt, exit to the regular terminal by typing exit() and hitting enter.

Run the ColorWall

Run the example effects:

  • On Windows, assuming the ColorWall software was downloaded to C:\Users\yourusername\Desktop\ColorWall
run \Python27\python.exe "C:\Users\yourusername\Desktop\colorwall\ColorWall\run.py"
  • On OS X, assuming the ColorWall software was downloaded to ~/Desktop/colorwall/ColorWall run
python ~/Desktop/colorwall/ColorWall/run.py
  • On Linux, assuming the ColorWall software was downloaded to ~/Desktop/colorwall/ColorWall run
python ~/Desktop/colorwall/ColorWall/run.py

Open run.py in text editor

Make sure you can open Python files in a text editor. Test this by running the text editor, navigating to your ColorWall directory, and opening

# Linux
gedit run.py
# Mac/Windows right-click on run.py and "open with" your text editor of choice

Programmer: You're ready for Saturday!

If you're doing the programming section of the workshop tomorrow and you got this far, you're ready to go. Show an instructor your run.py working and also opened in a text editor, get your sticker and go have a good sleep.

Intro to Web App stream: Setting up Django

If you want to make a web app on Saturday, you'll need to install some additional packages. The web app is an example of an integrated Python-based application. It uses the Django web framework. Because the setup for this project is somewhat involved, this project and its setup are optional. If you run into trouble, get the help of an instructor. Instructions: Setting up the web app

Web Developer: You're ready for Saturday!

If you're doing the web app stream of the workshop tomorrow and you got this far, you're ready to go. Show an instructor that your welcome page on alwaysdata.net is working, get your sticker and go have a good sleep.