Ensure program is free software

Everyone loves, wants and needs free software.
Ensure this program is free software.

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Remove mistakenly commited temporary Python compiled file

.pyc files are neither required to exist nor compatible between
different Python interpreters. They are nothing more that just stripped
down .py version and always can be automatically transparently created.

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
[PEP8] Replace all tabs with spaces

PEP8 is de-facto code style guidelines for Python programs.

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
[PEP8] Trivial stylistic corrections

PEP8 is de-facto code style guidelines for Python programs.

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Remove unused library import

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Remove unused variable assignment

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Comparison to True should be "if cond is True:" or "if cond:"

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Only single rrd function is used and should be imported

One should never do "*" importing, because:
* noone can determine what functions are missed from imports and that
  hardenes debugging much
* it wastes Python namespace with unused, but imported objects

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Use specialized functions for filepaths constructing

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
import should be called only once

Each get_trac() call leads to unnecessary resource-heavy import call.

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Do not do double __getitem__ for rrd dictionary

We already have value while iterating through dictionary.

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Remove unnecessary variable assignment

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Global variables are more visible in upper case

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Replace string concatenation with string formatting for performance

Each string concatenation creates several immutable string objects in
memory and formatting of several values creates just final formatted
string once.

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
os.path.join will add all necessary filepath slashes

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Remove shell call complexity hell

* os.popen is deprecated since 2.6 and subprocess must be used
* each grep/awk call is very resource-heavy and easily can be done
  inside Python itself

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Import only single used function from library

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Move constant dictionary outside oftenly called function

Each function call leads to creation of new dictionary (however removed
after garbage collection).

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Compute full database filepaths only once, instead of each function call

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
Remove check_db(), as it is an alias to os.path.isfile

Signed-off-by: Sergey Matveev <stargrave@stargrave.org>