diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7b619ab --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +# FreeBSD Ports Makefile For 'tgetwx' +# $Id: Makefile,v 1.1 2014/02/19 18:30:00 tundra Exp $ + +all: # Just need to create the compiled image + @python -OOOO -c"import py_compile;py_compile.compile('tgetwx.py')" + +install: + ${BSD_INSTALL_SCRIPT} tgetwx.py ${PREFIX}/bin + ${BSD_INSTALL_MAN} tgetwx.1.gz ${PREFIX}/man/man1 diff --git a/TODO b/TODO new file mode 100644 index 0000000..dc69e14 --- /dev/null +++ b/TODO @@ -0,0 +1,2 @@ +# List of open To Do items for tgetwx + diff --git a/WHATSNEW.txt b/WHATSNEW.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/WHATSNEW.txt diff --git a/makefile b/makefile new file mode 100644 index 0000000..a82fded --- /dev/null +++ b/makefile @@ -0,0 +1,164 @@ +# Build a release of 'tgetwx' using 'make' +# Requires a modern 'make' like GNU. +# +# Copyright (c) 2014 TundraWare Inc., Des Plaines, IL 60018 USA +# All Rights Reserved. For Terms Of Use See: tgetwx-license.txt +# +# For Program Updates See: http://www.tundraware.com/Software/tgetwx +# +# $Id: makefile,v 1.1 2014/02/19 18:30:00 tundra Exp $ + + +# Uncomment One Of The Following For Early Releases + +#EARLY = Alpha +#EARLY = Beta +#EARLY = RC1 + +##### +# Definitions Relevant To This Program +##### + +PROGNAME = tgetwx +PROGMAIN = tgetwx.py + +PROGFILES = ${PROGMAIN} # setup.py # Uncomment this if desired for python modules +PROGDOCS = ${PROGMAIN}.ps + +DOCS = tgetwx-license.txt \ + ${PROGNAME}.1.gz \ + ${PROGNAME}.html \ + ${PROGNAME}.pdf \ + ${PROGNAME}.ps \ + ${PROGNAME}.rst \ + ${PROGNAME}.txt \ + CHANGELOG.txt \ + Makefile \ + + +##### +# Nothing Should Need To Change Below This Line +##### + + +DIR = ${PROGNAME}-${VERSION} +HEADER1 = "WHATSNEW For '${PROGNAME}' ${VERSION} (`date`)" +HEADER2 = "----------------------------------------------------------------------" +RELEASES = "Releases" +TARBALL = ${DIR}.tar.gz +TMPFILE = tmpfile +VERSION = $(shell cvs log ${PROGMAIN} | grep ^head\: | cut -f2 -d " ")${EARLY} + + +##### +# Pattern Rules +##### + +### +# Document Production +### + +# Some Docutils installations keep the ".py" suffix for the various +# frontend programs, and some do not. It's even possible there are +# links from one to the other. Since the project can be checked out +# on any platform, we have to check for this every time we run the +# 'make'. This is irritating. + +2HTML = $(shell which rst2html.py rst2html 2>/dev/null | head -n 1) +2LATEX = $(shell which rst2latex.py rst2latex 2>/dev/null | head -n 1) --stylesheet=parskip --latex-preamble="\usepackage{fullpage}" +2ODT = $(shell which rst2odt.py rst2odt 2>/dev/null | head -n 1) +2MAN = $(shell which rst2man.py rst2man 2>/dev/null | head -n 1) + +# TeX/LaTeX Processing + +DVIPS = dvips +PDFLATEX = pdflatex +LATEX = latex + +%.dvi : %.latex + ${LATEX} $*.latex + +%.html : %.rst + ${2HTML} <$*.rst >$*.html + +%.latex : %.rst + ${2LATEX} $*.rst >$*.latex + +%.1 : %.rst + ${2MAN} <$*.rst >$*.1 + +%.1.gz: %.1 + @gzip -c <$*.1 >$*.1.gz + +%.odt : %.rst + ${2ODT} <$*.rst >$*.odt + +%.pdf : %.latex + ${PDFLATEX} $*.latex + ${PDFLATEX} $*.latex + ${PDFLATEX} $*.latex + +%.ps : %.dvi + ${DVIPS} $*.dvi + +%.txt: %.1 + @groff -man -Tascii $< | col -xb >$@ + +### +# Pretty Print Programs & Scripts +### + +%.pl.ps: %.pl + @enscript -Eperl --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $< + +%.py.ps: %.py + @enscript -Epython --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $< + +%.sh.ps: %.sh + @enscript -Esh --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $< + + +##### +# Actual Build Rules +##### + +FORCE: + +CHANGELOG.txt: FORCE + @cvs log ${PROGMAIN} >CHANGELOG.txt + +WHATSNEW.txt: FORCE + @printf "%s\n%s\n\n" ${HEADER1} ${HEADER2} | cat - $@ >${TMPFILE} + @mv ${TMPFILE} $@ + @jmacs $@ + @cvs commit -m${HEADER1} $@ + +docs: ${DOCS} ${PROGDOCS} + @chmod 644 ${DOCS} ${PROGDOCS} + @chmod 644 *.gz *.txt + +release: docs WHATSNEW.txt ${PROGFILES} + @mkdir ${DIR} + -@mkdir ${RELEASES} 2>&1 >/dev/null + @cp -pv WHATSNEW.txt ${PROGFILES} ${DOCS} ${PROGDOCS} ${DIR} + @tar -czvf ${TARBALL} --exclude CVS ${DIR} + @rm -rf ${DIR} + @mv ${DIR}.tar.gz ${RELEASES} + +##### +# Housekeeping +##### + +clean: + @rm -rf *~ *.1 *.1.gz *.aux *.core *.dvi *.latex *.log *.out tmpfile *.toc + +version: + @echo ${VERSION} + +scrub: clean + @rm -rf ${DIR} ${PROGFILES} ${DOCS} ${PROGDOCS} ${TARBALL} ${TMPFILE} + +init: scrub + cvs update + + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f26ea72 --- /dev/null +++ b/setup.py @@ -0,0 +1,5 @@ +# Install tgetwx as a Python Module +# $Id: setup.py,v 1.1 2014/02/19 18:30:00 tundra Exp $ + +from distutils.core import setup +setup(name="tgetwx", py_modules=["tgetwx"]) diff --git a/tgetwx-license.txt b/tgetwx-license.txt new file mode 100644 index 0000000..5fdb9c9 --- /dev/null +++ b/tgetwx-license.txt @@ -0,0 +1,99 @@ +$Id: tgetwx-license.txt,v 1.1 2014/02/19 18:30:00 tundra Exp $ + +In order to use, study, modify, or copy 'tgetwx', you must read +and agree to all the licensing terms below. If you do not agree with +or do not understand *ANYTHING* you see in this document, you are NOT +granted a license to use, study, modify, or copy 'tgetwx'. By +using, studying, modifying, or copying 'tgetwx', you are agreeing +to all the terms of the 'tgetwx' LICENSE below in their entirety. + + + 'tgetwx' LICENSE AGREEMENT + + +1) DEFINITIONS + +Throughout this Agreement, the term 'tgetwx' is used to mean: + +Anything included in the 'tgetwx' software distribution package +from TundraWare Inc. This includes scripts, programs, documentation, +license text and all other files provided in that original software +distribution package. + +Throughout this Agreement the term "User" is used to mean any person +who is enagaged in any of the following activities: + + a) Uses any files found in the 'tgetwx' software distribution + in any way. + + b) Reads the 'tgetwx' documentation. + + c) Reads or studies the 'tgetwx' program source code or + supporting files. + + d) Makes use of any part of the 'tgetwx' software distribution + for any purpose. + + e) Duplicates and/or distributes the 'tgetwx' software distribution. + + +2) OWNERSHIP + +'tgetwx' Is Copyright (c) 2014 TundraWare Inc., Des Plaines, IL 60018 USA +All Rights Reserved. + + +3) TERMS + +Permission is hereby granted to the User for the duplication and use +of 'tgetwx' so long as ALL the following conditions are met: + + a) There is no license fee for any use of 'tgetwx' + whether personal, commercial, non-profit, or government *so + long as you abide by the terms of this license agreement*. + Voluntary donations are always welcome. Information on how to + contribute can be obtained by contacting: + + tgetwx@tundraware.com + + b) The User of 'tgetwx' understands and agrees that this is + EXPERIMENTAL SOFTWARE which is provided "AS-IS" with no + warranties expressed or implied by TundraWare Inc. + + c) The User acknowledges 'tgetwx' has NOT been tested for: + + i) Correct operation + + ii) Freedom from unintended consequences + + iii) Any operation or condition which might cause damage, + compromise, or disruption to the User's or other: + hardware, software, networks, or data, or which might + cause any breach of system security of such systems, + software, and networks. + + d) By using 'tgetwx' in any way, the User does so at their + own risk and agrees to hold TundraWare Inc. harmless for any + damage, direct or indirect, that this software may or does + cause to the User's computational environment, including, but + not limited to, the User's or others' hardware, software, + network, or data. THE USER FURTHER AGREES TO HOLD TundraWare Inc. + INC. HARMLESS FOR ANY ECONOMIC DAMAGE OR ANY OTHER ADVERSE + CONSEQUENCE, DIRECT OR INDIRECT, CAUSED BY THE USE OF + 'tgetwx'. + + e) If duplicated and/or distributed, no fee beyond reasonable + duplication charges may be charged for 'tgetwx'. No + commercial use of 'tgetwx' which involves any + remuneration beyond these duplication charges is permitted. + + f) Any distributed copies of 'tgetwx' must include all the + originally provided software, documentation, and licensing + information in their original distribution format and + packaging without any modifications. + +By using any part or all of 'tgetwx', you are agreeing to be +bound by this license. + +IF YOU DO NOT UNDERSTAND, OR CANNOT ABIDE BY ANY OF THESE CONDITIONS, +DO NOT USE 'tgetwx'. diff --git a/tgetwx.py b/tgetwx.py new file mode 100755 index 0000000..2224eb2 --- /dev/null +++ b/tgetwx.py @@ -0,0 +1,293 @@ +#!/usr/bin/env python +# tgetwx.py - Get And Report Weather Conditions +# Copyright (c) 2014 TundraWare Inc., Des Plaines, IL 60018 USA +# All Rights Reserved. For Terms Of Use See: tgetwx-license.txt +# For Program Updates See: http://www.tundraware.com/Software/tgetwx +# $Id: tgetwx.py,v 1.1 2014/02/19 18:30:00 tundra Exp $ + +# Embed the source control ID string for use by program + +CVSID='$Id: tgetwx.py,v 1.1 2014/02/19 18:30:00 tundra Exp $' + +##### +# Program Information +##### + +PROGNAME = "tgetwx.py" +PROGENV = "tgetwx".upper() +VERSION = CVSID.split()[2] +PROGVER = PROGNAME + " " + VERSION + " - Get And Report Weather Conditions" + + +##### +# Copyright Information +##### + +COPYRIGHT = "Copyright (c) 2014 TundraWare Inc., Des Plaines, IL 60018 USA" + +##### +# List Of All Legal Options - Update This When You Add More!!!! +##### + +OPTIONSLIST = '-f:hv' + + +#----------------------------------------------------------# +# Variables User Might Change # +#----------------------------------------------------------# + + + +#------------------- Nothing Below Here Should Need Changing ------------------# + + +#----------------------------------------------------------# +# Imports # +#----------------------------------------------------------# + +import getopt +import os +import sys +# import tconfpy # Uncomment this and code below to parse config files + + +#----------------------------------------------------------# +# Aliases & Redefinitions # +#----------------------------------------------------------# + + + +#----------------------------------------------------------# +# Constants & Literals # +#----------------------------------------------------------# + + + +##### +# Constants +##### + + + +##### +# Literals +##### + + + +#----------------------------------------------------------# +# Prompts, & Application Strings # +#----------------------------------------------------------# + + +##### +# Debug Messages +##### + +##### +# Debug Messages +##### + +DEBUGFLAG = "-d" +dDEBUG = "DEBUG" +dPROGENV = "$" + PROGENV + +##### +# Error Messages +##### + +eBADARG = "Invalid command line: %s!" +eERROR = "ERROR" + + +##### +# Informational Messages +##### + +iINFO = "INFO" + + +##### +# Usage Prompts +##### + +# Make the options list more human readable + +optionslist = OPTIONSLIST.replace(':', ' arg -').strip() +if optionslist[-1] == '-': + optionslist = optionslist[:-1].strip() + +uTable = [PROGVER, + "usage: " + PROGNAME + " [%s]" % optionslist, + " where,", + " -f file configuration file to use", + " -h print this help information", + " -v print detailed version information", + ] + + +#----------------------------------------------------------# +# Global Variables & Data Structures # +#----------------------------------------------------------# + +CFGFILE = os.path.join(os.getenv("HOME"), "." + "tgetwx") # conf file + + +#--------------------------- Code Begins Here ---------------------------------# + + +#----------------------------------------------------------# +# Object Base Class Definitions # +#----------------------------------------------------------# + + + +#----------------------------------------------------------# +# Supporting Function Definitions # +#----------------------------------------------------------# + + +def ColumnPad(list, padchar=" ", padwidth=20): + + retval = "" + for l in list: + l = str(l) + retval += l + ((padwidth - len(l)) * padchar) + + return retval.strip() + +# End of 'ColumnPad()' + + +##### +# Print A Debug Message +##### + +def DebugMsg(msg): + PrintStderr(PROGNAME + " " + dDEBUG + ": " + msg) + +# End of 'DebugMsg()' + + +##### +# Dump The State Of The Program +##### + +def DumpState(): + + # Dump the command line + DebugMsg(ColumnPad(["Command Line", sys.argv])) + + # Names of all the state variables we want dumped + state = [ + ] + + for k in state: + DebugMsg(ColumnPad([k, eval(k)])) + +# End of 'DumpState()' + + +##### +# Print An Error Message +##### + +def ErrorMsg(emsg): + PrintStderr(PROGNAME + " " + eERROR + ": " + emsg) + +# End of 'ErrorMsg()' + + +##### +# Print An Info Message +##### + +def InfoMsg(imsg): + PrintStderr(PROGNAME + " " + iINFO + ": " + imsg) + +# End of 'InfoMsg()' + + +##### +# Print To stderr +##### + +def PrintStderr(msg, trailing="\n"): + sys.stderr.write(msg + trailing) + +# End of 'PrintStderr()' + + +##### +# Print To stdout +##### + +def PrintStdout(msg, trailing="\n"): + sys.stdout.write(msg + trailing) + +# End of 'PrintStdout' + + +##### +# Print Usage Information +##### + +def Usage(): + for line in uTable: + PrintStdout(line) + +# End of 'Usage()' + + +#----------------------------------------------------------# +# Program Entry Point # +#----------------------------------------------------------# + +# Command line processing - Process any options set in the +# environment first, and then those given on the command line + +OPTIONS = sys.argv[1:] +envopt = os.getenv(PROGENV) +if envopt: + OPTIONS = envopt.split() + OPTIONS + +try: + opts, args = getopt.getopt(OPTIONS, OPTIONSLIST) + +except getopt.GetoptError, (errmsg, badarg): + + ErrorMsg(eBADARG % errmsg) + sys.exit(1) + +for opt, val in opts: + + if opt == "-f": + CFGFILE=val + + if opt == "-h": + Usage() + sys.exit(0) + + if opt == "-v": + PrintStdout(CVSID) + sys.exit(0) + +# Processing of the configuration file below requires installation of +# the freely available TundraWare Inc. 'tconfpy' parser and then +# uncommenting the code below. The parser can be found at: +# +# http://www.tundraware.com/Software/tconfpy +# +# Process the configuration file +# +#retval = tconfpy.ParseConfig(CFGFILE, CallingProgram="%s %s " % (PROGNAME, VERSION)) +# +# Print any errors or warning generated by the parse +# +# for x in (retval.ErrMsgs, retval.WarnMsgs): +# for y in x: +# print y +# +# If there were any errors, we're done +#if retval.ErrMsgs: +# sys.exit(0) diff --git a/tgetwx.rst b/tgetwx.rst new file mode 100644 index 0000000..97b3b68 --- /dev/null +++ b/tgetwx.rst @@ -0,0 +1,70 @@ +NAME +---- + +**tgetwx** - Get And Report Weather Conditions + + +SYNOPSIS +-------- + +tgetwx.py [-hv] + + +DESCRIPTION +----------- + +Long description + + +OPTIONS +------- + + -h Print help information + -v Print detailed program version information and exit + + +OTHER +----- + +You must have a reasonably current version of ``python`` installed. + + +BUGS AND MISFEATURES +-------------------- + +None known as of this release. + + +COPYRIGHT AND LICENSING +----------------------- + +**tgetwx** is Copyright (c) 2014 TundraWare Inc., Des Plaines, IL 60018 USA + +For terms of use, see the ``tgetwx-license.txt`` file in the +program distribution. + +If you install **tgetwx** on a FreeBSD system using the 'ports' +mechanism, you will also find this file in:: + + /usr/local/share/doc/tgetwx + +AUTHOR +------ + +:: + + Tim Daneliuk + tgetwx@tundraware.com + + +DOCUMENT REVISION INFORMATION +----------------------------- + +:: + + $Id: tgetwx.rst,v 1.1 2014/02/19 18:30:00 tundra Exp $ + +You can find the latest version of this program at: + + http://www.tundraware.com/Software/tgetwx +