<commit_before># Copyright (c) 2006 rPath, Inc
# All rights reserved

from raa.db.schedule import ScheduleImmed
from raa.modules.raawebplugin import rAAWebPlugin
from raa.modules.raawebplugin import immedTask
import turbogears
import cherrypy

from conary import dbstore
from raa.db.database import DatabaseTable, writeOp, readOp
from raa.localhostonly import localhostOnly

class KeyChangeTable(DatabaseTable):
    name = 'plugin_rpath_rEAEntitlementTable'
    createSQL = """CREATE TABLE %s
                   (ent_key VARCHAR(255))""" % (name)
    fields = ['ent_key']
    tableVersion = 1

    @writeOp
    def setkey(self, cu, key):
        self.db.transaction()
        cu.execute("DELETE FROM %s" % self.name)
        cu.execute("INSERT INTO %s (ent_key) VALUES (?)" % self.name, key)
        return True

    @readOp
    def getkey(self, cu):
        cu.execute("""SELECT ent_key FROM %s""" % (self.name))
        key = cu.fetchone()
        if not key:
            return ''
        else:
            return key[0]

class rEAEntitlement(rAAWebPlugin):
    '''
        This plugin configures an rEA entitlement.
    '''

    displayName = _("Manage Administrative Entitlement")

    tableClass = KeyChangeTable
    cnrPath = "/srv/conary/repository.cnr"

    def _getReposCfg(self):
        # Get repository hostnames and fqdn
        from conary.repository.netrepos.netserver import ServerConfig
        import os
        cfg = ServerConfig()
        cfg.read(self.cnrPath)
        serverNames = cfg.serverName
        hostName = os.uname()[1]
        return serverNames, hostName

    @turbogears.expose(html="rPath.reaentitlement.reaentitlement")
    @turbogears.identity.require( turbogears.identity.not_anonymous() )
    def index(self):
        serverNames, hostName = self._getReposCfg()
        return dict(key=self.table.getkey(),<commit_msg>Branch merge<commit_after># Copyright (c) 2006 rPath, Inc
# All rights reserved

from raa.db.schedule import ScheduleImmed
from raa.modules.raawebplugin import rAAWebPlugin
from raa.modules.raawebplugin import immedTask
import turbogears
import cherrypy

from conary import dbstore
from raa.db.database import DatabaseTable, writeOp, readOp
from raa.localhostonly import localhostOnly

class KeyChangeTable(DatabaseTable):
    name = 'plugin_rpath_rEAEntitlementTable'
    createSQL = """CREATE TABLE %s
                   (ent_key VARCHAR(255))""" % (name)
    fields = ['ent_key']
    tableVersion = 1

    @writeOp
    def setkey(self, cu, key):
        self.db.transaction()
        cu.execute("DELETE FROM %s" % self.name)
        cu.execute("INSERT INTO %s (ent_key) VALUES (?)" % self.name, key)
        return True

    @readOp
    def getkey(self, cu):
        cu.execute("""SELECT ent_key FROM %s""" % (self.name))
        key = cu.fetchone()
        if not key:
            return ''
        else:
            return key[0]

class rEAEntitlement(rAAWebPlugin):
    '''
        This plugin configures an rEA entitlement.
    '''

    displayName = _("Manage Administrative Entitlement")

    tableClass = KeyChangeTable
    #cnrPath = "/srv/conary/repository.cnr"
    cnrPath = "repository.cnr"

    def _getReposCfg(self):
        # Get repository hostnames and fqdn
        from conary.repository.netrepos.netserver import ServerConfig
        import os
        cfg = ServerConfig()
        cfg.read(self.cnrPath)
        serverNames = cfg.serverName
        hostName = os.uname()[1]
        return serverNames, hostName

    @turbogears.expose(html="rPath.reaentitlement.reaentitlement")
    @turbogears.identity.require( turbogears.identity.not_anonymous() )
    def index(self):
        serverNames, hostName = self._getReposCfg()
        return dict(key=self.table.getkey(),
{'fraction_non_alphanumeric': 0.10056014937316618, 'fraction_numerical': 0.005334755934915978, 'mean_word_length': 2.90625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3517214', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1139, 'n_words': 282}