Пример #1
0
 def _checkParams(self):
     optionName = self._params.get("optionName", None)
     if optionName:
         options = optionName.split(".")
         ph = PluginsHolder()
         if len(options) == 3:
             pluginType, plugin, option = options
             if ph.hasPluginType(pluginType):
                 if ph.getPluginType(pluginType).hasPlugin(plugin):
                     self._targetOption = ph.getPluginType(pluginType).getPlugin(plugin).getOption(option)
                 else:
                     raise ServiceError("ERR-PLUG4", "plugin: " + str(plugin) + " does not exist")
             else:
                 raise ServiceError(
                     "ERR-PLUG3", "pluginType: " + str(pluginType) + " does not exist, is not visible or not active"
                 )
         elif len(options) == 2:
             pluginType, option = options
             if ph.hasPluginType(pluginType):
                 self._targetOption = ph.getPluginType(pluginType).getOption(option)
             else:
                 raise ServiceError(
                     "ERR-PLUG3", "pluginType: " + str(pluginType) + " does not exist, is not visible or not active"
                 )
         else:
             raise ServiceError(
                 "ERR-PLUG1", "optionName argument does not have the proper pluginType.plugin.option format"
             )
     else:
         raise ServiceError("ERR-PLUG0", "optionName argument not present")
Пример #2
0
 def _checkParams(self):
     optionName = self._params.get('optionName', None)
     if optionName:
         options = optionName.split('.')
         ph = PluginsHolder()
         if len(options) == 3:
             pluginType, plugin, option = options
             if ph.hasPluginType(pluginType):
                 if ph.getPluginType(pluginType).hasPlugin(plugin):
                     self._targetOption = ph.getPluginType(
                         pluginType).getPlugin(plugin).getOption(option)
                 else:
                     raise ServiceError(
                         'ERR-PLUG4',
                         'plugin: ' + str(plugin) + ' does not exist')
             else:
                 raise ServiceError(
                     'ERR-PLUG3', 'pluginType: ' + str(pluginType) +
                     ' does not exist, is not visible or not active')
         elif len(options) == 2:
             pluginType, option = options
             if ph.hasPluginType(pluginType):
                 self._targetOption = ph.getPluginType(
                     pluginType).getOption(option)
             else:
                 raise ServiceError(
                     'ERR-PLUG3', 'pluginType: ' + str(pluginType) +
                     ' does not exist, is not visible or not active')
         else:
             raise ServiceError(
                 'ERR-PLUG1',
                 'optionName argument does not have the proper pluginType.plugin.option format'
             )
     else:
         raise ServiceError('ERR-PLUG0', 'optionName argument not present')
Пример #3
0
 def getOptionValueRooms(cls, pluginId, optionName):
     """ Returns the room list of an option with type 'rooms' of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginId).getOption(optionName).getRooms()
Пример #4
0
    def getVars(self):
        ph = PluginsHolder()

        tplVars = WTemplated.getVars(self)
        tplVars["epayment_htdocs"] = UHEPaymentHtdocs.getURL()
        tplVars["currency_data"] = ph.getPluginType('EPayment').getOption("customCurrency").getValue()
        return tplVars
Пример #5
0
 def _checkParams(self):
     AdminService._checkParams(self)
     ph = PluginsHolder()
     self._targetOption = ph.getPluginType('EPayment').getOption(
         "customCurrency")
     self._currencyName = self._params.get('name', None)
     self._currencies = self._targetOption.getValue()
Пример #6
0
 def getOptionValue(cls, pluginId, optionName):
     """ Returns the value of an option of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginId).getOption(optionName).getValue()
Пример #7
0
    def getVars(self):
        ph = PluginsHolder()

        tplVars = WTemplated.getVars(self)
        tplVars["epayment_htdocs"] = UHEPaymentHtdocs
        tplVars["currency_data"] = ph.getPluginType('EPayment').getOption(
            "customCurrency").getValue()
        return tplVars
Пример #8
0
 def getOptionValue(cls, pluginId, optionName):
     """ Returns the value of an option of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginId).getOption(
         optionName).getValue()
Пример #9
0
 def getOptionValueRooms(cls, pluginId, optionName):
     """ Returns the room list of an option with type 'rooms' of a plugin (plugins/Collaboration/XXXXX/options.py)
         pluginName: a string with the name of the plugin
         optionName: a string with the name of the option
     """
     ph = PluginsHolder()
     return ph.getPluginType("Collaboration").getPlugin(pluginId).getOption(
         optionName).getRooms()
Пример #10
0
 def _checkParams(self):
     optionName = self._params.get('optionName', None)
     if optionName:
         options = optionName.split('.')
         ph = PluginsHolder()
         if len(options) == 3:
             pluginType, plugin, option = options
             if ph.hasPluginType(pluginType):
                 if ph.getPluginType(pluginType).hasPlugin(plugin):
                     self._targetOption = ph.getPluginType(pluginType).getPlugin(plugin).getOption(option)
                 else:
                     raise ServiceError('ERR-PLUG4', 'plugin: ' + str(plugin) + ' does not exist')
             else:
                 raise ServiceError('ERR-PLUG3', 'pluginType: ' + str(pluginType) + ' does not exist, is not visible or not active')
         elif len(options) == 2:
             pluginType, option = options
             if ph.hasPluginType(pluginType):
                 self._targetOption = ph.getPluginType(pluginType).getOption(option)
             else:
                 raise ServiceError('ERR-PLUG3', 'pluginType: ' + str(pluginType) + ' does not exist, is not visible or not active')
         else:
             raise ServiceError('ERR-PLUG1', 'optionName argument does not have the proper pluginType.plugin.option format')
     else:
         raise ServiceError('ERR-PLUG0', 'optionName argument not present')
Пример #11
0
    def getList( self ):

        ph = PluginsHolder()
        if ph.hasPluginType("EPayment"):
            self._targetOption = ph.getPluginType("EPayment").getOption("customCurrency")
            currencies = self._targetOption.getValue()
            currenciesList = []
            for currency in currencies:
                currenciesList.append(currency["abbreviation"])
            return currenciesList

        else:
            raise ServiceError('ERR-PLUG3', 'pluginType: ' + str("EPayment") + ' does not exist, is not visible or not active')

        return [""]
Пример #12
0
    def getList(self):

        ph = PluginsHolder()
        if ph.hasPluginType("EPayment"):
            self._targetOption = ph.getPluginType("EPayment").getOption(
                "customCurrency")
            currencies = self._targetOption.getValue()
            currenciesList = []
            for currency in currencies:
                currenciesList.append(currency["abbreviation"])
            return currenciesList

        else:
            raise ServiceError(
                'ERR-PLUG3', 'pluginType: ' + str("EPayment") +
                ' does not exist, is not visible or not active')

        return [""]
Пример #13
0
class RHAdminPluginsBase(RoomBookingDBMixin, RHAdminBase):
    """ Base RH class for all plugin management requests.
        It will store 2 string parameters: pluginType and pluginId.
        Example: pluginType = "COllaboration" & pluginId = "EVO"
    """

    def _checkParams(self, params):
        RHAdminBase._checkParams(self, params)
        self._pluginType = params.get("pluginType", None)
        #take out white spaces in case there are some
        if self._pluginType:
            self._pluginType = self._pluginType.replace(' ', '')
        self._pluginId = params.get("pluginId", None)
        #take out white spaces in case there are some
        if self._pluginId:
            self._pluginId = self._pluginId.replace(' ', '')
        self._ph = PluginsHolder()
        if self._pluginType and not self._ph.hasPluginType(self._pluginType, mustBeActive = False):
            raise PluginError("The plugin type " + self._pluginType + " does not exist or is not visible")
        elif self._pluginType and self._pluginId and not self._ph.getPluginType(self._pluginType).hasPlugin(self._pluginId):
            raise PluginError("The plugin " + self._pluginId + " does not exist")
Пример #14
0
 def getCustomerUsername(self):
     ph = PluginsHolder()
     return ph.getPluginType("EPayment").getPlugin("eWay").getOption("customer_username").getValue()
Пример #15
0
def runTests(host='localhost', port=FAKE_SERVICE_PORT,
             scenarios=[(2, 10)]):

    execTimes = []

    agent = InvenioBatchUploaderAgent('test1', 'test1', 'test',
                                      0, 'http://%s:%s' \
                                      % (host, port))

    ph = PluginsHolder()
    ph.reloadAllPlugins()
    ph.getPluginType('livesync').toggleActive()
    do = DummyObservable()

    do._notify('updateDBStructures', 'indico.ext.livesync',
                              None, None, None)

    sm = SyncManager.getDBInstance()

    sm.registerNewAgent(agent)

    cm = CategoryManager()

    avatar = user.Avatar()
    avatar.setName( "fake" )
    avatar.setSurName( "fake" )
    avatar.setOrganisation( "fake" )
    avatar.setLang( "en_GB" )
    avatar.setEmail( "*****@*****.**" )

    #registering user
    ah = user.AvatarHolder()
    ah.add(avatar)

    #setting up the login info
    li = user.LoginInfo("dummyuser", None)
    am = AuthenticatorMgr()
    userid = am.createIdentity( li, avatar, "Local" )
    am.add( userid )

    #activate the account
    avatar.activateAccount()

    #since the DB is empty, we have to add dummy user as admin
    minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
    al = minfo.getAdminList()
    al.grant( avatar )

    dummy = avatar

    ContextManager.destroy()

    HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(DefaultConference())

    cm.getRoot()

    do._notify('requestStarted')

    home = cm.getById('0')

    # execute code
    for nconf in range(0, 1000):
        conf = home.newConference(dummy)
        conf.setTitle('Test Conference %s' % nconf)

    do._notify('requestFinished')

    time.sleep(1)

    # params won't be used
    task = LiveSyncUpdateTask(dateutil.rrule.MINUTELY)

    for scen in scenarios:

        print "Scenario %s workers, size = %s " % scen,

        # configure scenario
        InvenioBatchUploaderAgent.NUM_WORKERS = scen[0]
        InvenioBatchUploaderAgent.BATCH_SIZE = scen[1]

        ts = time.time()
        # just run it
        task.run()

        te = time.time()
        execTimes.append(te - ts)

        print "%s" % (te - ts)

        sm._track._pointers['test1'] = None

    for i in range(0, len(execTimes)):
        results[scenarios[i]] = execTimes[i]
Пример #16
0
 def _checkParams(self):
     AdminService._checkParams(self)
     ph = PluginsHolder()
     self._targetOption = ph.getPluginType("EPayment").getOption("customCurrency")
     self._currencyName = self._params.get("name", None)
     self._currencies = self._targetOption.getValue()
Пример #17
0
def runTests(host='localhost', port=FAKE_SERVICE_PORT,
             scenarios=[(2, 10)]):

    execTimes = []

    agent = InvenioBatchUploaderAgent('test1', 'test1', 'test',
                                      0, 'http://%s:%s' \
                                      % (host, port))

    ph = PluginsHolder()
    ph.reloadAllPlugins()
    ph.getPluginType('livesync').toggleActive()
    do = DummyObservable()

    do._notify('updateDBStructures', 'indico.ext.livesync',
                              None, None, None)

    sm = SyncManager.getDBInstance()

    sm.registerNewAgent(agent)

    cm = CategoryManager()

    avatar = user.Avatar()
    avatar.setName( "fake" )
    avatar.setSurName( "fake" )
    avatar.setOrganisation( "fake" )
    avatar.setLang( "en_GB" )
    avatar.setEmail( "*****@*****.**" )

    #registering user
    ah = user.AvatarHolder()
    ah.add(avatar)

    #setting up the login info
    li = user.LoginInfo( "dummyuser", "dummyuser" )
    ih = AuthenticatorMgr()
    userid = ih.createIdentity( li, avatar, "Local" )
    ih.add( userid )

    #activate the account
    avatar.activateAccount()

    #since the DB is empty, we have to add dummy user as admin
    minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
    al = minfo.getAdminList()
    al.grant( avatar )

    dummy = avatar

    ContextManager.destroy()

    HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(DefaultConference())

    cm.getRoot()

    do._notify('requestStarted')

    home = cm.getById('0')

    # execute code
    for nconf in range(0, 1000):
        conf = home.newConference(dummy)
        conf.setTitle('Test Conference %s' % nconf)

    do._notify('requestFinished')

    time.sleep(1)

    # params won't be used
    task = LiveSyncUpdateTask(dateutil.rrule.MINUTELY)

    for scen in scenarios:

        print "Scenario %s workers, size = %s " % scen,

        # configure scenario
        InvenioBatchUploaderAgent.NUM_WORKERS = scen[0]
        InvenioBatchUploaderAgent.BATCH_SIZE = scen[1]

        ts = time.time()
        # just run it
        task.run()

        te = time.time()
        execTimes.append(te - ts)

        print "%s" % (te - ts)

        sm._track._pointers['test1'] = None

    for i in range(0, len(execTimes)):
        results[scenarios[i]] = execTimes[i]
Пример #18
0
 def getUrl(self):
     ph = PluginsHolder()
     return ph.getPluginType("EPayment").getPlugin("eWay").getOption("url").getValue()