if not CHANNEL: raise ValueError("Выберите канал привязки") change_channel, change_srv = CHANNEL.split("_") changer_channel, changer_srv = LOST_CHANNEL.split("[")[1][:-1].split("_") if change_srv != changer_srv: raise ValueError( "Канал привязки находится не на сервере привязываемой камеры!\nВыберите другой канал!" ) 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") host.activate_on_shortcut('F2', restore_lost)
<type>server</type> <name>Server</name> <value></value> </parameter> <parameter> <id>MODULE_LINK</id> <type>string</type> <name>Module</name> <value>FaceWorkTime</value> </parameter> </parameters> """ GLOBALS = globals() SERVER_GUID = GLOBALS.get("SERVER_GUID", "") MODULE_LINK = GLOBALS.get("MODULE_LINK", "FaceWorkTime") assert SERVER_GUID, "Server not selected" import host gui = host.object('operatorgui_%s' % host.settings('').guid) source = "%s_%s" % (host.stats().parent().guid, MODULE_LINK) link = "http://exthttp/{server_guid}/{module_link}".format( server_guid=SERVER_GUID, module_link=MODULE_LINK ) host.activate_on_shortcut("F1", lambda: gui.show_html(source, link))
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)
logger.info("Save shots by delay") saver.save_shots() host.timeout(delay, lambda: make_shots_loop(delay)) make_shots_loop(SSO_DELAY) if SSO_SCHEDULE: def color_change_handler(sched): if sched.color == "Red": saver.save_shots() schedule = ScheduleObject(SSO_SCHEDULE, color_change_handler=color_change_handler, tries=LOAD_SCHEDULE_TIMEOUT) if SSO_BUTTON_ALL: host.activate_on_shortcut(SSO_BUTTON_ALL, saver.save_shots) if SSO_BUTTON_ONE: class ActiveChannelHandler(object): def __init__(self, saver): self.saver = saver self.active_channel = "" def __call__(self, guid): logger.info("Focus Changed %s -> %s", self.active_channel, guid) self.active_channel = guid def save_shot(self): if not self.active_channel: host.alert(tr("Channel not selected!"))
assert OUTPUTS, host.tr("Необходимо выбрать тревожные выходы") _outputs = get_outputs(parse_object_names(OUTPUTS)) logger.debug("outputs objects found: %s", _outputs) output_reactions = OutputReactions( gpios=_outputs, delay=OUTPUT_DELAY, reaction_type=GLOBALS.get("OUTPUT_ACTION_TYPE"), delay_between_iterations=DELAY_BETWEEN_ITERATIONS, ) reactions.add_executor(output_reactions) if OUTPUT_MAN_ACTIV not in [host.tr("Нет"), host.tr("нет")]: logger.debug("Output manual activation key is %s", OUTPUT_MAN_ACTIV) host.activate_on_shortcut( OUTPUT_MAN_ACTIV, output_reactions.manual_activation_of_outputs) # ------------------------------------------------------- # Operations with physical system control ("СКУД") # ------------------------------------------------------- if ACS_ENBL: from reactions import AccessControlOperations assert ACS_TYPE in ["Sigur", "Orion"], "ACS_TYPE must be Sigur or Orion" assert ACS_DOOR, host.tr("Необходимо указать название точки доступа") acs_door_obj = host.object(ACS_DOOR)
] logger.debug(carousel_list) for x in [z[1] for z in host.objects_list("IP Device")]: if x in carousel_list: raise ValueError( host.tr("Имеется IP устройство с именем канала %s") % host.object(x).name ) logger.debug("list %s done!" % carousel_list) return {x: z for x, z in enumerate(carousel_list)} def user_login(ev): if ev.username == USER: slide.hand_using_carousel(False) slide = Carousel( initialization(), HAND_USING, ("show_%s" % choice_dict[CHOICE]).lower() ) if ALARM_TEMPLATE: for event_type in event.compil_event(): host.activate_on_events(event_type, "", slide.attention) host.activate_on_shortcut("F1", lambda: slide.hand_using_carousel(False)) host.activate_on_shortcut("F2", lambda: slide.hand_using_carousel(True)) host.activate_on_shortcut("F5", lambda: slide.hand_using_go("up")) host.activate_on_shortcut("F6", lambda: slide.hand_using_go("down")) host.activate_on_gui_event("Focus Changed", slide.mous_handler) if USER: host.activate_on_events("Login Successful, %1 from %2", "", user_login)
def gpio_handler(ev): global last_user if not USERS: return if ev.origin_object.name == INPUT_OBJECT: if ev.type == "Input Low to High": source = USER_RED else: source = USER_GREEN for user in USERS.split(','): ur.copy_user_rights(source, user) """ Activate """ if SAVE_BASE_REPORT: save_base_rights() if SAVE_ACL_REPORT: save_acl_rights() if USERS: check_params() if WORK_MODE == "Расписание": schedule = ScheduleObject(INPUT_OBJECT, color_change_handler=change_rights) change_rights(schedule) elif WORK_MODE == "Тревожный вход": if not INPUT_OBJECT: raise ValueError("GPIO input not selected") for event in ["Input Low to High", "Input High to Low"]: host.activate_on_events(event, "", gpio_handler) if BTN: host.activate_on_shortcut(BTN, change_rights_by_btn)