NPM ? SVN : SF

Registored for an account on Source Forge today and set up a project there for NPM.

My primary goal at the moment is the website because managing the source code on my laptop is no real problem, you could say I’m my own revision control system.

I’m planning on putting Source Forges project SVN Repository to work soon though. I am some what familiar with CVS, I’ve used it in the past but I’m not fond of it. Like emacs my relationship with CVS is a case of being able to live with it but not partial to it.

So in accordance with how much I have had to learn in getting this project a moving, I’ve elected to study a bit about using SVN. Heck, I havn’t used C++ in ages, I even hated the Python tutorials and never found the time to learn GUI toolkits besides (old version of) Java’s AWT. I also had to do a fair bit of hide and seek throughout the ports system internals. So I may as well learn a new versioning control system while I’m at it.

Hmm, busy busy busy time ! I’d love to get a micro-website and an alpha release sorted out this month.

NOTE TO SELF: Upload map for tomorrows live op tonight!

3 Modules and a pillow.

Been at work on 3 modules tonight, the searchlet looks like it’s able to stand alone quite well, leaving the NPM_MainWindow() to sort out how to lay it out in the main window. The module to handle pkg_info is becoming likewise (atm it’s just a thin layer around QListView). I’ve also made a few minor changes to the dialogs module, as soon as I have time to learn a more effective way of dealing with the arg’s involved I can get several classes sorted quickly in that module.

Very productive day all around it seems lol.

Now for some Simpsons and Sleep……. zzzZzzzzZzzzZzzZzzz

Spent last night working on further modulariation of the NPM_MainWindow class and I ended up sleeping next to Dixie =/

How many lucky guys get to wake up next to a laptop hahaha !!!

Today every one else was out so I managed to get time to sort out my paper work, makes me feel a little better at having dozed of after 2-3am =/

We also had a nice live op.. Went quite nice until we came to an area, from what I could see through lakes cam I thought the area was maybe 25-30m square. So I figured, roll a sting ball out and dominate along the two flanks. One man down in the entry attempt, 2 pinned down and one separated…

Moving out and trying to take cover we lost 2 more men so I shouted for Pittman to hold in cover.. Only to get sniped by a buckshot firing shotgun lol…. My failure not the teams.

Playing through the round for fun after we failed the live op (yuke whent to post the report). The resut of us went through again to explor, finding out that the area was closer to 45-55m square with evated shooters along one flank.

Nice secrets we uncovered, lake found a secret passage ‘ghost wall’ that opens a passage into hallway below. There’s a |_| area there that leads into a pair of dark rooms, one of which the door to the out-side is closed until you get to the room; it was there when we were exploring. But not there when me and Lake when hunting, until we cleared that room!

The passage under the pools, I h ad fired several 5.56x45mm FMJ into it before but no go, Lake applied his .45Cal UMP45 and it worked :-). So we went through the water, up to the secret room, and back through a sand filled set of hallways and boom.

We found out that the statue of a Crypt guarded by Anubis had slid to one side, unveiling the next hidden passage and exit.

While Lake went off to hunt down stuff, I tried walking off a platform into some plants. To my shop I fell through and found myself in an armour, varius pisol, smg, ar, sg, and tac aids on shelves and I took this screen shot of names on the wall:

[Click to Enlarge]
Free Image Hosting at www.ImageShack.us

code at last

Spent tonight working on rewritten logger and options modules for the next phases of their prototypes.

There still is a fair bit of work to do with logger (i.e. telling it / getting from it the name of log file(s)) but it’s now essentially integrated with the rest of the program. Internally the module might change quite a bit but it’s usage throughout NPM will remain pretty much the same save where the above is concerned ^ (basically within the options module).

The options module is quite a lot cleaner imho, now has a search for a config file and can write the configuration file, the module matures bit by bit. I’ve also streamlined the configuration file a bit but I’ve still got to find the time to work on some concept drawings of the GUI’s configuration menu.

I also want to take a look at QAction and QActionGroup later on based on inputs from the QT4 doc’s.

*technically* I could probably get it operational for building a port right now with a wee bit of work… But I’d much rather have the bloody thing working properly and tested first :-).

*sigh* after 0400… time for bed because work is in the morning. It sucks that I’ve to wait till like 2300 or later to start coding… Any attempt at getting stuff done while the rest of my family is awake has proved futile over the last year and a half….. I could be so much more productive if I didn’t have to cram-things around every one.. I’ve got paper work due for En4cers inbox that’s overdue, school work piling up, and a project to work on (npm) and I’ve got to fit it all into the time slot of

>= every one else in bed
< I'm ready to pass out
< the time to go to work
<= time to go to bed if I'm ever gonna get to work on time
Grrr…

snoring through logging

been working on a simple logging module for npm, so far I’ve set it up to handle 3 different outputs, the usual STDERR for big problems, a regular log file for every thing but debugging, and a developers log file for use during debugging.

stderr
CRITICAL: critical message
ERROR: error message
WARNING: warning message
run log
2007-12-27 07:27:45,156: CRITICAL -:- critical message
2007-12-27 07:27:45,157: ERROR -:- error message
2007-12-27 07:27:45,157: WARNING -:- warning message
2007-12-27 07:27:45,158: INFO -:- info message
dev log
2007-12-27 07:27:45,156 root CRITICAL: logger.logger.py.73
critical message
2007-12-27 07:27:45,157 root ERROR: logger.logger.py.74
error message
2007-12-27 07:27:45,157 root WARNING: logger.logger.py.75
warning message
2007-12-27 07:27:45,158 root INFO: logger.logger.py.76
info message
2007-12-27 07:27:45,159 root DEBUG: logger.logger.py.77
debug message

The formats are just a matter of what I find easy on the eyes, think the middle one could stand with a shorter date format.

I might ditch the idea of a second log file and just follow my original idea of being able to specify the level of logging to use. It’d also be less work then

Either way yee slice it, I need some freaking sleep… because I can’t think no more.

:wq!

Qute I/O

Been meandering about with Pythons subprocess and various IPC (inter Process Communication) focuses modules tonight. When I remembered I had noted that QT and KDE had classes for working with processes.

Looked up the class in the documentation and played with it. Then I found a small example program that they included. Here is the QT written example using C++, the primary language.


/****************************************************************************
** $Id: qt/process.cpp 3.3.7 edited Aug 31 2005 $
**
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
**
** This file is part of an example program for Qt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#include <qobject.h>
#include <qprocess.h>
#include <qvbox.h>
#include <qtextview.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <qmessagebox.h>

#include <stdlib.h>

class UicManager : public QVBox
{
Q_OBJECT

public:
UicManager();
~UicManager() {}

public slots:
void readFromStdout();
void scrollToTop();

private:
QProcess *proc;
QTextView *output;
QPushButton *quitButton;
};

UicManager::UicManager()
{
// Layout
output = new QTextView( this );
quitButton = new QPushButton( tr("Quit"), this );
connect( quitButton, SIGNAL(clicked()),
qApp, SLOT(quit()) );
resize( 500, 500 );

// QProcess related code
proc = new QProcess( this );

// Set up the command and arguments.
// On the command line you would do:
// uic -tr i18n "small_dialog.ui"
proc->addArgument( "uic" );
proc->addArgument( "-tr" );
proc->addArgument( "i18n" );
proc->addArgument( "small_dialog.ui" );

connect( proc, SIGNAL(readyReadStdout()),
this, SLOT(readFromStdout()) );
connect( proc, SIGNAL(processExited()),
this, SLOT(scrollToTop()) );

if ( !proc->start() ) {
// error handling
QMessageBox::critical( 0,
tr("Fatal error"),
tr("Could not start the uic command."),
tr("Quit") );
exit( -1 );
}
}

void UicManager::readFromStdout()
{
// Read and process the data.
// Bear in mind that the data might be output in chunks.
output->append( proc->readStdout() );
}

void UicManager::scrollToTop()
{
output->setContentsPos( 0, 0 );
}

int main( int argc, char **argv )
{
QApplication a( argc, argv );
UicManager manager;
a.setMainWidget( &manager );
manager.show();
return a.exec();
}

#include "process.moc"

Needless to say, I am not really a fan of C++ at times ^_^. I translated the example into Python for a simple test and I like it quite a bit.

#!/usr/local/bin/python

# I translated the example: process/process.cpp to python and boy do I love qt!
#
#############################################################################
##
## Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
##
## This file is part of an example program for Qt. This example
## program may be used, distributed and modified without limitation.
##
##############################################################################

import sys
from qt import *

class UicManager(QVBox):
def __init__(self):
QVBox.__init__(self)
self.output = QTextView(self)
self.quitButton = QPushButton(self.tr('Quit'), self)
self.connect(self.quitButton, SIGNAL('clicked()'), qApp,
SLOT('quit()'))
self.resize(500,500)

# QProcess related code
self.proc = QProcess(self)

self.proc.addArgument("uic")
self.proc.addArgument("form1.ui")

self.connect(self.proc, SIGNAL('readyReadStdout()'),
self.readFromStdout)
self.connect(self.proc, SIGNAL('processExited()'),
self.scrollToTop)

if not self.proc.start():
sys.stderr.write('fatal error could not start uicn')
sys.exit(1)

def readFromStdout(self):
'read in proc data which may be in chucks'
self.output.append(str(self.proc.readStdout()))

def scrollToTop(self):
self.output.setContentsPos(0,0)

if __name__ == "__main__":
a = QApplication(sys.argv)
manager = UicManager()
a.setMainWidget(manager)
manager.show()
sys.exit(a.exec_loop())

QProcess is nice but I’m not sure about using enormous amounts of data though yet.

EDIT:

As a test I set up the Python script to pass a ‘ls -R /’ basically causing it to list all files on all mounted file systems. The code to scroll back to the top caused major lock up to the program and some performance loss for the entire laptop: probably screaming at being down to about a 150MB of swap space left.

Removing that and closing programs so only konsole running it and top + amarok playing music was running. At times top reported free memory over < 1MB about 30-40% swap usage. However without the scroll to top thing gone it didn't cause any real performance for the laptop; probably because there was much less swap usage used up. As a test I ran ls -R / direct afterwards and while it did pile on the stats in top, it still kept to about 50MB free and even less swap usage on the displays.
So far I think it would probably work for whatever is needed as long as the computer continues to provide adequate memory and the kernel doesn’t have a hissy fit about the pipes and things in the background.

ZzzzZzz

Mondays are always tiring… thanks to the holidays that jobs now on Tuesdays until Janurary.. So I’m about ready to pass out.

Been playing with the prototype for configuring a port. Made some changes including actually writing out the options to a file. I also got to poke around at Pythons ways of handling file locking, nice to see that fcntl, flock, and lockf work more or less the same as in C.

At least work tomorrow work should be light and I might actually get home in time to rest.. The down side to having to reserve most of my time spent working on this to after dark, is I can only go about as long as it takes for my brain to crash.. And that is a bit constraining at times. Between a full days work and work the next morning.. Can’t wait for the weekends!

Tomorrow I need to finish work on the prototype and then start integrating it with the rest of the more complete code the day after. In between I’d like to experiment with a few things in QT, migh tbe a little easier to do the tests in C++ but that wouldn’t be totally helpful… hehe.

Spent about 2 hours tonight, mostly reading make files. I think I’ve read all of the bsd.port* makefiles in /usr/share/mk and /usr/ports/Mk. Along with most of /usr/ports/Tools/* and a ton of stuff in /usr/share/mk/. While there is a lot of leg-work there as far as ports goes it doesn’t seem to be as complicated as I would have thought.

Made some changes to the prototype for the dialog to handle our way to ‘make config’ but it’s to late to work on it further on it. I need to set it up to store what options have been checked / unchecked so they can be used to get things set up to run make.

if I didn’t have the small problem of getting up for work tomorrow I’d have that done tonight…

So far, work on this program has been fairly easy, the main problems I am anticipating is sorting out the final-form of the main GUI. I’ve been using the 2nd style that I posted awhile back, for the prototype but I can still replace it with another quite easy once the rest of the work is done.

I may have 0 formal education when it comes to Computers or Programming. But I am accustomed to doing things the way I am doing them now. Namely trying to implement things in as small and manageable sections as possible; where each section only handles as much as necessary and relies on as little as possible out-side of it’s related code. I like it when things can be tested as stand-alone as possible and then modified/rewritten as part of the larger program. You could say I’m not a fan of 10,000 line monolithic modules that do their job plus everything but recreate emacs lol.

I test the sections making sure that it does what I need it to. Then experiment with it to see how it reacts, and incorporate it into the rest of the project based on what was learned from that prototype. This is just the way I like to tackle the problem of writing a program.

I’m more used to dealing with C and a mess of .c/.h files but python is quite nice. And it has allowed me to spend most of my time concentrating on building a working program, solving the problems not tinkering around with GDB or malloc() more then thinking about how to best make stuff work.

I hate debuggers… But some times they are necessary. My favorite method of coping with some thing that doesn’t work as anticipated is go back to the code and apply brain power. Why doesn’t it work and why does it do what it does instead? Although I must admit GDB is invaluable when needed. But I’ve rarely needed to use a debugger outside of C and C++, and even then usually to track down a stray pointer or get a backtrace.

A short look

Well, almost missed my narrow window of code time… Was passed out on the couch with a full stomach before bed until nearly 0100 xD

Between My mom, my sister, the bird, and my nephew (a louder bird)… And helping with baking there is really not much I can do during the day.. Any attempt at even thinking about seriously trying to read or write goes out the window and in comes a headache. So I have to work at night, when every one else is alseep… Until I crash or the clock reaches a point where I need to go to sleep in order to be @ work on time.

I completed the mock up of a simple dialog for simulating make config. And I’ve almost finished a working prototype for the module but I don’t have time to handle writing the slots and associated code to deal with the check boxes right now. And I need to get that done and tested before I can incorporate the prototype unto the module it belongs.

I posted a screen shot of the mock up awhile back. I’ve fixed the display a bit (the leading variable name from the makefile is removed). And added an ok and cancel button with the beginnings of a more key-board friendly behavior when it comes to using the keys instead of the rat to use it hehe. I’ve also set the caption on the dialog to contain the ports name as category/program.

In doing this, I figured the most simple way was to just muck around with a string of our target (e.g. /usr/ports/net/samba3 and /usr/ports/www/links/ in my tests). Although now that I think of it, the same routine I wrote to get a list of options to create check boxes for. Could be used to look up the category and portname variables from the makefile instead because it’s not tied to looking up any specific variable. — TODO: compare both methods for speed
after the prototype is ready to be moved to alpha group.

In trying to figure out how to get the desired result from a string version of our working path, I remembered that most languages offer some way to obtain the basename of a file or directory and set to look for it in Pythons os module. But doing that would mean we’d have to cut off the trailing slash and refeed the path to the library routine then join them into a new thing. Not exactly my idea of fun when writing a quick helper subroutine. I was very happy that help(os.path.split) revealed a method that takes care of most of that legwork itself.

Python also has some thing called list compression and which allows the mapping of the contents from one list into another based on given criteria. I’ve generally avoided list compressions out of disfavor for some of the (large) examples I’ve seen before. But for this, I actually found it yielded both quick to write and easy to understand code.

p = name # '/usr/ports/category/program' for example
prog = os.path.split(p)
cat = os.path.split(prog[0])

path = ["%s/%s" % (c,p) for c,p in zip(cat, prog) if c and p]
return path.pop()

The above snippet splits name into two lists of two elements, each a string. Basically the 2nd line returns a list of [‘/usr/ports/category’, ‘program’]. So obviously line 3 likewise splits /usr/ports/category into a list of two elements, the last of which is category. I really love how os.path.split() speeds up reading this, it takes only a glance to read it without having to double check it.

The 5th line maps any elements of the two lists (cat and prog) into a single a list of strings, i.e. some thing like path => [ ‘/usr/ports/category’, ‘category/program’ ]. The test for each element being true could be ommited in this case but I wanted to show the possibility.

Since path is a list and we want to display a string (without using str() on the result!), we just pop() the last element off path, which is exactly the element we want ‘category/program’

mm, now for some sleep… It’s after 5am here and I’m exhausted.

tinkering

click to enlarge
Free Image Hosting at www.ImageShack.us

Last night I was trying to figure out a little bit about trying to display a suitable array of checkboxes for letting the user select the ports options. I checked out the QWidget class, looks like a nice time saver but a bit of over kill for what I need. I’m also sorry to see it’s deprecated in QT4, for the heck of it I started trying to write the examples in the QT4 doc’s for replacing it, in PyQT but I’ve got QT3 C++/Python bindings on my laptop and the same for QT4 on my Desktop so I didn’t have time to finish it completly. I find it rather werid using C++ doc’s for Python but I am starting to get pretty used to working with Python although I think Ruby and Perl handle regular expressions better along side strings. Not sure if QT3 has a Regex Engine le talong if PyQT has it if there is one =/. It is good to know how to use many different languages though.

For right now I’ve been tinkering with getting the checkboxes laid out and displayed, like in the screen shot of my mock up above. It is not done yet but once the mock up is finished I can set to work on doing more; most interestingly integrating it with the more robust code in the alpha directory (yes I’m to lazy to set up CVS for working from one machine).

In the end I’m likely to use QT Designer to take care of it, so it can be made to look nice. And after feeding it through pyuic use that and the mock up to create some thing to work in a more complete version. For right now though I need to get a little rest, it has been a very busy day. I would like to rest a little bit and finish the movie. Then get back to working on this stuff when I’m more relaxed but I am liable to fall asleep… I’m off until like Tuesday so I suppose it doesn’t really matter when I wake up… And a quick run of xgalaga is a good mental re focuser hehe

*Yawn*