Notes on Ubuntu (Linux) computing

Brief notes on installation, setup and other tasks in the Ubuntu world

Posts Tagged ‘Ubuntu

Install CherryPy on Ubuntu 12.04

leave a comment »

CherryPy “is a pythonic, object-oriented web framework”. My goal is to use the package to make a simple desktop, browser-based application for looking at the output of statistical inference routines I’ve developed elsewhere — we’ll see if this works (I’m not sure yet).

In any case, the first step is to install with pip:

sudo pip install CherryPy

This should install without issue. There are tutorial scripts located at /usr/local/lib/python2.7/dist-packages/cherrypy/tutorial/ that you should be able to run. For example, the `hello world’ example can be started typing the following at you terminal:

python /usr/local/lib/python2.7/dist-packages/cherrypy/tutorial/tut01_helloworld.py

This will start up the web service and the resulting output can be seen in your browser by going to http://localhost:8080. To exit, close the web browser and use a Cntrl-C at the terminal to stop the server.

As I said above, I’d like to be able to read the contents of local files and display them in a browser. If a local file is called numbers.dat and contains the following:

col1,col2
1,5
2,6
3,2
4,7

We can use the following script to display the contents of the above file:

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""A super simple example of reading a file and displaying results with
CherryPy.

"""
import cherrypy

class ReadFile(object):
    def index(self):
        page = "<html><body>\n"
        page += "<p>Read file: <i>numbers.dat</i></p>\n"

        with open("numbers.dat", "r") as f:
            for line in f.readlines():
                try:
                    col1, col2 = line.strip().split(',')
                    page += "<p>{:s} -- {:s}</p>\n".format(col1, col2)
                except:
                    pass

        page += "</body></html>"

        return page

    index.exposed = True

# start CherryPy
cherrypy.quickstart(ReadFile())

For more detailed documentation and tutorials, see the CherryPy website.

Written by Chris S

January 23, 2014 at 9:49 pm

Garmin forerunner and Ubuntu 12.04 — updated

leave a comment »

This post is an update to a previous post on getting information from my Garmin forerunner 305 using tools in Ubuntu 12.04. A comment on the previous post pointed out that svn repository I used was no longer working. This is not my repository, so I can’t do anything about that. However, I can make a github repository (the code seems to allow for free distribution) with the code I obtained in 2012. In the interest of being thorough I will provide complete instructions here, with updates as needed.

1 To download running information from my Garmin forerunner 305, I will use garmin-forerunner-tools:

sudo apt-get install garmin-forerunner-tools

2 To check the xml schema, we need xmllint. To make this utility available install libxml2-utils:

sudo apt-get install libxml2-utils

3 To do the file conversion between *.gmn and *.tcx we need utilities developed by others. I have made a github repository for them and you can obtain them using:

git clone git@github.com:cstrelioff/garmin-dev.git

If you don’t have git installed, use:

sudo apt-get install git

4 Finally, we have to make use of the utilities we have installed. One way to do this is to make a directory to save data, for example:

mkdir ~/GarminData
cd ~/GarminData

To extract data, connect the watch via USB and run:

garmin_save_runs

At this point you should see that there are *.gmn files in the GarminData directory that use the directory structure: Year/Month/filename.gmn .

Finally, we need to create *.tcx file that can be uploaded to Garmin Connect. To do this, we need to go to the directory where we placed the git repository (you should be able to execute ls in the directory and see the script gmn2tcx). The basic format of a command is:

./gmn2tcx ~/GarminData/Year/Month/filename.gmn > runfilname.tcx

A couple of important things to note, using the command as above, are:

  • the full path name must be provided for the input file
  • the output file runfilename.tcx will be placed in the same directory as gmn2tcx

Written by Chris S

October 21, 2013 at 6:17 pm

Install sympy from github

leave a comment »

Some quick notes on installing sympy package from github. Following instructions located here we first, clone the repo:

git clone git://github.com/sympy/sympy.git

Then change directory and install

cd sympy
sudo python setup.py install

Finally test out the install by importing the package

python

and

import sympy

If everything is okay, as is was for me, there should be no complaints.

Written by Chris S

August 6, 2013 at 8:56 pm

Posted in Python, Ubuntu 12.04

Tagged with , ,

Install pathogen.vim

with 6 comments

I am moving to vim as my main editor. To customize the environment, there are many plugins that make vim more powerful and easier to use. To start, I will install the plugin manager called pathogen. I will follow the install method detailed there and you should check the site for updates before proceeding.

mkdir -p ~/.vim/autoload ~/.vim/bundle;
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim

If the above doesn’t work because you don’t have curl installed, that is easy to remedy

sudo apt-get install curl

If you are new to vim and do not have a .vimrc file, create one with vim:

vim ~/.vimrc

and paste the following lines in a minimal .vimrc file

" Pathogen
execute pathogen#infect()
call pathogen#helptags() " generate helptags for everything in 'runtimepath'
syntax on
filetype plugin indent on

Otherwise, make sure these lines are added to your .vimrc file.

More Information

[1] Pathogen github site
[2] logicalfriday.com post

Written by Chris S

April 11, 2013 at 11:33 pm

pdftk on Ubunt 12.04

leave a comment »

pdftk is a wonderful (command line) tool for manipulating pdf documents in all kinds of ways. See the list of examples at this page to get an idea of what can be done.

To install the version in the repository type

sudo apt-get install pdftk

As an example, I often like to combine many pdf plots into a single document to make viewing easier. This can be done with the command

pdftk *.pdf cat output combinedplots.pdf

This takes all pdfs in the directory and creates a single file called combinedplots.pdf — the source pdfs are not changed, only the new, merged document is created.

Written by Chris S

January 1, 2013 at 7:24 pm

Upgrade nose in Ubuntu 12.04

leave a comment »

A project I am working on uses nose for unit testing. The default version of nose in the Ubuntu 12.04 repository is not the most current and I am experiencing some issues so I will upgrade.

First, remove old package

sudo apt-get remove python-nose

Download the current version (1.2.1)

tar -xzf nose-1.2.1.tar.gz
cd nose-1.2.1/

Following the notes here change line 71 of setup.py from

packages = ['nose', 'nose.ext', 'nose.plugins', 'nose.sphinx'],

to

packages = ['nose', 'nose.ext', 'nose.plugins', 'nose.sphinx', 'nose.tools'],

Finally, install in the usual way

sudo python setup.py install

Written by Chris S

December 28, 2012 at 10:47 pm

Installing pomp in R

leave a comment »

pomp (partially-observed Markov processes) is a package in R for simulating stochastic and deterministic mathematical models as well as to infer parameters using observed data — also see the r-forge page. I will provide (very) brief install instructions here and provide examples of use in later posts.

Install by going to the command line and starting R using sudo (I assume you are using Ubuntu here):

sudo R

Once in R, type:

install.packages('pomp', dep = TRUE)

The pomp package and other packages it requires will be downoaded, compiled, and installed. You can test that pomp is available by loading the package in an R session:

library(pomp)

Written by Chris S

December 22, 2012 at 7:02 pm