Another commit to NPM

Well this was a fun one, for the first night in quite awhile I’ve spent some code-time on one of my own projects instead of [SAS] related business.

After someone on daemonforums pointed me at a few make targets (depends-list, showconfig). I put it on my to do list to refactor NPM to make use of such things.

As it turns out, depends-list is not documented and doesn’t seem to work on every port. The included makefile that implements showconfig however, does list a lot of make targets that I can count on (more then the ports manual page), including suitable *-depends-list targets.

NPM’s way of handling port build options in the trunk, I’ve never been very happy with… Because although it works, the whole thing hinges on a method of pulling out the OPTIONS variable from a specified ports Makefile. The code to do it, should we say gives me a queezy feeling when I think about it.

I also had planned on writing a small module to handle calculating a programs dependencies through the ports INDEX file but never finished it. I had gotten as far as processing the index and scratching my head over a couple of the rarely used segments of the file. The various m/.*-depends-.*/ targets solve that problem already, so we’re in cake land 😉

It’s much easier to just read the information through a pipe and process it into something manageable. I’m to exhausted atm to keep working on things in a sound frame of mind… Else I would probably be awake for another 3 or 4 hours, passing out around 0700~0800.

Some stuff I would like to do on the next round of commits,

process data received from the pipes while reading them, not after reading it all (not that this is likely to be a noticeable improvement in response time for big jobs)

figure out exceptions to be raised

get it finished

get it tested

get the program using it

test that

pass out again.

JavaSwing.strange()

This is very funky. I downloaded a tutorial file from sun for Java’s Swing toolkit and it compiles fine but can’t find the main thread when compiled & run as directed.

I comment out the ‘package start;’ at the top, recompile and it runs fine >_>

To be honest, I think I’m sort of happy I’ve never written a lot of Java code… Especially because most encounters whereByPeopleWhoHaveTypeNames andVarNamesThisLong which kind of pisses me off lol.

I do have Qt Jambi installed on my desktop but the problem is family really makes it easier to write code off my laptop, since I get get further away from the line of fire… Which means without a fair bit of tinkering, it’ll be easier to write the GUI in Javas Swing.

I did learn a little of AWT way back when but I doubt any of it is still good by now lol.

Oy vey

Well now I’ve bloody well seen it all.

test script locally — works perfectly fine

test script on web server — dies with syntax error.

One that everyone who checks the script seems to agree along with the interpreters syntax checking as well, that the script is perfectly valid.

Well, at least I know the bloody thing _works_ when it works lol.

The scripts a major improvement over the existing one but far from important… Just one of those leave it better for the next generation kinda rewrites (y).

Well, one nice thing I actually got to work on a small XHTML and CSS template today, in between AFK spikes 8=)

What else I can actually get done before I’m stuck heading back into work otoh, is… doubtful.

Playing with perl

Ok, so I got bored and wound up with a new toy 😛

Hmm, now to hunt down some snacks…


1: #!/usr/bin/perl
2:
3: use strict;
4: use warnings;
5:
6: use Getopt::Long;
7: use Image::Size;
8: use Pod::Usage;
9:
10: =pod
11: =head1 NAME
12:
13: image-size.pl
14:
15: =head1 SYNOPSIS
16:
17: image-size.pl [options] [file ...]
18:
19: Options:
20: -f, --ask-file include output from file(1)
21: -h, --help print usage help info
22: --man read manual page
23: -s, --silent ignore errors
24: -v, --verbose more verbose output
25: -d, --die blow up on first error
26:
27: =head1 DESCRIPTION
28:
29: A quick perl script to do what I've always wanted, tell me the height and width
30: of an image file. Without having to open a graphical program (X11) just for the
31: sake of finding out! File formats supported are based on the Image::Size module
32: which is required for this script to function.
33:
34: Special thanks to the creators of the llama book for mentioning perls
35: Image::Size module and thanks to the creators of that module!
36:
37: =head1 OPTIONS
38:
39: =over 8
40:
41: =item B<-f, --ask-file>
42:
43: Politely ask the systems file utility about the files format. This option
44: requires the file program installed and accessible through your environments
45: PATH.
46:
47: =item B<-h, --help>
48:
49: Print out a summery of command line options and exit.
50:
51: =item B<--man>
52:
53: Displays this manual page using the provided Plain Old Documentation.
54:
55: =item B<-s, --silent>
56:
57: Ignore failed files and continue, combine with -v or --verbose to include the
58: file name but still skip printing error messages.
59:
60: =item B<-v, --verbose>
61:
62: Print the file name along with it's width, height, and type (if known). Each
63: field is also separated by a new line and ordered in a more elaborate format.
64:
65: =item B<-d, --die>
66:
67: Default behavior for image-size.pl is to print a simple warning message if any
68: specified file can not be operated on.
69:
70: When the the -d or --die switches are given, the program will halt execution
71: with an appropriate exit status instead of continuing.
72:
73: This is useful for when you do not wish to continue after an error when
74: processing a list of files
75:
76: Refer to the perl documentation for details about how the exit status is
77: affected.
78:
79: =back
80:
81: =head1 EXIT STATUS
82:
83: The image-size.pl utility exits 0 on success or returns via perls die() if -d or
84: --die was passed on the command line.
85:
86: =head1 SEE ALSO
87:
88: L<perl(1)>, L<perldoc(1)>, L<file(1)>
89:
90: =head1 LICENSE
91:
92: Copyright (c) CLASS=integer>2008, TerryP <snip>
93:
94: Permission to use, copy, modify, and distribute this software for any purpose
95: with or without fee is hereby granted, provided that the above copyright notice
96: and this permission notice appear in all copies.
97:
98: THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
99: REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
100: FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
101: INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
102: OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
103: TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
104: THIS SOFTWARE.
105:
106: =cut
107:
108:
109: # message for pod2usage()
110: my $usage_msg = "$0 -- figure out the height and width of image filesn";
111:
112: # message to display on error getting the image size
113: my $warn_msg = "File does not exist or cannot be opened: ";
114:
115: my ($deadly, $help, $verbose, $man, $silent, $ask) = undef;
116:
117: {
118: Getopt::Long::Configure('bundling');
119: GetOptions(
120: 'f|ask-file' => $ask,
121: 'h|help|?' => $help,
122: 'man' => $man,
123: 's|silent' => $silent,
124: 'v|verbose' => $verbose,
125: 'd|die' => $deadly,
126: ) or $help++;
127:
128: pod2usage(-msg => $usage_msg, -output => *STDOUT,
129: -exitval => 1, -verbose => 0 ) if $help;
130: pod2usage(-verbose => 2, -exitval => 1) if $man;
131:
132: exit 1 unless @ARGV;
133:
134: # check if we are reading file names off stdin
135: if ($ARGV[0] eq '-') {
136: while (<>) {
137: chomp;
138: &print_size(imgsize($_), $_)
139: if -f $_ or $silent ? next : &handle_error and next;
140: }
141: } else {
142: foreach (@ARGV) {
143: &print_size(imgsize($_), $_)
144: if -f $_ or $silent ? next : warn $warn_msg."$_n" and next;
145: }
146: }
147: }
148:
149: sub print_size() {
150: my ($x, $y, $type, $file) = @_;
151:
152: $x = 'unkown' unless $x;
153: $y = 'unkown' unless $y;
154:
155: # keep it simple stupid
156: my $std_msg = "width-x: $xtheight-y: $ytfile type: $typen";
157:
158: # unless asked to shoot off your mouth
159: my $verb_msg = "file name: $filen" .
160: "width-x: $xnheight-y: $yn" .
161: "file type: $typenn";
162:
163: $verbose ? print $verb_msg : print $std_msg;
164:
165: print "running file(1) ...nn",`file $_`,"n" if $ask;
166: }
167:
168: sub handle_error() {
169: $deadly ? die $! : warn $warn_msg."$_n";
170: }
171:


Been in my usually hyper-jumping multi-tasking state as usual.

I’ve had enough IM windows open simultaneously of late between friends, business, and other matters to be aiming for a new personal record. It’s a good thing I didn’t expect to get much done as Virtual WO1 on day 1 or day 2 looool.

Some times my systems load is light, at the least I usually will have a web browser, instant messenger, and a command prompt open some where (local or network). Other times even on my desktops 1600×1200 resolution screen space can be hard to get hehe.

That’s just the way I am though, I’m usually avail about 14-18 hours a day or more depending on working hours lol. Most people know, don’t call me, messenger me ! One thing I do love about IMs over phone calls is you don’t have to respond instantly, and you the message buffer handles incomings between AFK spikes… It’s sort of necessary with the way life at home is lol.

A few things on my agenda are already in the works… Most of which do to with things with the new AoR in [SAS] and the SOP Rewrites. You could say taking over a larger scope of things calls with it a bit of nose poking around hehe. With the SOPs I’ve been trying to get work done & keep the RSM informed.

Another thing I would like to do is find some time to learn Perls OO features. I’m no real fan of Object Oriented programming although I believe it is just a means of doing the right things a certain way. In this case it really is just the simple fact that I don’t know much about Perls Object Oriented syntax and I’m not interested in waiting for Perl6 to learn it lol.

For me Perl is getting to be kind of like an old friend in the tool chest, like a trusty hammer or a favorite screw driver. I often find my self using Python, Perl, and Ruby for scripting tasks or random programming that I either can’t use some thing else for or just don’t have time/energy for using another language for.

And for languages and tools I often put to work, I like to know them like a well read book 😉

What can I say but I love to learn!

The return of NPMs Coding Spider

My first commit to Neo Ports Managers SVN since March… Sheesh I’ve been AWOL on this ain’t I?

Revision 61 – Directory Listing
Modified Fri Apr 4 07:22:12 2008 UTC (5 minutes, 2 seconds ago) by sas_spidey01

searchlet module now uses an internal searching code by default with the ability to use a separate external program for searching ports.

It assumes calling convention is ‘your command’ ‘what to look for’ and the following output parsing convention:

portname description

any white space will do.

ability to set external command not yet implemented [in the GUI I meant]

It’s been so long I had to change my password in order to login to SVN and the websites SSH successfully loool. Oh well, back to work I go!!

My official todo list:

Terry@dixie$ cat ~/code/Python/src/npm/trunk/src/todo.txt                  7:26

searchlet config in settings pages:
external command
fields to search for with internal command

finish the GUI for configuring port build options.

GUI for updating via portsnap/c*sup

help browser

... older notes
Terry@dixie$ 7:30

There is not a lot that actually has to be done before a beta can be released, it’s just it has to get done. Most of the rest is stuff I *want* done first…

I’m usually happier when I’m working on some thing then when I’m groaning about, and honestly I’d rather concentrate on code then my mind wandering off along past explicits.

Well, I have a todo list stored away on Neo Ports Manager and one of the things on my todo was to remove the dependency on the psearch program, namely because it would be faster to update our display as we find stuff in ports rather then parsing the output.

I think I might make another page in the settings to allow one to choose what fields to search in and possibly which to display as details. I plan on embedding the code to search ports right in NPM, but if it doesn’t clog things up I don’t see why not to allow the ability to use an external program. The best reason being if the index file ever changes or is ax’ed and I get hit by a bus, no one has to learn Python to fix NPM lol.

A couple months ago I sat down and started trying to figure out the format of the index file in ports, it was pretty easy and I wrote a small script to search it and print out all the cells of information in each entry of the index that had a matching package-version in it.

This is a quick test script I wrote tonight that searchs for a port and displays a short info on it, being a test I wrote the port to look for in the file test rather then passing sys.argv over to save time. I plan to adopt NPM to using a variation of this for searching ports now.


1: #!/usr/bin/env python
2:
3: # This is as much of the format of /usr/ports/INDEX-* file as I have
4: # been able to reverse engineer by looking at it and a few other things
5: # that didn't come with a nice fat manual page: the source is the documentation!
6: #
7: # Each program is listed on one line with each field separated with the pipe
8: # symbol (|), list values are delimited by a space.
9: #
10: # pkg-ver| -> as listed in pkg_info
11: # location in ports| -> /usr/ports/editors/vim
12: # install prefix| -> /usr/local
13: # short descr| ->
14: # path to pkg-descr| -> /usr/ports/editors/vim/pkg-decsr
15: # maintainer e-mail| -> who@foo.com
16: # listed in categories| -> list of cat, e.g. cat1 cat2
17: # dependencies to build| -> list of pkg-ver required to build this port
18: # dependencies at run time| -> list of pkg-ver required to run this program
19: # website| -> the programs website
20: # | -> unknown
21: # | -> unknown
22: # XXX: the unknowns may relate to internal port opts, e..g use zip, etc
23: ####
24:
25:
26: import re, os.path
27:
28: INDEX="/usr/ports/INDEX-6"
29:
30: # find keys 1,2,4 in index row via regex
31: def search(pattern):
32: idx = open(INDEX)
33: for line in idx:
34: keys = line.split('|')
35: k = (keys[0],os.path.split(keys[1])[1], keys[3])
36: for each in k:
37: if re.search(pattern, each):
38: print 'found'
39: mypp(keys)
40: idx.close()
41:
42: def mypp(table):
43: print "PORT INFORMATION FOR: %s" % table[0]
44: print 'location: %s' % table[1][11:]
45: print 'descr: %s' % table[3]
46: print 'category: %s' % table[6]
47: print 'website: %s' % table[9]
48:
49:
50: if __name__ == "__main__":
51: search("linux-flock")
52:
53:


Musings about the new GCC

GCC 4.3.0 exposes a kernel bug

Interesting discussion,

I know FreeBSD 7 is moving to GCC4 for the system compiler, iirc 7.0-Release comes with 4.2.x. I have GCC 4.3 installed on this laptop but my primary reason for it is that I wanted to try GCJ, the GNU Compiler for Java :-).

I can’t say the same about Linux distros but I’d expect FreeBSD to always make sure the systems compiler won’t have problems with a build world/kernel cycle.

I’ve only used GCCs 3.x.x C and C++ compilers but I’m not partial, all I expect from a compiler is sufficient standards compliance to the current standards. GCC 3.4.6 might not be perfect but hey, it beats Microsoft’s C Compiler hands down last I tried it :-).

I used to collect some types of software, text editors, terminal emulators, shells, window managers, and sometimes even office suites but I never took to collecting C Compilers. Largely because I don’t want to sit and wait to compile one more often then needed haha.

Egg on my face

Oh this is a shocker!

I noticed I had one of my quick bookmarks in konqueror that I never finished reading, some thing on command line arguments — a very poor name for a bookmark generally speaking.

So I opened it in another tab and parsed it at my usual rapid pace. Gradually I started lookinf around at other stuff on the site, intrigued by some of the other things I found, even things noted about the design of termcap/terminfo, fetchmail, gcc, etc and decisions involved with the problems the developers had to solve. About a half an hour and almost 3 chapters later and figuring it was probably some (good) book gifted to the WWW by a universities CS department I finally clicked the ‘home’ button and felt like popping myself in the head when I realized what I had been reading a mirror of:

The Art of Unix Programming

I remember I was reading it last year but I never had time to finish it. Hmm, I wonder where I left off? It is a very fine book but unfortunately not one I was able to inhale in my spare time :. I might be a strange person but when I find a good book, it usually makes a transition from eye to brain at a rate of 50-120 pages a day xD, time and energy permitting of course.

It’s a book I’d fully recommend for any one interested in problem solving or engineering’ish thinking.