• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python manager.StorageManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中system.storage.manager.StorageManager的典型用法代码示例。如果您正苦于以下问题:Python StorageManager类的具体用法?Python StorageManager怎么用?Python StorageManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StorageManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setup

    def setup(self):
        ### Grab important shit
        self._commands = CommandManager()
        self._storage = StorageManager()

        ### Initial config load
        try:
            self._config = self._storage.get_file(self, "config", YAML,
                                                  "plugins/dice.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self.logger.error("Disabling...")
            self._disable_self()
            return
        if not self._config.exists:
            self.logger.error("Unable to find config/plugins/dice.yml")
            self.logger.error("Disabling...")
            self._disable_self()
            return

        ### Register commands
        self._commands.register_command("roll",
                                        self.roll_cmd,
                                        self,
                                        "dice.roll",
                                        aliases=["dice"],
                                        default=True)
开发者ID:EionRobb,项目名称:Ultros-contrib,代码行数:27,代码来源:__init__.py


示例2: setup

    def setup(self):
        signal.signal(signal.SIGINT, self.signal_callback)

        self.yapsy_logger.debug_ = self.yapsy_logger.debug
        self.yapsy_logger.debug = self.yapsy_logger.trace

        self.storage = StorageManager()
        self.main_config = self.storage.get_file(self, "config", YAML,
                                                 "settings.yml")

        self.commands.set_factory_manager(self)

        self.load_config()  # Load the configuration

        try:
            self.metrics = Metrics(self.main_config, self)
        except Exception:
            self.logger.exception(_("Error setting up metrics."))

        self.plugman.scan()
        self.load_plugins()  # Load the configured plugins
        self.load_protocols()  # Load and set up the protocols

        if not len(self.factories):
            self.logger.info(_("It seems like no protocols are loaded. "
                               "Shutting down.."))
            return
开发者ID:NotAFile,项目名称:Ultros,代码行数:27,代码来源:factory_manager.py


示例3: setup

    def setup(self):
        self.commands = CommandManager()
        self.storage = StorageManager()

        self.logger.trace("Entered setup method.")
        try:
            self.config = self.storage.get_file(self, "config", YAML,
                                                "plugins/items.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self.logger.warn("Defaulting to SQLite for storage.")
        else:
            if not self.config.exists:
                self.logger.warn("Unable to find config/plugins/items.yml")
                self.logger.warn("Defaulting to SQLite for storage.")
            else:
                self.logger.info("Using storage type: %s" % self.storage_type)

        self._load()
        self.config.add_callback(self._load)

        self.commands.register_command("give", self.give_command, self,
                                       "items.give", default=True)
        self.commands.register_command("get", self.get_command, self,
                                       "items.get", default=True)
        self.commands.register_command("items", self.count_command, self,
                                       "items.count", default=True)
开发者ID:case,项目名称:Ultros-contrib,代码行数:27,代码来源:__init__.py


示例4: setup

    def setup(self):
        self.storage = StorageManager()
        try:
            self.config = self.storage.get_file(self, "config", YAML,
                                                "plugins/wordnik.yml")
        except Exception:
            self.logger.exception("Unable to load the configuration!")
            return self._disable_self()
        if not self.config.exists:
            self.logger.error("Unable to find the configuration at "
                              "config/plugins/wordnik.yml - Did you fill "
                              "it out?")
            return self._disable_self()
        if "apikey" not in self.config or not self.config["apikey"]:
            self.logger.error("Unable to find an API key; did you fill out the"
                              " config?")
            return self._disable_self()

        self._load()
        self.config.add_callback(self._load)

        self.plugman = PluginManager()

        self.commands = CommandManager()

        self.commands.register_command("dict", self.dict_command,
                                       self, "wordnik.dict", default=True)
        self.commands.register_command("wotd", self.wotd_command,
                                       self, "wordnik.wotd", default=True)
开发者ID:case,项目名称:Ultros-contrib,代码行数:29,代码来源:__init__.py


示例5: setup

    def setup(self):
        self.events = EventManager()
        self.storage = StorageManager()

        try:
            self.config = self.storage.get_file(self, "config", YAML,
                                                "plugins/blowfish.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self._disable_self()
            return
        if not self.config.exists:
            self.logger.error("Unable to find config/plugins/blowfish.yml")
            self._disable_self()
            return

        self.events.add_callback(
            "PreMessageReceived", self, self.pre_message, 10001
        )

        self.events.add_callback(
            "MessageSent", self, self.message_sent, 10001
        )

        self.events.add_callback(
            "ActionReceived", self, self.message_sent, 10001
        )

        self.events.add_callback(
            "ActionSent", self, self.message_sent, 10001
        )
开发者ID:EionRobb,项目名称:Ultros-contrib,代码行数:31,代码来源:__init__.py


示例6: setup

    def setup(self):
        self.logger.trace("Entered setup method.")
        self.storage = StorageManager()
        try:
            self.config = self.storage.get_file(self, "config", YAML,
                                                "plugins/feeds.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self.logger.error("Disabling..")
            self._disable_self()
            return
        if not self.config.exists:
            self.logger.error("Unable to find config/plugins/feeds.yml")
            self.logger.error("Disabling..")
            self._disable_self()
            return

        self.config.add_callback(self.delayed_setup)

        self.events = EventManager()
        self.plugman = PluginManager()

        self.logger.info("Waiting 30 seconds to set up.")

        reactor.callLater(30, self.delayed_setup)
开发者ID:EionRobb,项目名称:Ultros-contrib,代码行数:25,代码来源:__init__.py


示例7: __init__

    def __init__(self):
        configure(None)
        self.logger = getLogger("Permissions")

        self.confdir = tmpdir + "/config/"
        self.datadir = tmpdir + "/data/"

        try:
            os.makedirs(self.confdir)
            os.makedirs(self.datadir)
            self.logger.debug("Config and data dirs created.")
        except Exception:
            pass

        yaml.dump({"editor_warning": False},
                  open(self.confdir + "settings.yml", "w"))

        self.storage = StorageManager(self.confdir, self.datadir)

        self.data = self.storage.get_file(self, "data", formats.YAML,
                                          "permissions.yml")

        self.handler = permissionsHandler(self, self.data)

        super(TestPlugin, self).__init__(
            AttrDict(name="test", module="test_permissions"),
            AttrDict(name="python"),
        )
开发者ID:UltrosBot,项目名称:Ultros,代码行数:28,代码来源:test_permissions.py


示例8: setup

    def setup(self):
        self.logger.trace("Entered setup method.")

        self.commands = CommandManager()
        self.events = EventManager()
        self.storage = StorageManager()

        try:
            self.config = self.storage.get_file(self, "config", YAML,
                                                "plugins/inter.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self.logger.error(_("Disabling.."))
            self._disable_self()
            return

        if not self.config.exists:
            self.logger.error("Unable to find config/plugins/inter.yml")
            self.logger.error(_("Disabling.."))
            self._disable_self()
            return

        self.config.add_callback(self.reload)

        self.commands.register_command("players", self.players_command, self,
                                       "inter.players", default=True)

        self.events.add_callback("ReactorStarted", self, self.first_load, 0)
开发者ID:domainr,项目名称:Ultros-contrib,代码行数:28,代码来源:__init__.py


示例9: setup

    def setup(self):
        self.logger.trace("Entered setup method.")
        self.storage = StorageManager()
        try:
            self.config = self.storage.get_file(self, "config", YAML,
                                                "plugins/minecraft.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self._disable_self()
            return
        if not self.config.exists:
            self.logger.error("Unable to find config/plugins/minecraft.yml")
            self.logger.error("Disabling..")
            self._disable_self()
            return

        if not self.relay_targets:
            self.logger.warn("No valid target protocols found. "
                             "Disabling status relaying.")

        self.commands = CommandManager()
        self.commands.register_command("mcquery", self.query_command, self,
                                       "minecraft.query", default=True)

        if self.do_relay:
            reactor.callLater(30, self.start_relay)
开发者ID:case,项目名称:Ultros-contrib,代码行数:26,代码来源:__init__.py


示例10: setup

    def setup(self):
        ### Grab important shit
        self.commands = CommandManager()
        self.storage = StorageManager()

        ### Initial config load
        try:
            self._config = self.storage.get_file(self,
                                                 "config",
                                                 YAML,
                                                 "plugins/8ball.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self.logger.error("Disabling...")
            self._disable_self()
            return
        if not self._config.exists:
            self.logger.error("Unable to find config/plugins/8ball.yml")
            self.logger.error("Disabling...")
            self._disable_self()
            return

        ### Setup some stuff
        self._random = random.Random()
        self._question_regex = re.compile("[\W_]+")

        ### Register commands
        self.commands.register_command("8ball",
                                       self.eight_ball_cmd,
                                       self,
                                       "8ball.8ball",
                                       default=True)
开发者ID:EionRobb,项目名称:Ultros-contrib,代码行数:32,代码来源:__init__.py


示例11: setup

    def setup(self):
        self.commands = CommandManager()
        self.events = EventManager()
        self.storage = StorageManager()
        self.data = self.storage.get_file(
            self,
            "data",
            DBAPI,
            "sqlite3:data/plugins/lastseen/users.sqlite",
            "data/plugins/lastseen/users.sqlite",
            check_same_thread=False
        )

        self.data.runQuery("CREATE TABLE IF NOT EXISTS users ("
                           "user TEXT, "
                           "protocol TEXT, "
                           "at INTEGER)")

        self.commands.register_command("seen", self.seen_command, self,
                                       "seen.seen", default=True)

        # General events

        self.events.add_callback("PreMessageReceived", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_source_caller])
        self.events.add_callback("PreCommand", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_source_caller])
        self.events.add_callback("NameChanged", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_user_caller])
        self.events.add_callback("UserDisconnected", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_user_caller])

        # Mumble events

        self.events.add_callback("Mumble/UserRemove", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_user_caller])
        self.events.add_callback("Mumble/UserJoined", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_user_caller])
        self.events.add_callback("Mumble/UserMoved", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_user_caller])
        self.events.add_callback("Mumble/UserSelfMuteToggle", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_user_caller])
        self.events.add_callback("Mumble/UserSelfDeafToggle", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_user_caller])
        self.events.add_callback("Mumble/UserRecordingToggle", self,
                                 self.event_handler, 0, cancelled=True,
                                 extra_args=[self.event_user_caller])
开发者ID:domainr,项目名称:Ultros-contrib,代码行数:56,代码来源:__init__.py


示例12: setup

    def setup(self):
        self.storage = StorageManager()
        self.data = self.storage.get_file(self, "data", YAML,
                                          "plugins/memos/memos.yml")

        self.commands.register_command("memo", self.memo, self, default=True,
                                       permission="memos.memo")

        self.events.add_callback("PreMessageReceived", self,
                                 self.message_received, 0)
开发者ID:EionRobb,项目名称:Ultros-contrib,代码行数:10,代码来源:__init__.py


示例13: ItemsPlugin

class ItemsPlugin(plugin.PluginObject):

    commands = None

    config = None
    data = None
    storage = None

    handler = None

    @property
    def storage_type(self):
        if self.config["storage"].lower() == "json":
            return "json"
        return "sqlite"

    def setup(self):
        self.commands = CommandManager()
        self.storage = StorageManager()

        self.logger.trace("Entered setup method.")
        try:
            self.config = self.storage.get_file(self, "config", YAML,
                                                "plugins/items.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self.logger.warn("Defaulting to SQLite for storage.")
        else:
            if not self.config.exists:
                self.logger.warn("Unable to find config/plugins/items.yml")
                self.logger.warn("Defaulting to SQLite for storage.")
            else:
                self.logger.info("Using storage type: %s" % self.storage_type)

        self._load()
        self.config.add_callback(self._load)

        self.commands.register_command("give", self.give_command, self,
                                       "items.give", default=True)
        self.commands.register_command("get", self.get_command, self,
                                       "items.get", default=True)

    def _load(self):
        if self.storage_type == "json":
            self.handler = JSONType(self, self.storage, self.logger)
        else:
            self.handler = SQLiteType(self, self.storage, self.logger)

    @RateLimiter(5, 0, 10)
    def give_command(self, *args, **kwargs):
        return self.handler.give_command(*args, **kwargs)

    @RateLimiter(5, 0, 10)
    def get_command(self, *args, **kwargs):
        return self.handler.get_command(*args, **kwargs)
开发者ID:domainr,项目名称:Ultros-contrib,代码行数:55,代码来源:__init__.py


示例14: setup

    def setup(self):
        ### Grab important shit
        self.commands = CommandManager()
        self.storage = StorageManager()

        ### Initial config load
        try:
            self._config = self.storage.get_file(self,
                                                 "config",
                                                 YAML,
                                                 "plugins/aoshelper.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self.logger.error("Disabling...")
            self._disable_self()
            return
        if not self._config.exists:
            self.logger.error("Unable to find config/plugins/aoshelper.yml")
            self.logger.error("Disabling...")
            self._disable_self()
            return

        ### Load options from config
        self._load()

        self._config.add_callback(self._load)

        ### Register commands
        self.commands.register_command("aosplayercount",
                                       self.playercount_cmd,
                                       self,
                                       "aoshelper.playercount",
                                       [
                                           "playercount"
                                       ], default=True)
        self.commands.register_command("aostoip",
                                       self.aos_to_ip_command,
                                       self,
                                       "aoshelper.aostoip",
                                       [
                                           "aos2ip"
                                       ])
        self.commands.register_command("iptoaos",
                                       self.ip_to_aos_command,
                                       self,
                                       "aoshelper.iptoaos",
                                       [
                                           "ip2aos"
                                       ])

        ### Setup soem variables
        self._last_update_voxlap = 0
        self._last_update_steam = 0
        self._last_voxlap_player_count = -1
        self._last_steam_player_count = -1
开发者ID:EionRobb,项目名称:Ultros-contrib,代码行数:55,代码来源:__init__.py


示例15: setup

    def setup(self):
        self.storage = StorageManager()
        self.config = self.storage.get_file(self, "config", YAML,
                                            "plugins/money.yml")

        self.commands = command_manager.CommandManager()
        self.commands.register_command("money", self.money_command_called,
                                       self, "money.main", default=True)

        self._load()

        self.config.add_callback(self._load)
开发者ID:domainr,项目名称:Ultros-contrib,代码行数:12,代码来源:__init__.py


示例16: setup

    def setup(self):
        """
        Called when the plugin is loaded. Performs initial setup.
        """

        self.logger.trace(_("Entered setup method."))
        self.storage = StorageManager()
        try:
            self.config = self.storage.get_file(self, "config", YAML,
                                                "plugins/urls.yml")
        except Exception:
            self.logger.exception(_("Error loading configuration!"))
        else:
            if not self.config.exists:
                self.logger.warn(_("Unable to find config/plugins/urls.yml"))
            else:
                self.content_types = self.config["content_types"]
                self.spoofing = self.config["spoofing"]

        self.logger.debug(_("Spoofing: %s") % self.spoofing)

        self.channels = self.storage.get_file(self, "data", YAML,
                                              "plugins/urls/channels.yml")
        self.shortened = self.storage.get_file(
            self,
            "data",
            DBAPI,
            "sqlite3:data/plugins/urls/shortened.sqlite",
            "data/plugins/urls/shortened.sqlite",
            check_same_thread=False
        )

        self.commands = CommandManager()
        self.events = EventManager()

        self.reload()

        def message_event_filter(event=MessageReceived):
            target = event.target
            type_ = event.type

            return type_ == "message" \
                or isinstance(target, Channel) \
                or isinstance(target, User)

        self.add_shortener("tinyurl", self.tinyurl)

        self.events.add_callback("MessageReceived", self, self.message_handler,
                                 1, message_event_filter)
        self.commands.register_command("urls", self.urls_command, self,
                                       "urls.manage")
        self.commands.register_command("shorten", self.shorten_command, self,
                                       "urls.shorten", default=True)
开发者ID:NotAFile,项目名称:Ultros,代码行数:53,代码来源:__init__.py


示例17: setup

    def setup(self):
        ### Grab important shit
        self.commands = CommandManager()
        self.storage = StorageManager()

        ### Initial config load
        try:
            self._config = self.storage.get_file(self, "config", YAML,
                                                 "plugins/lastfm.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            self.logger.error("Disabling...")
            self._disable_self()
            return
        if not self._config.exists:
            self.logger.error("Unable to find config/plugins/lastfm.yml")
            self.logger.error("Disabling...")
            self._disable_self()
            return
            ### Same for the data file (nickname=>lastfmusername map)
        try:
            self._nickmap = self.storage.get_file(self, "data", YAML,
                                                  "plugins/lastfm-nickmap.yml")
        except Exception:
            self.logger.exception("Error loading nickmap!")
            self.logger.error("Disabling...")
            self._disable_self()

        ### Load options from config and nick map from data
        self._load()

        self._config.add_callback(self._load)

        ### Register commands
        self.commands.register_command("nowplaying",
                                       self.nowplaying_cmd,
                                       self,
                                       "lastfm.nowplaying",
                                       aliases=["np"],
                                       default=True)
        self.commands.register_command("lastfmnick",
                                       self.lastfmnick_cmd,
                                       self,
                                       "lastfm.lastfmnick",
                                       default=True)
        self.commands.register_command("lastfmcompare",
                                       self.compare_cmd,
                                       self,
                                       "lastfm.compare",
                                       aliases=["musiccompare", "compare"],
                                       default=True)
开发者ID:domainr,项目名称:Ultros-contrib,代码行数:51,代码来源:__init__.py


示例18: WebhooksPlugin

class WebhooksPlugin(plugin.PluginObject):

    config = None
    data = None

    commands = None
    events = None
    plugins = None
    storage = None

    @property
    def web(self):
        """
        :rtype: plugins.web.WebPlugin
        """
        return self.plugins.get_plugin("Web")

    def setup(self):
        self.logger.trace("Entered setup method.")

        self.commands = CommandManager()
        self.events = EventManager()
        self.plugins = PluginManager()
        self.storage = StorageManager()

        try:
            self.config = self.storage.get_file(self, "config", YAML, "plugins/webhooks.yml")
        except Exception:
            self.logger.exception("Error loading configuration!")
            return self._disable_self()
        else:
            if not self.config.exists:
                self.logger.error("Unable to find config/plugins/webhooks.yml")
                return self._disable_self()

        self._load()
        self.config.add_callback(self._load)

        self.events.add_callback("Web/ServerStartedEvent", self, self.add_routes, 0)

    def _load(self):
        pass

    def add_routes(self, _=None):
        self.web.add_navbar_entry("Webhooks", "/webhooks", "url")
        self.web.add_handler("/webhooks", "plugins.webhooks.routes.webhooks.Route")
        self.logger.info("Registered route: /webhooks")

    pass  # So the regions work in PyCharm
开发者ID:EionRobb,项目名称:Ultros-contrib,代码行数:49,代码来源:__init__.py


示例19: setup

    def setup(self):
        ### Grab important shit
        self._commands = CommandManager()
        self._storage = StorageManager()

        ### Initial config load
        try:
            self._config = self._storage.get_file(self, "config", YAML,
                                                  "plugins/xkcd.yml")
        except:
            self.logger.exception("Error loading configuration!")
            self.logger.error("Disabling...")
            self._disable_self()
            return
        if not self._config.exists:
            self.logger.error("Unable to find config/plugins/xkcd.yml")
            self.logger.error("Disabling...")
            self._disable_self()
            return
        ### Same for the data files
        try:
            self._comic_cache = self._storage.get_file(
                self, "data", YAML,
                "plugins/xkcd/comic-cache.yml")
        except:
            self.logger.exception("Error loading comic-cache!")
            self.logger.error("Disabling...")
            self._disable_self()
        try:
            self._archive = self._storage.get_file(self, "data", YAML,
                                                   "plugins/xkcd/archive.yml")
        except:
            self.logger.exception("Error loading archive!")
            self.logger.error("Disabling...")
            self._disable_self()

        ### Initial data file setup and stuff
        self._load()

        self._config.add_callback(self._load)
        self._comic_cache.add_callback(self._load)
        self._archive.add_callback(self._load)

        ### Register commands
        self._commands.register_command("xkcd",
                                        self.xkcd_cmd,
                                        self,
                                        "xkcd.xkcd", default=True)
开发者ID:EionRobb,项目名称:Ultros-contrib,代码行数:48,代码来源:__init__.py


示例20: __init__

    def __init__(self, get=True):
        self.storage = StorageManager()
        if get:
            info_url = self.base_file_url + self.info_file
            response = urllib2.urlopen(info_url)
            data = response.read()
            self.data = yaml.load(data)
            self.packages = sorted(self.data.keys())

        self.config = self.storage.get_file(self, "data", YAML, "packages.yml")

        with self.config:
            if "installed" not in self.config:
                self.config["installed"] = {}
            if "etags" not in self.config:
                self.config["etags"] = {}
开发者ID:UltrosBot,项目名称:Ultros,代码行数:16,代码来源:packages.py



注:本文中的system.storage.manager.StorageManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python system_test.main_module函数代码示例发布时间:2022-05-27
下一篇:
Python services.systemctl函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap