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.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 = 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.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.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.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 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 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 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.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)
def setup(self, cfg): BasePlugin.setup(self, cfg) self.account = self.cfg.get("account", dict())
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, "*.*.new_interval") self.subscribe(self.process_event, "scheduler.*.*")