def __init__(self, name, cls, service, cfg): """ Constructor :param name: Name of plugin. :type name: str. :param cls: Class/type of plugin. :type cls: str. :param service: Container service. :type service: mhub.service. :param cfg: Plugin configuration dictionary. :type cfg: dict. """ BasePlugin.__init__(self, name, cls, service, cfg) self.url = self.cfg.get("url", None) self.patterns = self.cfg.get("patterns", list()) if self.url is None: self.logger.debug("URL not specified.") return poll_task = LoopingCall(self.poll_url) poll_task.start(self.cfg.get("poll_interval", 60))
def setup(self, cfg): BasePlugin.setup(self, cfg) self.factory = AmqpFactory(plugin=self) self.factory.read("*", self.amqp_receive) self.client = TCPClient(self.cfg.get("host", "localhost"), self.cfg.get("port", 5672), self.factory)
def setup(self, cfg): BasePlugin.setup(self, cfg) self.factory = TelnetFactory(plugin=self) self.factory.plugin = self self.client = TCPServer(self.cfg.get("port", 9999), self.factory)
def setup(self, cfg): BasePlugin.setup(self, cfg) self.env = dict() self.intervals = ["year", "month", "day", "hour", "minute", "second"] self.schedules = dict() self.first_run = True lc = LoopingCall(self.process_schedules) lc.start(1.0)
def setup(self, cfg): BasePlugin.setup(self, cfg) self.client = XmppClient(self.cfg.get("username"), self.cfg.get("password"), self.cfg.get("server"), self.cfg.get("port")) self.factory = XmppFactory(plugin=self) self.factory.setHandlerParent(self.client)
def setup(self, cfg): BasePlugin.setup(self, cfg) self.device = self.cfg.get("device", "u") self.sensors = dict() ow.init(self.device) poll_task = LoopingCall(self.poll_bus) poll_task.start(self.cfg.get("poll_interval", 60))
def setup(self, cfg): BasePlugin.setup(self, cfg) self.factory = TivoFactory(plugin=self) self.factory.plugin = self self.client = TCPClient(self.cfg.get("host", "mytivo"), self.cfg.get("port", 31339), self.factory) self.cache = dict()
def setup(self, cfg): BasePlugin.setup(self, cfg) self.url = self.cfg.get("url", None) self.patterns = self.cfg.get("patterns", list()) if self.url is None: self.logger.debug("URL not specified.") return poll_task = LoopingCall(self.poll_url) poll_task.start(self.cfg.get("poll_interval", 60))
def setup(self, cfg): BasePlugin.setup(self, cfg) self.socket = socket(AF_INET, SOCK_DGRAM) self.protocol = ByeByeStandbyProtocol() self.protocol.plugin = self self.port = self.cfg.get("port_receive", 53007) self.blacklist = self.cfg.get("blacklist", []) reactor.listenUDP(self.port, self.protocol) self.subscribe(self.switch_device, ["c:byebyestandby", "i:switch"])
def setup(self, cfg): try: import spidermonkey except ImportError: return BasePlugin.setup(self, cfg) self.env = dict() self.scripts = dict() self.invalid_scripts = set() self.load_scripts() self.subscribe(self.process_event)
def setup(self, cfg): BasePlugin.setup(self, cfg) self.feed = self.cfg.get("feed", None) self.zones = self.cfg.get("zones", dict()) self.zone_state = dict() self.first_run = True if self.feed is None: self.logger.warn("No feed configured") return poll_task = LoopingCall(self.poll_feed) poll_task.start(self.cfg.get("poll_interval", 60))
def __init__(self, parent=None, settings=None): BasePlugin.__init__(self, parent) self.pathLabel = QtGui.QLabel(self.tr("Destination Path:")) self.pathComboBox = self.createComboBox() self.browseButton = self.createButton(self.tr("&Browse..."), self.browse) mainLayout = QtGui.QFormLayout() mainLayout.addWidget(self.pathLabel) mainLayout.addWidget(self.pathComboBox) mainLayout.addWidget(self.browseButton) self.setLayout(mainLayout) self.setWindowTitle(self.tr("Select destination path to unrar surce files to")) self.set_settings(settings)
def __init__(self, manager): BasePlugin.__init__(self, manager) self._spotify = SpotifyClient(config.SPOTIFY) self._intent_map = { 'play_genre': self._play_genre, 'play_artist': self._play_artist, 'play_playlist': self._play_playlist, 'play_album': self._play_album, 'play_track': self._play_track, 'speaker_list': self._get_speakers, 'pause_music': self._pause, 'resume_music': self._resume, 'skip_track': self._skip_track, 'volume': self._set_volume, 'currently_playing': self._currently_playing, 'playing_next': self._playing_next }
def __init__(self, parent=None, settings=None): BasePlugin.__init__(self, parent) self.output = None self.fileLabel = QtGui.QLabel(self.tr("Select Path:")) self.fileComboBox = self.createComboBox() # self.fileComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) self.fileComboBox.setFixedHeight(self.fileComboBox.minimumSizeHint().height()) self.fileComboBox.activated[str].connect(self.validatePath) self.browseButton = self.createButton(self.tr("&Browse..."), self.browse) mainLayout = QtGui.QFormLayout() mainLayout.addWidget(self.fileLabel) mainLayout.addWidget(self.fileComboBox) mainLayout.addWidget(self.browseButton) self.setLayout(mainLayout) self.setWindowTitle(self.tr("Select path")) self.set_settings(settings)
def setup(self, cfg): BasePlugin.setup(self, cfg) logging.getLogger("twittytwister").setLevel(logging.ERROR) logging.getLogger("HTTPPageDownloader").setLevel(logging.ERROR) self.consumer_key = self.cfg.get("consumer_key") self.consumer_secret = self.cfg.get("consumer_secret") self.access_token = self.cfg.get("access_token") self.access_token_secret = self.cfg.get("access_token_secret") self.timeline = self.cfg.get("timeline") self.consumer = oauth.OAuthConsumer(self.consumer_key, self.consumer_secret) self.token = oauth.OAuthToken(self.access_token, self.access_token_secret) self.tw = twitter.Twitter(consumer=self.consumer, token=self.token) poll_task = LoopingCall(self.poll_tweets) poll_task.start(self.cfg.get("poll_interval", 60))
def __init__(self, parent=None, settings=None): BasePlugin.__init__(self, parent) self.fileComboBox = self.createComboBox() self.textComboBox = self.createComboBox() self.sourcePath = QtGui.QLabel('') self.fileLabel = QtGui.QLabel(self.tr('Named:')) self.textLabel = QtGui.QLabel(self.tr('Containing text:')) mainLayout = QtGui.QFormLayout() mainLayout.addWidget(self.fileLabel) mainLayout.addWidget(self.fileComboBox) mainLayout.addWidget(self.textLabel) mainLayout.addWidget(self.textComboBox) self.setLayout(mainLayout) self.setWindowTitle(self.tr("Find Files")) if settings is None: # by default show a * in file combobox settings = {'fileComboBox': [self.tr("*")]} self.set_settings(settings)
def setup(self, cfg): BasePlugin.setup(self, cfg) self.data_root = os.path.join(os.path.dirname(__file__), "data", "web") app_cfg = self.service.cfg.get("app") mongo_server = app_cfg.get("general").get("mongo_server", "localhost") mongo_port = app_cfg.get("general").get("mongo_port", 27017) self.app = Flask(__name__, template_folder=os.path.join(self.data_root, "templates")) static = Static.File(os.path.join(self.data_root, "static")) static.processors = { ".py": script.PythonScript, ".rpy": script.ResourceScript } static.indexNames = ["index.rpy", "index.html", "index.htm"] root = Root(self) root.putChild("static", static) site = WebSocketSite(root) WebSocketProtocol.plugin = self site.addHandler("/ws", WebSocketProtocol) self.service.reactor.listenTCP(self.cfg.get("port", 8901), site) @self.app.route("/") def index(): return redirect("/admin/") @self.app.route("/reconfigure/") def reconfigure(): self.publish(["c:mhub", "i:reconfigure"]) return redirect("/") @self.app.route("/admin/") def admin(): ctx = self.context_processor() return render_template("admin/home.html", **ctx) @self.app.route("/admin/db/") def admin_db(): return redirect("/admin/db/list/") @self.app.route("/admin/db/list/") def admin_db_list(): ctx = self.context_processor() store_items = self.service.db_find("store", {}) ctx["store_items"] = list(store_items) return render_template("admin/db/list.html", **ctx) @self.app.route("/admin/db/edit/<item_id>", methods=["GET", "POST"]) def admin_db_edit(item_id): ctx = self.context_processor() item = self.service.db_find_one("store", item_id) form = _build_db_form(item) form.populate_obj(request.form) ctx["item"] = item ctx["form"] = form if request.method == "POST" and form.validate(): return redirect("/admin/db/list/") return render_template("admin/db/edit.html", **ctx) def _build_db_form(item): fields = dict() for k, v in item.iteritems(): fields[k] = TextField() form = BaseForm(fields=fields) return form
def setup(self, cfg): BasePlugin.setup(self, cfg) self.subscribe(self.process_event)
def setup(self, cfg): BasePlugin.setup(self, cfg) self.subscribe(self.process_event, "*.*.new_interval") self.subscribe(self.process_event, "scheduler.*.*")
def setup(self, cfg): BasePlugin.setup(self, cfg) self.account = self.cfg.get("account", dict())