コード例 #1
0
ファイル: views.py プロジェクト: notabyte/cairis
def set_dbproxy(dbUser, userName):
    b = Borg()
    dbPasswd = current_user.dbtoken

    dbUser = canonicalDbUser(dbUser)
    dbName = dbUser + '_default'
    db_proxy = MySQLDatabaseProxy(user=dbUser, passwd=dbPasswd, db=dbName)
    pSettings = db_proxy.getProjectSettings()

    id = b.init_settings()
    db_proxy.close()
    session['session_id'] = id
    b.settings[id]['dbProxy'] = db_proxy
    b.settings[id]['dbUser'] = dbUser
    b.settings[id]['userName'] = userName
    b.settings[id]['dbPasswd'] = dbPasswd
    b.settings[id]['dbHost'] = b.dbHost
    b.settings[id]['dbPort'] = b.dbPort
    b.settings[id]['dbName'] = dbName
    b.settings[id]['rPasswd'] = b.rPasswd
    b.settings[id]['fontSize'] = pSettings['Font Size']
    b.settings[id]['apFontSize'] = pSettings['AP Font Size']
    b.settings[id]['fontName'] = pSettings['Font Name']
    b.settings[id]['jsonPrettyPrint'] = False
    return b.settings[id]
コード例 #2
0
ファイル: backup_server.py プロジェクト: tjholodnik/cairis
def main():
    parser = argparse.ArgumentParser(
        description=
        'Computer Aided Integration of Requirements and Information Security - Backup server'
    )
    parser.add_argument('tarArchive',
                        help='Model archive tarball to be created ')
    args = parser.parse_args()

    cairis.core.BorgFactory.initialise()
    b = Borg()

    aNames = accounts(b.rPasswd, b.dbHost, b.dbPort)
    for email in aNames:
        userPasswd = dbtoken(b.rPasswd, b.dbHost, b.dbPort, email)
        dbUser = canonicalDbUser(email)
        dbName = dbUser + '_default'
        dbProxy = MySQLDatabaseProxy(b.dbHost, b.dbPort, dbUser, userPasswd,
                                     dbName)
        packageFile = b.tmpDir + '/' + email + '.cairis'
        try:
            exportPackage(packageFile, None, 0, dbProxy)
            logger.info('Exported ' + email + ' default database')
        except ARMException as ex:
            logger.info('Error exporting ' + email + ' default database : ' +
                        str(ex))
            exportPackage(packageFile, None, 1, dbProxy)
            logger.info('Exported ' + email +
                        ' default database by ignoring validity checks')
        dbProxy.close()

    with tarfile.open(args.tarArchive, 'w') as archive:
        for p in os.listdir(b.tmpDir):
            modelName = b.tmpDir + '/' + p
            archive.add(modelName,
                        arcname=p,
                        filter=lambda x: x
                        if x.name.endswith('.cairis') else None)
        hashFile = b.tmpDir + '/hashes.txt'
        with open(hashFile, 'w') as f:
            f.write('\n'.join(
                list(
                    map(lambda x: ','.join(x),
                        emailHashes(b.rPasswd, b.dbHost, b.dbPort)))))
        archive.add(hashFile, arcname='hashes.txt')
コード例 #3
0
def set_dbproxy():
    b = Borg()
    db_proxy = MySQLDatabaseProxy()
    pSettings = db_proxy.getProjectSettings()

    id = b.init_settings()
    db_proxy.close()
    session['session_id'] = id
    b.settings[id]['dbProxy'] = db_proxy
    b.settings[id]['dbUser'] = b.dbUser
    b.settings[id]['dbPasswd'] = b.dbPasswd
    b.settings[id]['dbHost'] = b.dbHost
    b.settings[id]['dbPort'] = b.dbPort
    b.settings[id]['dbName'] = b.dbName
    b.settings[id]['fontSize'] = pSettings['Font Size']
    b.settings[id]['apFontSize'] = pSettings['AP Font Size']
    b.settings[id]['fontName'] = pSettings['Font Name']
    b.settings[id]['jsonPrettyPrint'] = False
    return b.settings[id]
コード例 #4
0
def set_dbproxy():
  b = Borg()
  db_proxy = MySQLDatabaseProxy()
  pSettings = db_proxy.getProjectSettings()

  id = b.init_settings()
  db_proxy.close()
  session['session_id'] = id
  b.settings[id]['dbProxy'] = db_proxy
  b.settings[id]['dbUser'] = b.dbUser
  b.settings[id]['dbPasswd'] = b.dbPasswd
  b.settings[id]['dbHost'] = b.dbHost
  b.settings[id]['dbPort'] = b.dbPort
  b.settings[id]['dbName'] = b.dbName
  b.settings[id]['fontSize'] = pSettings['Font Size']
  b.settings[id]['apFontSize'] = pSettings['AP Font Size']
  b.settings[id]['fontName'] = pSettings['Font Name']
  b.settings[id]['jsonPrettyPrint'] = False
  return b.settings[id]
コード例 #5
0
ファイル: views.py プロジェクト: failys/cairis
def set_dbproxy(dbUser,userName):
  b = Borg()
  dbName = dbUser + '_default'
  dbPasswd = current_user.dbtoken

  db_proxy = MySQLDatabaseProxy(user=dbUser,passwd=dbPasswd,db=dbName)
  pSettings = db_proxy.getProjectSettings()

  id = b.init_settings()
  db_proxy.close()
  session['session_id'] = id
  b.settings[id]['dbProxy'] = db_proxy
  b.settings[id]['dbUser'] = dbUser
  b.settings[id]['userName'] = userName
  b.settings[id]['dbPasswd'] = dbPasswd
  b.settings[id]['dbHost'] = b.dbHost
  b.settings[id]['dbPort'] = b.dbPort
  b.settings[id]['dbName'] = dbName
  b.settings[id]['rPasswd'] = b.rPasswd
  b.settings[id]['fontSize'] = pSettings['Font Size']
  b.settings[id]['apFontSize'] = pSettings['AP Font Size']
  b.settings[id]['fontName'] = pSettings['Font Name']
  b.settings[id]['jsonPrettyPrint'] = False
  return b.settings[id]