Thursday, May 19, 2011

We Have Print Data

After some short meetings with our Director and other staff, there seemed to be some excitement about analyzing our printing data. They gave me a list of some additional functionality and I had fun learning how to use some new widgets with Python/Glade and how to retrieve data from sqlite. I don't get the chance to write software very much anymore, and I still find it enjoyable after all of these years.

Here is the shot of the UI, simple and easy to use. The users select the data range, the departments and then the various functions they wish to query. The information is returned in three tabs on the right side which appear as "Department", "Printers" and "Users". One of the requested features was the ability to get the data as it appears in the Tree into OpenOffice Calc. The sqlite query is looping to fill the tree, and it was very simple to just dump the data concurrently out to a perl library which allows you to generate an identical .ods file. When the Tree displays, the file is finished and ready for use. I added an area labeled 'Files' which contains the spreadsheets. When clicked, the buttons use the normal MIME popups that we use on the rest of the desktop. The perl library does not generate the thumbnail file that normally appears in an .ods file, so the preview window comes up blank.

In the shot below, I selected OpenOffice - Calc opens the .ods file and will allow them to tinker with the numbers or copy and paste into other applications as needed. It took a bit of Googling to find the right technique to get the numbers over as integers and not as strings. But it's all working.

The primary UI gives them SQL SUMs of the various data, and I knew that people would be shocked at the number. So if you double-click on any of the Tree rows, it opens a child window which performs the same SQL statement except showing the detail records. It's very interesting to be able to see all print jobs by department, printer and user in chronological order. You can really get a better understand of how people are using/abusing the software.

I have a bit of work to do yet to merge in the log files coming over from the MS Windows spoolers which are in a different format. At that point management can review the data and consider ways to reduce costs with the use of other technologies such as portrait monitors, policies, training and tablets.


natxete said...

and the name of this Perl library is ... ?

:-) just curious, nice combination of Python for the gui stuff and Perl for the data munging.

Dave Richards said...


Here is a snip of the perl code, this library is awesome and so easy:

use OpenOffice::OODoc;
# define output file
my $doc = odfDocument(file=>'/tmp/drichard_dept.ods',create=>'spreadsheet',part=>'content' );
# define the physical size of the cells
my $sheet = $doc->expandTable(0, 15, 3);
# Write out headers
$doc->cellValue($sheet,0,1,'Number Pages');
# write out text
# write out integers, a bit more tricky
my $cell = $doc->getCell($sheet,1, 1);
$doc->cellValueType($cell, 'float');
my $cell = $doc->getCell($sheet,1, 2);
$doc->cellValueType($cell, 'float');

sdf said...


but you probably already fixed that...