Spiga
Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

OneClickInstall for Yum

Spent the whole day today learning Python ElementTree. And the product, a yum plugin for parsing OpenSuSE's One Click Install metadata, though, its still quite incomplete.

I've always wanted something like OCI, and I've been using RPM MetaPackages for most of my previous use. However, MetaPackages have some limitations, one of which it might conflict with existing RPMs, and if I use a lot of metapackages, I'll end up with a rpm database filled with them and each of them must have a unique name. That is good enough for sysadmins, but it can be a hassle for the so-called 'users' in the long term.

OpenSuSE's implementation looks more suitable for me, so, after waiting for quite some time for someone to implement it on fedora (and nobody has - or I didn't notice it), I decided to jump and write my own. However, the implementation on OpenSuSE is only for YaST (which I guess it beats the purpose of having the XML format multi-distro), so, I need to write my own parser.

I have experience writing yum plugins for adding features into yum for specific purposes, so what I needed is to figure out how to extract data from the XML file and install them. Gladly, ElementTree serve that purpose very well. Python Rocks!!.

For those interested to try it out, the code is here - http://kagesenshi-private.googlecode.com/svn/trunk/yum-oneclickinstall/. It works ok through command line, though for GUI, I guess it'll need some work.

To use, first, install it as you would to install any yum plugin (I won't help here, coz I don't want any 'users' to use it at this moment). Get a OneClickInstall XML file, theres an example in the code folder or write your own (OpenSuSE specification is good) and run:

# to install packages
yum oci-install oneclickinstallxmlfile

# to query metadata for packages
yum oci-query packages oneclickinstallxmlfile

# to query metadata for details
yum oci-query details oneclickinstallxmlfile

# to query metadata for repositories
yum oci-query repositories oneclickinstallxmlfile


(Of course, thats nowhere near being One-click)

Installing packages kindof works, but I'm still working on the ability to install 3rd party repository (the code is there, just need to think of some way to make it safe). Adding 3rd party repo feature is controversially not safe, as mixing repositories might make user end up with dependencies and compatibility problems. So, need to think of a good way to handle that.

Anyway, happy trying it. :D

PIDA: An IDE which loves you!

I discovered PIDA while reading around Fedora mailing lists (forgot which thread), and decided to try it out. yum'ed it from the Fedora repository, and launched it.

My first impression - Coool!.. its gvim + version control + shell/terminal + customizable IDE, all in one!.

I usually do development with very basic tools - gvim and a bunch of shells/terminals. I don't like most IDE because of the over-complexity of them. I do use geany or gedit once in a while when I want to have a bit of non-vim'ish behaviour of text editor. But PIDA, its a whole different level. It looks very promising to be my next best-friend.

Not so long after, that I started using it for continuing my current project with Inigo, and quickly, it took over my daily use of gnome-terminal, and my frequent need to change directories and restart Zope. The basic version control feature it have is wonderful. Unlike Eclipse or other IDEs where it is quite hard to get flexibility on how the project is laid out because of the "smartness" of the IDE, PIDA's basic, "stupid", yet useful, version control integration JustWorks.

So far, I have fell in love with this IDE. I haven't tried its other features yet, but I'm quite sure its going to be fun. Its written in Python, so it should be easily extendable. Going to use this a bit more longer and see how my comfort with it - its already replaced my habit of using gnome-terminal at this point of time.

Some screenies:




Tee'ing Python subprocess.Popen output

A little hack for python coders out there who wanted to have a functionality similar to the unix's tee command for redirecting output to multiple places.


import sys
from subprocess import Popen,PIPE
p = Popen(['put','command','and','arguments','here'],stdout=PIPE)

while True:
o = p.stdout.readline()
if o == '' and p.poll() != None: break
# the 'o' variable stores a line from the command's stdout
# do anything u wish with the 'o' variable here
# this loop will break once theres a blank output
# from stdout and the subprocess have ended

Using Glade to write GUI applications

A few useful links for people who want to learn on how to write GTK applications using Glade



The video for using Glade with Python is not very clear, so I'll explain a little bit the process below.

1. Build your GUI

2. Open a .py file, and import gtk and gtk.glade
#!/usr/bin/python
import gtk
import gtk.glade


3. define your handlers method
def hander_method(widget):
do_something_here
do_more


4. load the glade XML
xml = gtk.glade.XML("/path/to/glade/file")


5. connect handlers to its methods/functions
dict = { 'handler_name' : handler_method,
'handler_name2' : handler_method2
}

xml.signal_autoconnect(dict)


6. run gtk instance
gtk.main()


I also have written a similar script to the ruby glade template generator in Video 3. It'll generate a very basic Python template for use. ( I couldn't find where to download GladeGen )

pyglade-gentemplate.py

VMXGenerator.py : Python program to generate VMware configuration

Ok, I'm bored during this holidays ..

While surfing around and playing with Xen and VMWare, I stumbled upon this http://sanbarrow.com/vmxbuilder.html and saw a DOS Shell script to generate VMX. The crazy me took over, I started converting the script to Python~ :P. I have reimplemented most of the basic functionalities of the script in Python classes. Below is the script.

vmxgenerator.py

If youre interested to improve it, Sanbarrow.com provides lots of useful docs related to VMX parameters here - http://sanbarrow.com/vmx.html

Sun Tech Days : University World Tour

My Object Oriented Programming class had a field trip to Sun Tech Day's University World Tour yesterday. It was quite fun for me (considering its free + got a lot of freebies + a free transport home for the mid-sem break).

There was 5 topics on the event

  • What you need to know as a student today: The Next 10 years - by Matt Thompson
    Quite okay talks about what students should grasp in the OpenSource world. How open source fast development can benefit students etc what the web offers for future developers. Nothing much new to me because I'm already in the Free/OpenSource world. Another point of interest was the info about parallel programming will be more important in the future because processors wont go faster but instead it will be denser. And thats something extremely important for future developers.

  • Java and NetBeans Demo's You Shouldn't miss - by Angela Caicedo
    This one was fun to watch. Some demos of Java on non-PC platforms (a.k.a toys). I has been taking Java as a bulky language that eat lots of processor power but after looking at the demo, I think I'll take that back .. haha .. but still .. one of the program she shown (a server program that control a remote buggy bot) hog her processor.. The demo of Looking Glass is also a little bit lagging - Compiz/Beryl is better :P.

  • OpenSolaris for beginners - Peter Karlson
    Considering I'm a linux user, this session is quite fun for me as I got to know another *nix. The demo of Branded Zone was impressive and interesting to me. And I got a Solaris Express DVD from Peter (I was curious about BrandZ and asked some questions about it from Peter).

  • Java Puzzles: If only all learning could be as much fun! - Michael Li
    Some quizzes on finding errors in a Java code, its fun, informative, and fun :P. The quizzes were not that hard if you've been programming Java/C++/Python for a while because they are mostly OOP concepts. I got a free T-shirt in this session (wee~~)

  • Enhancing Employability: The Power Of Sun - Gerald Ng
    Erm .. how to put it .. this session was boring .. haha .. I dont listen to it much ..


Overall the event was fun and informative, however , as Aizat Faiz pointed out, they should give more attention to Free Software and the community around it. Local FOSS groups/developers should also be given chance to talk in the event.

The freebies I got:
  • A Sun Microsystem ballpoint pen - with green lights!!

  • T-Shirts
    • A white T-Shirt - got after messing around during the Duke mascot joke session

    • A black Sun T-Shirt - From the Java Puzzles

    • An orange University World Tour T-Shirt - Everyone got it


  • DVDs
    • Open Solaris Starter Kit
      • I-learn DVD - contains Nexenta OS , Belenix , SchilliX liveCDs

      • I-Install DVD - contains Solaris Express Community Release b54, Nexenta OS Alpha 6 Install, OpenSolaris Source, Sun Studio 11.

    • Solaris Express Developer Edition - Thanks Peter!


On a sidenote, I got to meet my childhood friend from Shah Alam UiTM there. Haven't see her for quite a while considering I've been studying away from home since 4 years ago and when I'm at home I seldom goes out. I also met with Aizat Faiz not long after our session ended but not for long considering he still had more talks to join.

yum-keep-retry plugin

This is my first try to write something useful using python .. so, please tell me if something not right with this plugin ..

Functionality
This plugin add a retry download functionality to yum when download errors happen. Those that got a fast and stable internet seldom get download timeout/checksum/no more mirrors error, but theres a lot of ppl in 3rd world n developing countries have slow/unstable internet and timeouts sometimes occurs too frequently. I wrote this plugin to make yum retry downloading for a few more times before die.

keep-retry.py

Geany : A multi-language, fast and lightweight IDE using GTK2

I noticed a package in Fedora Extras called Geany while shopping through packages using synaptic .. The description says

A fast and lightweight IDE using GTK2

Currently I'm using Anjuta for my assignments and course C/C++ work, but to me, Anjuta is too much for my simple day-to-day programming - which sometimes I just do it on Gedit or Vi - , so I decided to give Geany a try.

At first, I expected it to be a lightweight C/C++ IDE , but to my surprise after launching it, it support lots of languages~!!!!!. C/C++, Java, PHP, Bash Scripting, Python, Ruby, Perl, etc etc. And it does not only support syntax highlighting, but also a basic code completion, a basic class browser, some other simple tools , and best of all, compiling/executing the programs written despite the various languages it supports. Geany select the compilers/interpreters automatically and use it when you click the compile/execute button

The UI is easy enough for use, simple, and effective. It does not have all those advanced project-management modules like Anjuta and Netbeans, but it have everything it needs to be an IDE for simple applications.



A Windows installer is also available from the official Geany site's downloads page