Beispiel #1
0
def getLogger( name ):
    log = kbclog.getLogger( name )
    
    log.setLevel( kbclog.INFO )
    
    global errorSet
    
    if not errorSet:
        kbclog.logErrorsToStderrOnly()
        errorSet = True
    
    return log
Beispiel #2
0
def getLogger(name):
    log = kbclog.getLogger(name)

    log.setLevel(kbclog.INFO)

    global errorSet

    if not errorSet:
        kbclog.logErrorsToStderrOnly()
        errorSet = True

    return log
Beispiel #3
0
#!/usr/local/bin/python
import KBC.fotech
import os, popen2, fcntl, select
from Util import kbclog

log = kbclog.getLogger(__name__)


def makeNonBlocking(fd):
    'helper for getCommandOutput'
    fl = fcntl.fcntl(fd, fcntl.F_GETFL)
    fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NDELAY)


def getCommandOutput(command=None,
                     inChild=None,
                     returnError=False,
                     returnCode=False):
    """
    Runs the given command, returning the standard output.

    If inChild is specified, no command is executed, but the already existing child process is read.
    If returnError is True, then return a tuple of standard output and standard error.
    If returnError and returnCode are both True, then return a tuple of standard output, standard error, and return code.

    see http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52296 for how to run a Unix cmd and control stderr/stdout.
    This is modified from that source to allow caller to supply the child, and remove closed file descriptors from select()
    Consider also http://www.pixelbeat.org/libs/subProcess.py
    """
    child = inChild or popen2.Popen3(
        command, 1)  # capture stdout and stderr from command
Beispiel #4
0
#!/usr/local/bin/python
# $Header: /home/inqwell/cvsroot/dev/scripts/python/FotechUtils/modules.py,v 1.1 2009/05/22 22:16:44 sanderst Exp $

import re, os.path, os, sys
from Util import kbclog

log = kbclog.getLogger(__name__)


class ArbitraryModule:
    """
    After creation an ArbitraryModule instance holds the name, the fullname (i.e.
    fully qualified name) and the filename of a Python module. For example the
    module file "/python/libs/KBC/fotech.py" would, assuming the Python Path was
    "/python/libs/" have the following information:

        name     := fotech
        fullname := KBC.fotech
        filename := /python/libs/KBC/fotech.py

    The load method will attempt to import the module in to the current
    interpreter state. This should only be called once. If the load is successful
    the ArbitraryModule instance module will also hold an reference to the actual
    module instance.

    The has and get methods are used to query whether the module provides a
    particular function and to retrieve a reference to the function callable.

    NOTE - Normally this class is not seen by code outside of this module. All
           functionality should be accessed via the ArbitraryModuleManager.
    """
Beispiel #5
0
# $Header: /home/inqwell/cvsroot/dev/scripts/python/FotechUtils/dbConfig.py,v 1.1 2009/05/22 22:16:27 sanderst Exp $

import os
import os.path
import socket
from StringIO import StringIO
        
from xml.dom.minidom import parseString

import KBC.fotech
from Util.getpw import GetPW
from Util import kbclog
from FotechUtils.dbError import dbError
from FotechUtils import execcontext

log = kbclog.getLogger("dbConfig")

#
# TODO - this is duplicated from db.py. Duplication is necessary as we cannot import db.py when
# running on windows. When the connection info and connection code is split in db.py then
# this duplication should be removed.
#

class configurationProvider:
    '''A database connection configuration provider. This class is capable of scanning a configuration
    file for connection information and providing methods for getting the appropriate connection
    info for a given server, user, site etc.

    This differs from db.py in that it uses databases.xml for specification of database connection info

    Note that the cfgFile passwed to the constructor can be either a file name or a file/file-like object.'''