예제 #1
0
def setPort(port):
    logger.info('Applying web port...')
    b = Borg()
    if port == 0:
        if not hasattr(b, 'webPort'):
            b.webPort = 7071
    else:
        b.webPort = port
예제 #2
0
def setPort(port):
    logger.info('Applying web port...')
    b = Borg()
    if port == 0:
        if not hasattr(b, 'webPort'):
            b.webPort = 7071
    else:
        b.webPort = port
예제 #3
0
def dInitialise(configFile):
  b = Borg()
  b.runmode = 'web'
  b.settings = dict()
  b.logger = logging.getLogger('cairisd')

  homeDir = os.getenv("HOME")
  if homeDir is not None:
    cairisRoot = os.path.join(homeDir, "CAIRIS/cairis")
  else:
    raise RuntimeError('The HOME environment variable is not defined.')

  cfgFileName = ''
  try:
    cfgFileName = os.environ['CAIRIS_CFG']
  except KeyError:
    cfgFileName = cairisRoot + '/cairis/config/cairis.cnf'

  if configFile is not '':
    if os.path.exists(configFile):
      cfgFileName = configFile
    else:
      raise IOError('''Unable to locate configuration file at the following location:
  '''+configFile)

  try:
    cfgFile = open(cfgFileName)
    for cfgLine in cfgFile.readlines():
      cfgTuple = cfgLine.split('=')
      cfgKey = strip(cfgTuple[0])
      cfgVal = strip(cfgTuple[1])

      if cfgKey == 'tmp_dir':
        b.tmpDir = cfgVal
      elif cfgKey == 'upload_dir':
        b.uploadDir = cfgVal
      elif cfgKey == 'root':
      	b.cairisRoot = cfgVal
      elif cfgKey == 'web_port':
        try:
          b.webPort = int(cfgVal)
        except TypeError, ex:
          b.logger.error(str(ex.message))
          b.webPort = 0
      elif cfgKey == 'log_level':
        log_level = cfgVal.lower()
        if log_level == 'debug':
            b.logLevel = logging.DEBUG
        elif log_level == 'none':
            b.logLevel = logging.FATAL
        elif log_level == 'info':
            b.logLevel = logging.INFO
        elif log_level == 'error':
            b.logLevel = logging.ERROR
        else:
            b.logLevel = logging.WARNING
      elif cfgKey == 'web_static_dir':
        b.staticDir = cfgVal
예제 #4
0
def dInitialise():
  cfgDict = parseConfigFile()
  initialiseCairisDbSettings(cfgDict)

  b = Borg()
  b.runmode = 'web'
  b.logger = logging.getLogger('cairisd')
  b.imageDir = os.path.join(b.cairisRoot,'images')
  b.configDir = os.path.join(b.cairisRoot,'config')

  b.uploadDir = cfgDict['upload_dir']
  try:
    b.webPort = int(cfgDict['web_port'])
  except TypeError, ex:
    b.logger.error(str(ex.message))
예제 #5
0
def dInitialise():
    cfgDict = parseConfigFile()
    initialiseCairisDbSettings(cfgDict)

    b = Borg()
    b.runmode = 'web'
    b.logger = logging.getLogger('cairisd')
    b.configDir = os.path.join(b.cairisRoot, 'config')
    b.uploadDir = cfgDict['upload_dir']
    b.secretKey = cfgDict['secret_key']
    b.passwordHash = cfgDict['password_hash']
    b.passwordSalt = cfgDict['password_salt']
    b.auth_dbHost = cfgDict['auth_dbhost']
    b.auth_dbUser = cfgDict['auth_dbuser']
    b.auth_dbPasswd = cfgDict['auth_dbpasswd']
    b.auth_dbName = cfgDict['auth_dbname']

    try:
        b.webPort = int(cfgDict['web_port'])
    except TypeError, ex:
        b.logger.error(str(ex.message))
예제 #6
0
def dInitialise():
  cfgDict = parseConfigFile()
  initialiseCairisDbSettings(cfgDict)

  b = Borg()
  b.runmode = 'web'
  logging.basicConfig()
  b.logger = logging.getLogger('cairisd')
  b.configDir = os.path.join(b.cairisRoot,'config')
  b.uploadDir = cfgDict['upload_dir']
  b.secretKey = cfgDict['secret_key']
  b.passwordHash = cfgDict['password_hash']
  b.passwordSalt = cfgDict['password_salt']
  b.auth_dbHost = cfgDict['auth_dbhost']
  b.auth_dbUser = cfgDict['auth_dbuser']
  b.auth_dbPasswd = cfgDict['auth_dbpasswd']
  b.auth_dbName = cfgDict['auth_dbname']


  try:
    b.webPort = int(cfgDict['web_port'])
  except TypeError, ex:
    b.logger.error(str(ex.message))