You are browsing the archive for 2011 June.

Python – again

7:46 PM in Programming by Vic Russell

My tasks of late have reacquainted me with the Python programming language.  I used it years ago at American Greetings Interactive, and for about two weeks at Humana in Louisville, KY, but little more.  The infrastructure where I am currently employed uses Cold Fusion, a tag-based language that is efficient when working with web pages, but I could see little value using it as a sysadmin tool – quick, concise, terse code in the minimum of time is what I needed – Python is the perfect choice.

My passion for the language was reignited after creating script after script in little time.  Each script became more ‘pythonic’ and better utilized the compact nature of the language.  I again appreciated the indentation over brackets that define a code block – I had to write readable code!

Email and logging were important aspects of the scripts I was writing.  I thus utilized the ‘logging‘ class library for log file creation – easy to set up once find the right example.  For email, I used smtplib.

Aside: I am not a fan of Pythons documentation – I prefer PHP‘s explain->example style.  But, a little digging and venturing to popular Python sites (‘dive into python‘, ‘stack overflow‘, python.org) will eventually produce the result you need.

Logging in Python

The logging class is intuitive and has relatively low code overhead.  There are more complex ways of configuring the logging class, but for my needs, a simple inline syntax was required.  These are sys admin scripts and not part of an application where the time and effort to set up a comprehensive configuration file would be justified.

import logging
# Set up logger
logFile = '/path/to/logfile/myLogFileName.log'
logging.basicConfig(filename=logFile,format='%(asctime)s %(message)s',level=logging.DEBUG)

That is all that is required to set up a logger.  The logfile name can be anything and located anywhere you have read/write privileges.

To use the logger you created, use this command:

logging.info('An informative log message that applies to info status')

That will place an Info entry into the log file defined above.

logging.error('An error message for your app')
logging.debug('Debug info goes here.')

Now there is no excuse not to use log files in your Python applications.  Simple.  Concise.  Intuitive.

Electrical Contractors – What Software do you use for estimating?

3:04 PM in Programming by Vic Russell

In the past, I was involved in the construction industry.  One of the most time consuming and challenging parts of the job was estimating.  Back in my time, the tools available for the smaller contractor were limited – basically Lotus 123 and later, Excel, spreadsheets.  Pen, paper, and telephone ruled the estimating task for most small businesses.

Spreadsheets are great for tabulating data, but they are not so good for data lookups.  You can put a small ‘database’ together in a spreadsheet and query that, but you must maintain the pricing manually, and save each job sheet separately.  If something is missing, you have to manually look up the price and part number and add it to the data section of the spreadsheet.  Not efficient, and prone to error.

So today, with personal computers in almost every home and on every contractors desk, what do the smaller contractors use for estimating?

I am contemplating creating a service for contractors that provide industry-standard pricing and catalogs with an easy to use web interface.  Everything the contractor needs for estimating will be in the cloud, accessible from anywhere with any web-enabled device (smart phone, tablet computer, laptop, etc).

Anyone have an opinion, or a service that already exists that offers the same functionality, about providing this service for the smaller contractors?

Thanks,

Vic.