Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Lab: Running a program in JES


Lab2a: Using JES

Lab 2, Part A

Objectives:


Installing JES

If you have not done so already, you need to install JES on your computer.

For Windows Users:
  1. Insert the software CD.
  2. Double-click "My Computer" or open it from the "Start" menu.
  3. Open the CD drive (probably D:) by double-clicking it.
  4. Double-click on the content folder to open it.
  5. Double-click on the JES Software folder to open it.
  6. Double-click on the Windows folder to open it.
  7. If YOU DO NOT HAVE THE CD go here and download JES.zip file. Unzip it and follow the next step.
  8. Copy the folder called "JES" from inside the Windows folder onto your C: drive.
  9. Open the new JES folder on your computer.
  10. Note: There is no installation process for JES.
  11. To open JES, double-click on the snake icon titled "JES". It may take a (possibly very long) minute for JES to get started.
If JES does not open:
  1. Launch JES by double-clicking on the icon called "jes-console.exe". It looks like a black box.
  2. Wait to see if JES opens. If JES opens, you're done! From now on, you'll need to open JES with this icon. But when JES is open, do not close the black console window.
  3. If JES still doesn't open with either method, contact your TA or post your problem to the CoWeb.

******Later in the course, we will be using QuickTime for Java to do video playback. You need to install that now.******

Installing QuickTime for Java:
  1. To download QuickTime from the Apple website go to:QuickTime Download, but Do not download the Win 2000/XP (includes iTunes) option.
  2. Instead, click the link to the QuickTime Standalone installer.
  3. When a screen comes up asking you "Do you want to install and run QuickTime Installer", hit yes.
  4. Select the Custom option when the installer gets to the Choose Installation Type window.
  5. Select as many options as you want to include on your system, but you must check the boxes next to both "QuickTime for Java" and "QuickTime Essentials"
  6. Continue with the installation as directed.
For Mac OS X users:
You will want to use the online version as opposed to the book version. It is the most "upToDate". You can however continue down to the CD installation instructions if you wish, just skip the next sentence and start with step number 1. To install from the website, download JES.sit from here and follow the instructions located there.
  1. Insert the software CD and open it from your desktop.
  2. Open the folder called "Mac". Then click and drag the folder called "JES" into your home directory (the icon that looks like a house). This will copy the folder into your home directory.
  3. To open JES, open the terminal window by going through the menus Applications->Utilities->Terminal. Type in "cd JES". Press enter.
  4. Then type in "./JES &" and then enter. Once JES has opened, you can close the terminal window.

*Unfortunately, video playback will not work from within JES on Macintosh operating systems. All Mac systems do come with QuickTime, though. Almost every video format can be played using QuickTime.

All Users:
  1. After you have gotten JES installed, open the program (see specific directions above).
  2. A message appears about JES in a new window which you should read and then close. This message is only shown the first time you open JES.
  3. Then JES will open a window called "JES Settings". As instructed, type in your full name and your student number (gtXXXXX).
  4. Then click on the button that says Save Changes. This saves your settings. If you have made any mistakes, you can fix them at any time by going to the "Turnin" menu in JES and then selecting "Register".
  5. One valuable reference for the JES environment is the Help utility. Click on the "Help" menu and go to "Getting Started with JES". This will provide you with some beginning information about our programming environment. You will need to read it before you complete the lab.

Running a Recipe in JES

  1. Start up JES.
  2. Copy and paste the the jython code below into a new JES file.


  3. # Simple Picture Example
    
    def example1():
      file = 'barbara.jpg'
      picture = makePicture(file)
      show(picture)
      for pixel in getPixels(picture):
        redValue = getRed(pixel)
        newColor = makeColor( redValue, 0, 255 - redValue)
        setColor(pixel,newColor)
      repaint(picture)
    
    # Add example2() here:
    
    
    
    #Question 1:
    #Which operating system are you using? (Linux, Win95/98, WinNT, WinME, MacOSX, etc.)
    #
    #
    #Question 2:
    #Explain in English what is happening in each line of the recipe and 
    #what the words "def", "file", and "picture" mean in it. # #

  4. Now you must save and load the file. Click the Load button. A dialogue box will ask you if you would like to save. Click "ok," then save the file as "lab2a.py". The file will then automatically load.


  5. The file "barbara.jpg" that we use in example1() is on the CD for this course, along with other pictures and images you will want to use in the future. To access these files easily, you need to copy them onto your computer from the disk like this:
    1. Insert the CD, and then open by clicking on it. Locate the folder labeled "mediasources".
    2. Click on the Mediasources folder to select it, and then copy it by selecting Edit->Copy (or by using the shortcut keys: control + C for Windows, apple + C for Mac).
    3. Now, locate the JES folder on your computer. It should be in your C: drive if you are a Windows user. For Mac users, it is in your home directory. Double-click on the folder to open it.
    4. Paste the mediasources folder into the JES directory by selecting Edit->Paste (or by using the shortcut: control + V for Windows, apple + V for Mac).

  6. To make this recipe work, we need to know the entire path name of the file "barbara.jpg". The path name of a file is like its address in the computer. Each part of the path name gives the computer a smaller, more defined place to look for that file. Every drive, directory, and folder must be noted in the correct order and format for the computer to locate the file. You'll be learning much more about this concept in lecture. For now, we'll give you the path name. However, different operating systems like their path names to look certain ways.  So, make sure you use the correct format:

        Mac and Unix: "/Users/<USER NAME>/JES/mediasources/barbara.jpg"
    *In the space filled above with <USER NAME>, fill in the name of whomever you are logged in as. It is probably your name if you are working on your own computer.

       Windows: "C:\JES\mediasources\barbara.jpg"
    *Windows users need to always place an "r" before any complete path name for a file when using JES. Your path entries in JES should always look like this: r"C:\***\*****\......"

    You also need to know that all file names in JES need to be surrounded by quotation marks. Your recipe should now look like this:

    def example1():  
      file = "/Users/.../JES/mediasources/barbara.jpg"
      picture = makePicture(file)
      show(picture)
      for pixel in getPixels(picture):
        redValue = getRed(pixel)
        newColor = makeColor( redValue, 0, 255 - redValue)
        setColor(pixel,newColor)
      repaint(picture)
    
    OR
    def example1():
      file = r"C:\JES\mediasources\barbara.jpg"
      picture = makePicture(file)
      show(picture)
      for pixel in getPixels(picture):
        redValue = getRed(pixel)
        newColor = makeColor( redValue, 0, 255 - redValue)
        setColor(pixel,newColor)
      repaint(picture)
    
    

  7. Since we have made a change to our lab2a.py file, we need to load it into JES before trying to run example1() again. So click on the Load button, and then reply "ok" to the save prompt. Next, click in the command area. Type example1() at the prompt (>>>) and hit enter. You should first see a picture of a woman and then it should be replaced by a red and blue picture of that same woman. You have just run a recipe in JES!

Writing a JES recipe and writing a picture to the harddrive

What if we wanted to show a different .jpg file? We would have to change the recipe to include the entire path name of the new file and then load the new recipe. We would have to do this every time we wanted to show a new picture. How annoying! Fortunately, there is an easier way to do this. There is a function called "pickAFile()" that will let you find the path to a file on your computer. This function allows you to show any .jpg file on your computer using only one recipe; all you have to do is pick which one you want to see when the computer prompts you.

Here is how you incorporate "pickAFile()" into our previous recipe. All you need to do is:

  1. Copy and paste example1() into the space below the line that says
    # Add example2() here:

  2. Change the name of the function to example2().

  3. Then replace '..\JES\mediasources\barbara.jpg' in your new recipe with "pickAFile()". Your recipe will now look like this:
    
    def example2(): 
      file = pickAFile() 
      picture = makePicture(file)
      show(picture)
      for pixel in getPixels(picture):
        redValue = getRed(pixel)
        newColor = makeColor( redValue, 0, 255 - redValue)
        setColor(pixel,newColor)
      repaint(picture)
    

  4. Since we have made a change to our lab2a.py file, we need to load again to save the changes to the file.

  5. There is one more change we want to make. What if we want to see our picture after we quit JES or share our picture with someone else? JES has a way to do this as well. We use the command writePictureTo().To do this, we will add one more line of code to our recipe.

  6. At the very end of the recipe and at the same indentation as the repaint(picture) command we want to add the command writePictureTo(). writePictureTo() uses two things. First, the picture we want to write out. Second, the location we want to write it to(lets put in in the mediasources folder). Our command will look something like this: writePictureTo(picture, r"C:\JES\mediasources\SomePicture.jpg"). It is very important not to forget the .jpg.
    Note: If you are using MacOS or Linux, you will need to use the form writePictureTo(picture, "/Users/.../JES/mediasources/SomePicture.jpg").

  7. Here is an example of what our recipe will look like.
    def example2(): 
      file = pickAFile() 
      picture = makePicture(file)
      show(picture)
      for pixel in getPixels(picture):
        redValue = getRed(pixel)
        newColor = makeColor( redValue, 0, 255 - redValue)
        setColor(pixel,newColor)
      repaint(picture)
      writePictureTo(picture, r"C:\JES\mediasources\myPicture.jpg")
    

    Note: For this next step, if you pick a really big picture file, it may take a while for the program to run, so be patient.

  8. Next, you can type example2() at the prompt in the command area and hit enter. A File Browser window will appear, allowing you to choose which file you would like to show. To reach a file from "mediasources", however, you must first select which directory JES is in (Home directory for Mac, C: for Windows). Then you must select JES. Then you must select "mediasources". Finally, from there you can select a new .jpg file or you can just use barbara.jpg again.
  9. Once again, you will first see the original picture, then the modified picture. As an added benefit you will now have your picture stored in the mediasources folder on you computer. Find this picture and keep in mind where it is, you will want to use it in the Word portion of this lab.

Questions

Below your two recipes in the JES program area, add your answers to the questions that you copied and placed there. Each line of your written response needs to start with a # so JES doesn't attempt to run your answers. It should look something like:

# Question 1 
#    answer blah blah blah 
#    blah blah

# Question 2 
#    answer blah blah blah 
#    blah blah


Here are the questions again:

Question 1:
Which operating system are you using? (Windows 95, Windows 98, Windows ME, Windows NT, Windows 2000, Windows XP, Mac OS X, Linux, etc.)?

Question 2:
Refer to example1() to answer.

 
def example1():
  file = 'barbara.jpg'
  picture = makePicture(file)
  show(picture)
  for pixel in getPixels(picture):
    redValue = getRed(pixel)
    newColor = makeColor( redValue, 0, 255 - redValue)
    setColor(pixel,newColor)
  repaint(picture)

Explain in English what is happening in each line of the recipe, and what the words "def", "file", and "picture" mean in it.


Turning in Your Lab

Your JES lab and your Microsoft Word lab need to be turned in together. Please complete the Word lab here before continuing the turnin.

The turning method is the same for labs, homeworks, and projects. In order to turn in assignments, your turnin settings must be set up correctly in JES. Hopefully, you did this when you first opened JES. If not, you can set them up by choosing "Settings" in the "Turnin" menu. See "Turning in Assignments" in the "Help" menu for more information.

To submit this lab, first make sure that your answers to the above questions and your two programs (example1() and example2()) are in the program area of the JES window. Be sure that you have loaded to save all of the changes you have made. Your computer must be connected to the Internet, as well.

  1. Go to the "Turnin" menu at the top of the JES Window.
  2. Select the "Assignment" option. This opens a new window in JES which should show your name, your GT#, and the name of the file that you want to submit, in this case lab2a.py.
  3. Select "LAB 2" from the "Assignment to Submit" pull-down menu.
  4. Click on the Add File button under the "Media Files Attached" box. This will give you a file browser window, where you will select the edited Word file that contains your solutions to the other section of this lab (lab2b). Make sure this file appears in the "Media Files Attached" box.
  5. If you collaborated with anyone else on this lab, state this fact and the personís name in the "Notes to TA" box.
  6. Click on the Turnin button at the very bottom of the window to submit your lab.
NOTE:
If you want to turn in a second version of an assignment, you can do so through JES as long as you do so before the assignment is due. For example, if you turn in an assignment two days before it is due, and then find a mistake and correct it, you can still turn in the corrected version as long as you do within two days. However, your TA will only grade your last submission! A new submission will always overwrite the previous submission. Also, JES will not prevent you from turning in assignments after they are due; however, they will not be accepted. You are responsible for turning in assignments before they are due.

Making Sure Things Are Where They Should Be (AFTER TURNIN)

You may be wondering how you will know if your turnin was recieved. Well, there is a website that has a copy of everyone's turnin.

  1. Goto http://coweb.cc.gatech.edu/cs1315turnin. On this page you will see a list of names of people. These are the names of the TAs for this class. Right this second, the TA list isnt updated to reflect the current group of TAs. That will be done most likely while you are doing this lab.
  2. Let us pick a TA. How about Larry Olson? Click on his name. This will bring you to a page of assignments. All of the format Olson:assignment. These are all the assignments you will be turning in through JES.
  3. The next thing to do is to pick the assignment you have just been working on and that you tried to turn in. Click on it. (For this assignment you will click on lab2).
  4. On this page you will see a list of GT numbers. If yours is on this list, then we have recieved your file.

Crash and Burn:

Subtitle: What to do in the event that your file isnt on the turnin page. The way we are going to handle this is the same way that you will attach things to the coweb for future assignemnts. (So pay attention).
  1. We need to get to the place where we want to attach our file. In this example we will go back to the turnin pages on the coweb http://coweb.cc.gatech.edu/cs1315turnin
  2. Now that we are there, we will once again want to find our TA and after that the assignment we are working on. Once again, let's use Larry Olson, and the Lab2 assignment for this example.
  3. Now that we are on the page of turnins (you should see that list of GT numbers again) we can look around. What we will first see is a command at the top of the page called "attach". Click it.
  4. This will bring you to a new page that will show all of the attachments and has an area (text box) at the top to add one. You should see the "browse" button. Click on it. This will open a file selector. Use it to pick the file you want to attach(turnin).
  5. The box should now read whatever the path is to your file. Now click upload. You may be prompted for a password. If this is the case, use user:attach password:carmen. Otherwise, the page should refresh itself and you should be able to see your file at the bottom of the attachments list


If you are having trouble with any part of the lab, you can post to online poker.

Links to this Page