Esempio n. 1
0
    def __init__(self, name, sname, modpath, basepath, fullimploc):  # pylint: disable=too-many-arguments
        """
    initialize the instance
    The following things should not be done in __init__ in a plugin
      Interacting with anything in the api except api.add, api.overload
          or dependency.add
    """
        # Examples:
        #  name : 'Actions' - from plugin file variable NAME (long name)
        #  sname : 'actions' - from plugin file variable SNAME (short name)
        #  modpath : '/client/actions.py' - path relative to the plugins directory
        #  basepath : '/home/src/games/bastproxy/bp/plugins' - the full path to the
        #                                                         plugins directory
        #  fullimploc : 'plugins.client.actions' - import location

        self.author = ''
        self.purpose = ''
        self.version = 0
        self.priority = 100
        self.name = name
        self.sname = sname
        self.dependencies = []
        self.versionfuncs = {}
        self.reloaddependents = False
        self.summarytemplate = "%20s : %s"
        self.canreload = True
        self.canreset = True
        self.resetflag = True
        self.api = API()
        self.firstactiveprio = None
        self.loadedtime = time.time()
        self.savedir = os.path.join(self.api.BASEPATH, 'data', 'plugins',
                                    self.sname)
        try:
            os.makedirs(self.savedir)
        except OSError:
            pass
        self.savefile = os.path.join(self.api.BASEPATH, 'data', 'plugins',
                                     self.sname, 'settingvalues.txt')
        self.modpath = modpath
        self.basepath = basepath
        self.fullimploc = fullimploc
        self.pluginfile = os.path.join(basepath, modpath[1:])
        self.pluginlocation = os.path.normpath(
            os.path.join(self.api.BASEPATH, 'plugins') + \
              os.sep + os.path.dirname(self.modpath))

        self.package = fullimploc.split('.')[1]

        self.settings = {}
        self.settingvalues = PersistentDictEvent(self, self.savefile, 'c')

        self._dump_shallow_attrs = ['api']

        self.api.overload('dependency', 'add', self._api_dependencyadd)
        self.api.overload('setting', 'add', self._api_settingadd)
        self.api.overload('setting', 'gets', self._api_settinggets)
        self.api.overload('setting', 'change', self._api_settingchange)
        self.api.overload('api', 'add', self._api_add)
Esempio n. 2
0
    def __init__(self, name, sname, modpath, basepath, fullimploc):
        # pylint: disable=too-many-arguments
        """
    initialize the instance
    The following things should not be done in __init__ in a plugin
      Interacting with anything in the api except api.add, api.overload
          or dependency.add
    """
        self.author = ''
        self.purpose = ''
        self.version = 0
        self.priority = 100
        self.name = name
        self.sname = sname
        self.dependencies = []
        self.versionfuncs = {}
        self.reloaddependents = False
        self.canreload = True
        self.resetflag = True
        self.api = API()
        self.loadedtime = time.time()
        self.savedir = os.path.join(self.api.BASEPATH, 'data', 'plugins',
                                    self.sname)
        try:
            os.makedirs(self.savedir)
        except OSError:
            pass
        self.savefile = os.path.join(self.api.BASEPATH, 'data', 'plugins',
                                     self.sname, 'settingvalues.txt')
        self.modpath = modpath
        self.basepath = basepath
        self.fullimploc = fullimploc
        self.pluginfile = os.path.join(basepath, modpath[1:])
        self.pluginlocation = os.path.normpath(
            os.path.join(self.api.BASEPATH, 'plugins') + \
              os.sep + os.path.dirname(self.modpath))

        self.package = fullimploc.split('.')[1]

        self.settings = {}
        self.settingvalues = PersistentDictEvent(self, self.savefile, 'c')

        self._dump_shallow_attrs = ['api']

        self.api.overload('dependency', 'add', self.api_dependencyadd)
        self.api.overload('setting', 'add', self.api_settingadd)
        self.api.overload('setting', 'gets', self.api_settinggets)
        self.api.overload('setting', 'change', self.api_settingchange)
        self.api.overload('api', 'add', self.api_add)