Multiple Version Control Systems At Once!

Posted July 12, 2010 under General, Hacking, Keryx, Ubuntu

For Keryx, I have been working on a new backend system called Unwrapt (A play on words regarding the APT package system :P ). I’ve been coding on github for the social coding aspects and keeping the branch on Launchpad.net as well to be part of Keryx’s page. This meant every time I wanted to commit and push, I’d have to do twice the amount of commands. Of course, being a lazy coder like the rest of us, I decided to script it. Fired up Gedit, and two seconds later I had this:

#!/bin/bash
 
bzr commit -m "$@"
bzr push
 
git commit -am "$@"
git push origin master

Usage is simple (example is using this script saved in ~/vcs.sh). Just execute this from inside your versioned directory like you would normally with git and bazaar:

$ sh ~/vcs.sh "first commit"

It pushes to your default branches (if you have any setup) in one strike using the commit message you pass to the script. Easy as that! I’m sure people might have some good ideas on features and improvements so leave them in the comments!


Getting Started With Quickly

Posted June 21, 2010 under Keryx, Python

Recently an open source project called Quickly has sprung up and looks to be an incredible tool for new developers looking to work on open source GUI projects. The description from their website reads as follows:

Quickly helps you create software programs (and other things) quickly. You can select from a set of application templates and use some simple quickly commands to create, edit code and GUI, and publish your software for others to use. Quickly’s templates are easy to write. So if you are a fan of language foo, you can create a foo-project template. Or if you want to help people making plugins for your killer app, you can make a killer-app-plugin template. You can even create a template for managing corporate documents, creating your awesome LaTeX helpers The sky is the limit!

Sounds like a cool project right? You bet. I’m going to be using Quickly to begin working on the official unstable branch for Keryx 1.0 and will outline the steps I took to get started here.

Installing Quickly

Super simple. Just fire up a terminal and “sudo apt-get install quickly” or install the quickly package via Synaptic or your favorite package management tool (maybe even through Keryx!). Once that is installed, you can fire up the documentation if you like by typing “quickly tutorial ubuntu-application” and it will open up the Quickly User Guide which is a handy reference.

Creating a Project

Nothing more than a “quickly create ubuntu-application keryx”. Just tells quickly you are building a new application with the Ubuntu template named Keryx. Simple as that. It sets up the directory structure for you and everything! So handy!

Getting to Work

Modifying the GUI is simple, just do “quickly design” and Glade is opened up with your ui file ready to go. The same goes for editing the code with a simple “quickly edit” which opens up all the files necessary for your application in your standard text editor.

Committing

“quickly save notes” is all you need to do to make a commit of your changes with the comment “notes” and submit this to launchpad using the bzr version control system.

There are a few other commands you might be interested in, mainly for packaging and releasing but this is a very simple tutorial on how we setup Keryx 1.0. If you’d like to contribute, just download the unstable code branch from launchpad and start using it with Quickly!

So I suppose I will leave it at that for now. Quickly is a way for new developers and contributors to easily be able to jump in and start working on projects. We will be using this for Keryx 1.0 and hope this will encourage contributions and make bugs easier to fix.


Resume downloads with PycURL RESUME_FROM

Posted June 12, 2010 under Keryx, Python

If you’ve ever played with urllib, you might have noticed its reasonably slow download speeds and wanted something a little bit more. That’s where cURL comes into play. It’s a very powerful library and is used in applications such as Gwibber. Seeing that this ships with Ubuntu, it is a good fit for Keryx’s new backend library Unwrapt.

I spent yesterday working on this new downloading code and wanted to share my code as I found the documentation (in reality, the entire library too) is primarily in C style and confusing examples. This is an easy to use class that helps to take care of some of the mundane details like following redirects (which is important! if you don’t enable this you won’t be able to reach a lot of files). I plan on extending this to support proxies soon as well as a GTK progress function.

#    Unwrapt - cross-platform package system emulator
#    Copyright (C) 2010 Chris Oliver <chris@excid3.com>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
import math
import pycurl
import os
import time
import sys
 
 
class EasyCurl:
 
 
    def __init__(self, proxy=None):
 
        self.pco = pycurl.Curl()
        self.pco.setopt(pycurl.FOLLOWLOCATION, 1)
        self.pco.setopt(pycurl.MAXREDIRS,      5)
        #self.pco.setopt(pycurl.TIMEOUT,       5*3600)
        self.pco.setopt(pycurl.CONNECTTIMEOUT, 30)
        self.pco.setopt(pycurl.AUTOREFERER,    1)
 
        #TODO: Proxy!
 
 
    def perform(self, url, filename=None, resume=True, progress=None):
 
        # Generate filename if not given
        if not filename:
            filename = url.strip("/").split("/")[-1].strip()        
        self.filename = filename
 
        # Get resume information 
        self.existing = self.start_existing = 0
        if resume and os.path.exists(filename):
            self.existing = self.start_existing = os.path.getsize(filename)
            self.pco.setopt(pycurl.RESUME_FROM, self.existing)
 
        # Configure progress hook            
        if progress:
            self.pco.setopt(pycurl.NOPROGRESS,       0)
            self.pco.setopt(pycurl.PROGRESSFUNCTION, progress)
 
        # Configure url and destination
        self.pco.setopt(pycurl.URL, url)
        self.pco.setopt(pycurl.WRITEDATA, open(filename, "ab"))
 
        # Start
        self.pco.perform()
 
        sys.stdout.write("n")
 
 
    def textprogress(self, download_t, download_d, upload_t, upload_d):            
 
        downloaded = download_d + self.existing
        total      = download_t + self.start_existing
        try:    frac = float(downloaded)/float(total)
        except: frac = 0
 
        bar = "=" * int(25*frac)
 
        sys.stdout.write("r%-25.25s %3i%% |%-25.25s| %5sB of %5sB" % 
            (self.filename,
             frac*100,
             bar,
             format_number(downloaded),
             format_number(total)))
 
 
# Borrowed from the urlgrabber source
def format_number(number, SI=0, space=' '):
    """Turn numbers into human-readable metric-like numbers"""
    symbols = ['',  # (none)
               'k', # kilo
               'M', # mega
               'G', # giga
               'T', # tera
               'P', # peta
               'E', # exa
               'Z', # zetta
               'Y'] # yotta
 
    if SI: step = 1000.0
    else: step = 1024.0
 
    thresh = 999
    depth = 0
    max_depth = len(symbols) - 1
 
    # we want numbers between 0 and thresh, but don't exceed the length
    # of our list.  In that event, the formatting will be screwed up,
    # but it'll still show the right number.
    while number > thresh and depth < max_depth:
        depth  = depth + 1
        number = number / step
 
    if type(number) == type(1) or type(number) == type(1L):
        # it's an int or a long, which means it didn't get divided,
        # which means it's already short enough
        format = '%i%s%s'
    elif number < 9.95:
        # must use 9.95 for proper sizing.  For example, 9.99 will be
        # rounded to 10.0 with the .1f format string (which is too long)
        format = '%.1f%s%s'
    else:
        format = '%.0f%s%s'
 
    return(format % (float(number or 0), space, symbols[depth]))
 
 
if __name__ == "__main__":
    url = "http://launchpad.net/keryx/stable/0.92/+download/keryx_0.92.4.zip"
    ec = EasyCurl()
    ec.perform(url, progress=ec.textprogress)

Unable to open file: unknown opcode

Posted June 10, 2010 under Keryx, Python

Well, this certainly isn’t too common of a problem it appears. I have been searching for a bit today trying to work out a recent Keryx bug that has crept up on our current stable release. Took me a little bit but I seem to have figured it out.

Now this all is all based around our Pyinstaller Linux binary. We packaged this with 1.4 (pre-release) and didn’t think much of it until now. It seemed that the release we had built ran fine on Ubuntu 32 and 64bit releases. That has proved to be an incorrect assumption now. Something must have changed in the latest Ubuntu release that caused this to break. Maybe it’s libraries that have changed, maybe it’s something else. I’m not sure.

What happens is when you run the Pyinstaller Linux binary of Keryx on a 64bit machine, you receive the following errors:

/usr/lib/gio/modules/libgvfsdbus.so: wrong ELF class: ELFCLASS64
Failed to load module: /usr/lib/gio/modules/libgvfsdbus.so
/usr/lib/gio/modules/libgioremote-volume-monitor.so: wrong ELF class: ELFCLASS64
Failed to load module: /usr/lib/gio/modules/libgioremote-volume-monitor.so
/usr/lib/gio/modules/libgiogconf.so: wrong ELF class: ELFCLASS64
Failed to load module: /usr/lib/gio/modules/libgiogconf.so
XXX lineno: 320, opcode: 54
Unable to open file: unknown opcode

This appears to happen when opening the gzip files which we downloaded just before the error occurred. The rest of the application seems to have normal execution. Testing this exact same release on my Eee PC running 32 bit Ubuntu 10.04, you can imagine that it worked perfectly fine. So it appears that something in the Python gzip libraries that was dynamically linked (and not bundled into the executable) has changed and is no longer compatible.

I’m working on building a 64bit copy of the Linux executable using Pyinstaller for those users. I’ll post an announcement on the Keryx website when it is available.


Keryx Shwag!

Posted June 6, 2010 under Keryx

Available starting today is our CafePress store! You can buy things like Keryx tshirts, hoodies, and gift items to support the project! http://shops.cafepress.com/KeryxProject


« Older | Newer »