def getClass( clazz ): """ Load/retrieve class dynamically """ parts = clazz.split('.') module = ".".join(parts[:-1]) m = __import__( module ) for comp in parts[1:]: m = getattr(m, comp) return m """Workaround for resolving modules properly""" if __name__ == "__main__": sys.path.append( getAbsDirName(__file__,1)) from logger import RALogging LOG = RALogging.getLogger("utils") def resolveJavaPath() : #@Author Grzegorz (vara) Warywoda 2010-11-13 08:16:01 CET # Fix: local variable '_javaBin' referenced before assignment when env wll not be set _javaBin = None for value in ("JAVA_HOME","JRE_HOME","JDK_HOME") : if os.getenv(value) != None: _javaBin = os.getenv(value) break #_javaBin = None if _javaBin == None: if OSUtil.isLinux() or OSUtil.isMac():
# -*- coding: utf-8 -*- import os import re from configuration.Configuration import env from utils import Utils from logger import RALogging from types import * LOG = RALogging.getLogger("parser-conf") class ConfigParserInfo: _fileName = None _currentNumber = 0 _totalLineNumbers = 0 def __init__(self,fileName): self._fileName = fileName def getFileName(self): return self._fileName def getLineNumber(self): return self._currentNumber def getTotalLineNumbers(self): return self._totalLineNumbers class ConfigParser:
# -*- coding: utf-8 -*- # # Author: Grzegorz (vara) Warywoda # Since: 2010-11-05 22:20:20 CET # import os, sys, commands, time, getopt, optparse, string, signal, subprocess from logger import RALogging from logger.RALogging import RALogger RALogging.initialize() from utils import Utils from utils.Utils import OSUtil, FSUtil, Timer from configuration.Configuration import Config,Keys,env, KeyEntry from configuration.Parser import ParserManger START_TIME_MS = Timer.time() VERSION = "1.0.0" USAGE_FP = os.path.dirname(Config.getScriptRootPath())+os.sep+"usage.txt" #RALogger.setRootDebugLevel() LOG = RALogging.getLogger("runapp") #LOG.setLevel(RALogging.DEBUG) PRINT_DEPENDENCIES_AND_EXIT = KeyEntry("PRINT_DEPENDENCIES_AND_EXIT") Keys.registerKey(PRINT_DEPENDENCIES_AND_EXIT)
# -*- coding: utf-8 -*- import os,string from logger import RALogging from Parser import ConfigParser from configuration.Configuration import Config,env import glob LOG = RALogging.getLogger("parser-bash") def _strip_spaces(alist): return map(lambda x: string.strip(x), alist) def _get_index(text,pattern,fromIndex=0): #print "i:",fromIndex, " p:'",pattern,"' t:'",text,"'" try: return text.index(pattern,fromIndex) except ValueError: pass return -1 def _get_index_for_first(text,patterns,fromIndex=0,defaultVal=-1): #print "i:",fromIndex, " p:'",pattern,"' t:'",text,"'" index = fromIndex for char in text[fromIndex:]: for pattern in patterns: if pattern == char: return index index+=1
path = os.path.realpath(path) path = os.path.abspath(path) if os.path.isfile(path): path = os.path.dirname(path) if topLevels > 0: for i in range(0,topLevels): path = os.path.dirname(path) return path os.sys.path.append( getAbsDirName(__file__,1)) from logger import RALogging RALogging.initialize() import configuration.Configuration def insertVar(key,value): """ This is a forcing for inserting variable directly to local environment variables container. Operands should be validated before calling this method. """ configuration.Configuration._Env.put([[key,value]]) if __name__ == "__main__": for i in range(0,3): print i, ":", getAbsDirName(__file__,i)