Esempio n. 1
0
 def __init__(self):
     self.commands = []
     self._os = os.uname()
     self.deps = dependencies()
     self.config = configurator()
     self.features = features()
     self.gen = yamlGenerators()
Esempio n. 2
0
def pprint(string, label, color=None, labelColor=None):
    """ a pretty print that prints with padding and right aligned text """
    config = configurator()
    ##
    ## If the user doesnt pass --np
    if config.GetGlobal('nonpretty') != True:
        padChar     = ' '
        endPadLen   = 2
        labelMsgLen = 0
        
        ## Nast way of getting the terminal column length
        sPack = struct.pack("HHHH", 0, 0, 0, 0)
        fdOut = sys.stdout.fileno()
        fcN = fcntl.ioctl(fdOut, termios.TIOCGWINSZ, sPack)
        uPack = struct.unpack("HHHH", fcN)
        
        ## this is the row length
        rowLen = uPack[1]
        
        ## re-assign the totalLen
        totalLen = rowLen
        
        if label:
            ## gets the label length and appends 2 for the brackets
            labelMsgLen = len(label.splitlines()[0]) + 2
        
        ## gets the string length
        stringLen = len(string.splitlines()[0])
        ## builds a pad string
        padding = padChar * (totalLen - (stringLen + labelMsgLen + endPadLen))
        endPad  = padChar * endPadLen

        ## only label coloring			 
        if labelColor and not color:
            sys.stdout.write("%s%s[%s%s%s]%s\n" %
            (string, padding, colorList[labelColor.upper()], label, 
            colorList['NORMAL'], endPad))	
        
        ## if we have color
        if color:
            sys.stdout.write("%s%s%s%s[%s%s%s]%s\n" %
            (colorList[color.upper()], string, colorList['NORMAL'], padding,
            colorList[labelColor.upper()], label, colorList['NORMAL'], endPad))

        
        ## no coloring
        #else:
        #    sys.stdout.write("%s%s[%s]%s\n" % (string, padding, label, endPad)) 

    ## if nonpretty is True
    else:
        str = "%s [%s]" % (string, label)
        print str
        return str
Esempio n. 3
0
def debug(string, level=DEBUG):
    ''' the debug method, a printer for debugging with verbosity control'''
    config = configurator()
    ## Get the frames so we know who's calling us from what line
    current = inspect.currentframe(0)
    # print inspect.getframeinfo(current)
    # print inspect.stack(current)
    outer   = inspect.getouterframes(current)
    
    ## get the debug level from our global class
    dLevel = int(config.getGlobal('debug'))
    ## Keep a marker so we dont print the same thing more than once
    hasPrinted = False
    
    if dLevel > NONE:
        if dLevel >= level and not hasPrinted:
            hasPrinted = True
            _dPrint(level, string, outer)

    ## we must explicitly delete the frame inspector or it will cause 
    ## unnecessary garbage
    del current    
Esempio n. 4
0
 def __init__(self):
     self.runFunction = 'run'
     self.config = configurator()
Esempio n. 5
0
 def setUp(self):
     sys.path.append('../')
     from core.configurator import configurator
     self.Config = configurator()
Esempio n. 6
0
 def test_8_ConfiguratorGlobalConfig(self):
     sys.path.append('../core/')
     from core.configurator import configurator
     Config = configurator()
     Config.putConfig('p1', True)
     assert self.Config.getConfig('p1') == True
Esempio n. 7
0
 def test_6_ConfiguratorGlobalFeature(self):
     sys.path.append('../core/')
     from core.configurator import configurator
     Config = configurator()
     Config.putFeature('c1')
     assert self.Config.getFeature('c1') == True
Esempio n. 8
0
 def test_5_ConfiguratorGlobalInstances(self):
     sys.path.append('../Core/')
     from core.configurator import configurator
     Config = configurator()
     Config.putGlobal('c1', True)
     assert self.Config.getGlobal('c1') == True
Esempio n. 9
0
 def __init__(self):
     """dostring for __init__"""
     self.splitString = '.'
     self.config = configurator()
Esempio n. 10
0
	def __init__(self):
		self.Config = configurator()
Esempio n. 11
0
 def __init__(self):
     self.config   = configurator()
     self.plugins  = plugin()
     self.yml      = nyaml()