def clear(self): if os.path.isfile(self._config_path): os.remove(self._config_path) logger.info("Config cleaned: %s", self._config_path) host.message("Config cleaned") else: host.alert("Config not found")
def counting(self): logger.debug("Start: %s" % self.start) self.write() self.start = False logger.debug("Start: %s" % self.start) for guid_ip_dev, family in self.all_device_dict.copy().iteritems(): logger.debug("guid_ip_dev: %s, family: %s" % (guid_ip_dev, family)) if family not in self.license_dict: if self.license_dict.get("ANYFREE"): self.license_dict["ANYFREE"] -= 1 self.all_device_dict.pop(guid_ip_dev) continue if self.license_dict.get("HYBRID"): self.license_dict["HYBRID"] -= 1 self.all_device_dict.pop(guid_ip_dev) continue if self.license_dict.get("ANYIP"): self.license_dict["ANYIP"] -= 1 self.all_device_dict.pop(guid_ip_dev) continue for guid_ip_dev, family in self.all_device_dict.iteritems(): if family in self.license_dict: if self.license_dict[family] == 0: continue self.license_dict[family] -= 1 else: self.error_dict[guid_ip_dev] = family logger.debug("Start: %s" % self.start) self.write() host.message("Done!")
def save_shot(self): if not self.active_channel: host.alert(tr("Channel not selected!")) else: channel = get_channel(self.active_channel) if channel is not None: paths = self.saver.save_shots([channel]) host.message(tr("Saving shot to <br><b>%s</b>") % paths[0]) else: host.error("Can't find channel %s" % self.active_channel)
def execute(self, channel, ts, alarm_messages, *args, **kwargs): if not isinstance(alarm_messages, dict): logger.error("alarm_messages is not dict: %s", alarm_messages) return alarm_message = alarm_messages.get("alert_message") if not alarm_message: logger.error("alarm_messages hasn't 'alert_message key'") return host.message(alarm_messages["alert_message"], self.show_message_delay * 1000)
def change_rights_by_btn(): global last_user if not USERS: return if last_user == USER_GREEN: source = USER_RED else: source = USER_GREEN for user in USERS.split(','): ur.copy_user_rights(source, user) last_user = source host.message(source)
def restore_lost(): for device in host.settings("/{srv}/ip_cameras".format(srv=SERVER)).ls(): if device.type == "Grabber": for x in xrange(31): if device["channel%02d_guid" % x] == change_channel: host.message("Replace!") device["channel%02d_guid" % x] = changer_channel host.settings("/{}/channels/{}".format( changer_srv, changer_channel))["archive_zombie_flag"] = 0 host.settings("/{}/channels/{}".format( change_srv, change_channel))["archive_zombie_flag"] = 1 return host.error("Can't find channel to replace")
except KeyError: raise RuntimeError( "Не доступны настройки севрера, проверьте настройки дсотупа пользователя Script" ) for route in media_route.split(":"): if route.startswith("ip="): module_host = route[3:] break else: raise RuntimeError( "IP сервера %s не найден, возможно вы подключены к серверу через облако<br>" "media_route: %s" % (server.name, media_route)) try: gui = host.object("operatorgui_%s" % local_server.guid) host.message("%s laoded success" % gui.name) except EnvironmentError: raise EnvironmentError("OpertatorGUI is not available") def show_minibrowser(): gui.show( "minibrowser(0,htmltab(,http://{host}:{port}))".format( host=module_host, port=PORT), MONITOR, ) host.activate_on_shortcut(USER_FUNC, show_minibrowser)