Python npyscreen.notify_wait() Examples

The following are 19 code examples of npyscreen.notify_wait(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module npyscreen , or try the search function .
Example #1
Source File: agent_config_selector.py    From dynamite-nsm with GNU General Public License v3.0 6 votes vote down vote up
def actionHighlighted(self, act_on_this, keypress):
        zeek_installed, suricata_installed, filebeat_installed = zeek_profile.ProcessProfiler().is_installed, \
                                                                 suricata_profile.ProcessProfiler().is_installed, \
                                                                 filebeat_profile.ProcessProfiler().is_installed
        app_mapping = {}
        if filebeat_installed:
            if zeek_installed and suricata_installed:
                app_mapping = zeek_and_suricata_mapping
            elif zeek_installed:
                app_mapping = zeek_only_mapping
            elif suricata_installed:
                app_mapping = suricata_only_mapping

        npyscreen.notify_wait(
            act_on_this, form_color='GOODHL'
        )
        app_mapping[act_on_this]().run()
        exit(0) 
Example #2
Source File: results.py    From pi_romulus with GNU General Public License v2.0 6 votes vote down vote up
def afterEditing(self):
        selected_option = self.parentApp.SELECTED_RESULT
        try:
            selection = self.parentApp.RESULTS.get(selected_option)
            if not selection:
                npyscreen.notify_wait("Please select a ROM by hitting ENTER on your selection", "Selection error")
            self.search = self.parentApp.SCRAPER_OBJ
            download_thread = ThreadDownload(selection=selection)
            download_thread.start()
            # self.download_link = self.search.get_link(selection)
            while download_thread.is_alive():
                npyscreen.notify("Please wait while Romulus downloads this ROM...", "Downloading")
            # self.d = Download()
            # self.d.download(self.download_link, platform=selection.system)
            npyscreen.notify("The ROM is now available on EmulationStation", "Success")
            self.parentApp.setNextForm('MAIN')
        except TypeError:
            npyscreen.notify_wait('Please hit ENTER on your selection to select it', 'Error') 
Example #3
Source File: filebeat_interface_config.py    From dynamite-nsm with GNU General Public License v3.0 6 votes vote down vote up
def whenPressed(self):

        if self.parent.parentApp.filebeat_config.is_kafka_output_enabled():
            self.parent.parentApp.filebeat_config.enable_logstash_output()
            output_type = 'LogStash'
        else:
            self.parent.parentApp.filebeat_config.enable_kafka_output()
            output_type = 'Kafka'

        npyscreen.notify_wait(
            'Enabling {} output mode.'.format(output_type), form_color='GOODHL'
        )
        self.parent.parentApp.filebeat_config.write_config()

        self.parent.parentApp.removeForm('MAIN')
        self.parent.parentApp.addForm('MAIN', FilebeatInstanceSettingsForm, name='FileBeat Configuration')
        self.parent.parentApp.removeForm('EDITTARGETFM')
        self.parent.parentApp.addForm('EDITTARGETFM', EditTargetsForm, name='Edit FileBeat Targets')
        self.parent.parentApp.switchForm('MAIN') 
Example #4
Source File: suricata_rule_config.py    From dynamite-nsm with GNU General Public License v3.0 5 votes vote down vote up
def on_ok(self):
        npyscreen.notify_wait(
            'Be sure to restart the agent for changes to take effect!', form_color='WARNING'
        )
        for rule in self.rendered_rules:
            if rule.value:
                self.parentApp.suricata_rule_config.enable_rule(rule.name)
            else:
                self.parentApp.suricata_rule_config.disable_rule(rule.name)

        self.parentApp.suricata_rule_config.write_config()
        self.parentApp.setNextForm(None) 
Example #5
Source File: tui.py    From community-edition-setup with MIT License 5 votes vote down vote up
def onCleanExit(self):
        if self.do_notify:
            npyscreen.notify_wait("setup.py will exit in a moment. " + self.exit_reason, title="Warning!") 
Example #6
Source File: stdfmemail.py    From EDCOP with Apache License 2.0 5 votes vote down vote up
def h_save_message_part(self, ch):
        self.parent.saveMessagePart()
        npyscreen.notify_wait("Message part saved to your downloads folder: \n %s" % self.parent.DOWNLOAD_DIR) 
Example #7
Source File: stdfmemail.py    From EDCOP with Apache License 2.0 5 votes vote down vote up
def h_save_message_part(self, ch):
        self.parent.saveMessagePart()
        npyscreen.notify_wait("Message part saved to your downloads folder: \n %s" % self.parent.DOWNLOAD_DIR) 
Example #8
Source File: __init__.py    From signal-curses with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        log('message thread')

        if self.app.state.bus == 'system':
            self.bus = pydbus.SystemBus()
        else:
            self.bus = pydbus.SessionBus()

        log('waiting for ({}) dbus...'.format(self.app.state.bus))
        self.signal = exception_waitloop(self.get_message_bus, GLib.Error, 60)
        if not self.signal:
            log('dbus err')
            npyscreen.notify_wait('Unable to get signal {} bus. Messaging functionality will not function.'.format(
                self.app.state.bus), title='Error in SignalDaemonThread')
            exit(1)
        log('got dbus')
        # self.signal.onMessageReceived

        while True:
            item = self.queue.get()
            log('queue item', item)
            if 'exit' in item:
                break
            self.do_action(**item)
            self.queue.task_done()
        log('message thread exit') 
Example #9
Source File: forms.py    From signal-curses with GNU General Public License v3.0 5 votes vote down vote up
def getQR(self):
        if not self.parentApp.setup.showingToken:
            return
        while self.parentApp.setup.token is None:
            npyscreen.notify_wait(
                "Waiting for token...\n\nOpen Signal > Settings > Linked Devices > Add and scan the QR code.", title="Setup")
            time.sleep(0.1)
        if not self.parentApp.setup.token.startswith('tsdevice:'):
            npyscreen.notify_confirm(
            "There was not a valid registration token returned from signal-cli\n\nReturned token: {}".format(self.parentApp.setup.token), title="Setup")
            exit(0)
        return pyqrcode.create(self.parentApp.setup.token, error='L').terminal(quiet_zone=1) 
Example #10
Source File: backup.py    From vent with Apache License 2.0 5 votes vote down vote up
def on_ok(self):
        """ Perform restoration on the backup file selected """
        if self.dir_select.value:
            npyscreen.notify_wait('In the process of restoring',
                                  title='Restoring...')
            status = self.restore(self.dirs[self.dir_select.value[0]])
            if status[0]:
                npyscreen.notify_confirm('Status of restore:\n' +
                                         status[1])
            else:
                npyscreen.notify_confirm(status[1])
            self.quit()
        else:
            npyscreen.notify_confirm('Choose a version to restore from') 
Example #11
Source File: zeek_node_config.py    From dynamite-nsm with GNU General Public License v3.0 5 votes vote down vote up
def on_ok(self):
        npyscreen.notify_wait(
            'Be sure to restart the agent for changes to take effect!', form_color='WARNING'
        )
        self.parentApp.setNextForm(None) 
Example #12
Source File: suricata_interface_config.py    From dynamite-nsm with GNU General Public License v3.0 5 votes vote down vote up
def on_ok(self):
        try:
            if self.threads_text.value == '':
                self.threads_text.value = 'auto'
            int(self.threads_text.value)
        except ValueError:
            if self.threads_text.value != 'auto':
                npyscreen.notify_ok_cancel(
                    'Worker Threads must be given as an integer.',
                    form_color='DANGER'
                )
                return
        if not self.net_interface_text.value:
            npyscreen.notify_ok_cancel(
                'Network Interface cannot be blank.',
                form_color='DANGER'
            )
            return
        if self.value:
            self.parentApp.suricata_config.remove_afpacket_interface(self.value)
        self.parentApp.suricata_config.add_afpacket_interface(
            interface=self.net_interface_text.value,
            threads=self.threads_text.value,
            cluster_id=self.cluster_id.value,
            bpf_filter=self.bpf_filter.value
        )

        # Switch back to the main interface
        npyscreen.notify_wait(
            self.net_interface_text.value + ' has been updated!', form_color='GOOD'
        )
        self.parentApp.suricata_config.write_config()
        self.parentApp.removeForm('MAIN')
        self.parentApp.addForm('MAIN', SuricataInstanceSettingsForm, name='Suricata Instance Configuration')
        self.parentApp.switchForm('MAIN') 
Example #13
Source File: zeek_script_config.py    From dynamite-nsm with GNU General Public License v3.0 5 votes vote down vote up
def on_ok(self):
        npyscreen.notify_wait(
            'Be sure to restart the agent for changes to take effect!', form_color='WARNING'
        )
        for script in self.rendered_scripts:
            if script.value:
                self.parentApp.zeek_script_config.enable_script(script.name)
            else:
                self.parentApp.zeek_script_config.disable_script(script.name)

        self.parentApp.zeek_script_config.write_config()
        self.parentApp.setNextForm(None) 
Example #14
Source File: filebeat_interface_config.py    From dynamite-nsm with GNU General Public License v3.0 5 votes vote down vote up
def on_ok(self):
        kafka_enabled = self.parentApp.filebeat_config.is_kafka_output_enabled()
        if not InstallManager.validate_targets(targets=[self.target_text.value]):
            npyscreen.notify_ok_cancel(
                'Target must be given in the format: host:port (E.G 192.168.0.100:5044)',
                form_color='DANGER'
            )
            return
        if kafka_enabled:
            kafka_config = self.parentApp.filebeat_config.get_kafka_target_config()
            original_targets = list(kafka_config.get('hosts', []))

        else:
            original_targets = list(self.parentApp.filebeat_config.get_logstash_target_hosts())
        if self.value:
            edit_target_index = original_targets.index(self.value)
            original_targets[edit_target_index] = self.target_text.value
            npyscreen.notify_wait(
                self.target_text.value + ' has been updated!', form_color='GOOD'
            )
        else:
            original_targets.append(self.target_text.value)
            npyscreen.notify_wait(
                self.target_text.value + ' has been created!', form_color='GOOD'
            )
        if kafka_enabled:
            username, password = self.username_text.value, self.password_text.value
            if self.username_text.value.strip() == '':
                username = None
            if self.password_text.value.strip() == '':
                password = None
            self.parentApp.filebeat_config.set_kafka_targets(original_targets, topic=self.topic_text.value,
                                                             username=username, password=password)
        else:
            self.parentApp.filebeat_config.set_logstash_targets(original_targets)
        # Switch back to the main interface

        self.parentApp.filebeat_config.write_config()
        self.parentApp.removeForm('MAIN')
        self.parentApp.addForm('MAIN', FilebeatInstanceSettingsForm, name='FileBeat Configuration')
        self.parentApp.switchForm('MAIN') 
Example #15
Source File: filebeat_interface_config.py    From dynamite-nsm with GNU General Public License v3.0 5 votes vote down vote up
def on_ok(self):
        try:
            self.parentApp.filebeat_config.set_agent_tag(self.agent_tag.value)
            self.parentApp.filebeat_config.write_config()
        except exceptions.InvalidAgentTag as e:
            res = npyscreen.notify_ok_cancel(
                e.message,
                form_color='DANGER',
            )
            if not res:
                return
        npyscreen.notify_wait(
            'Be sure to restart the agent for changes to take effect!', form_color='WARNING'
        )
        self.parentApp.setNextForm(None) 
Example #16
Source File: zeek_node_config.py    From dynamite-nsm with GNU General Public License v3.0 4 votes vote down vote up
def on_ok(self):
        if not self.host_text.value:
            npyscreen.notify_ok_cancel(
                'Host name cannot be blank.',
                form_color='DANGER'
            )
            return
        if not self.component_name_text.value:
            npyscreen.notify_ok_cancel(
                '{} name cannot be blank.'.format(self.component_type.capitalize()),
                form_color='DANGER'
            )
            return
        if self.value:
            if self.component_type == 'logger':
                self.parentApp.zeek_config.remove_logger(self.value)
            if self.component_type == 'proxy':
                self.parentApp.zeek_config.remove_proxy(self.value)
            elif self.component_type == 'manager':
                self.parentApp.zeek_config.remove_manager(self.value)
                self.parentApp.zeek_config.add_manager(
                    name=self.component_name_text.value,
                    host=self.host_text.value,
                )
        if self.component_type == 'logger':
            self.parentApp.zeek_config.add_logger(
                name=self.component_name_text.value,
                host=self.host_text.value,
            )
        elif self.component_type == 'proxy':
            self.parentApp.zeek_config.add_proxy(
                name=self.component_name_text.value,
                host=self.host_text.value,
            )

        # Switch back to the main interface
        self.parentApp.zeek_config.write_config()
        npyscreen.notify_wait(
            self.component_name_text.value + ' has been updated!', form_color='GOOD'
        )
        self.parentApp.removeForm('MAIN')
        self.parentApp.addForm('MAIN', ZeekNodeSettingsForm, name='Zeek Node Configuration')
        self.parentApp.switchForm('MAIN') 
Example #17
Source File: zeek_node_config.py    From dynamite-nsm with GNU General Public License v3.0 4 votes vote down vote up
def on_ok(self):
        pin_cpus = []
        for cpu in self.cpus_text.value.split(','):
            try:
                pin_cpus.append(int(cpu.strip()))
            except ValueError:
                npyscreen.notify_ok_cancel(
                    'CPU Affinity must be given as a list of integers separated by commas.',
                    form_color='DANGER'
                )
                return
        try:
            int(self.threads_text.value)
        except ValueError:
            npyscreen.notify_ok_cancel(
                'Worker Threads must be given as an integer.',
                form_color='DANGER'
            )
            return
        if not self.net_interface_text.value:
            npyscreen.notify_ok_cancel(
                'Network Interface cannot be blank.',
                form_color='DANGER'
            )
            return
        if not self.worker_name_text.value:
            npyscreen.notify_ok_cancel(
                'Worker name cannot be blank.',
                form_color='DANGER'
            )
            return
        if not self.host_text.value:
            npyscreen.notify_ok_cancel(
                'Host name cannot be blank.',
                form_color='DANGER'
            )
            return
        if self.value:
            self.parentApp.zeek_config.remove_worker(self.value)
        self.parentApp.zeek_config.add_worker(
            name=self.worker_name_text.value,
            interface=self.net_interface_text.value,
            host=self.host_text.value,
            lb_procs=self.threads_text.value,
            pin_cpus=tuple(pin_cpus)
        )

        # Switch back to the main interface
        npyscreen.notify_wait(
            self.worker_name_text.value + ' has been updated!', form_color='GOOD'
        )
        self.parentApp.zeek_config.write_config()
        self.parentApp.removeForm('MAIN')
        self.parentApp.addForm('MAIN', ZeekNodeSettingsForm, name='Zeek Node Configuration')
        self.parentApp.switchForm('MAIN') 
Example #18
Source File: choose_tools.py    From vent with Apache License 2.0 4 votes vote down vote up
def on_ok(self):
        """
        Take the tool selections and add them as plugins
        """
        def diff(first, second):
            """
            Get the elements that exist in the first list and not in the second
            """
            second = set(second)
            return [item for item in first if item not in second]

        def popup(original_tools, branch, thr, title):
            """
            Start the thread and display a popup of the tools being added until
            the thread is finished
            """
            thr.start()
            tool_str = 'Adding tools...'
            npyscreen.notify_wait(tool_str, title=title)
            while thr.is_alive():
                tools = diff(ManifestTools(), original_tools)
                if tools:
                    tool_str = ''
                for tool in tools:
                    pre_tool = 'Added: ' + branch + '/' + tool + '\n'
                    tool_str = pre_tool + tool_str
                npyscreen.notify_wait(tool_str, title=title)
                time.sleep(1)
            return

        original_tools = ManifestTools()
        for branch in self.tools_tc:
            tools = []
            for tool in self.tools_tc[branch]:
                if self.tools_tc[branch][tool].value:
                    # get rid of temporary show for multiple tools in same
                    # directory
                    if tool == '/':
                        tools.append(('.', ''))
                    else:
                        tools.append((tool, ''))
            repo = self.parentApp.repo_value['repo']
            version = self.parentApp.repo_value['versions'][branch]
            api_action = Tools(version=version, branch=branch)
            thr = threading.Thread(target=api_action.new, args=(),
                                   kwargs={'tool_type': 'repo',
                                           'uri': repo,
                                           'tools': tools})
            popup(original_tools, branch, thr,
                  'Please wait, adding tools for the ' + branch + ' branch...')
        npyscreen.notify_confirm('Done adding repository: ' +
                                 self.parentApp.repo_value['repo'],
                                 title='Added Repository')
        self.quit() 
Example #19
Source File: __init__.py    From signal-curses with GNU General Public License v3.0 4 votes vote down vote up
def handleEnvelope(self, env):
        self.envelopes.append(env)

        if env.timestamp and (time.time() - env.epoch_ts) >= 60:
            log('ignoring envelope due to time difference of',
                str((time.time() - env.epoch_ts)))
            return

        if env.dataMessage.is_message():
            if self.state.shouldDisplayEnvelope(env):
                self.addEnvelope(env)
            elif self.state.shouldNotifyEnvelope(env):
                log('notifying line')
                gen_line = env.gen_line()
                txt = '{}:\n\n{}'.format(gen_line[0], gen_line[2])
                if env.group:
                    txt = 'Group: {}\n'.format(json.dumps(env.group)) + txt
                npyscreen.notify_wait(
                    txt, title='New Message from {}'.format(gen_line[1]))
            else:
                log('not displaying or notifying dataMessage')

        if env.syncMessage.is_read_message():
            log('is read message', env.syncMessage)
            for e in self.envelopes[:-1]:
                if env.syncMessage.sync_read_matches(e):
                    log('mark_read', e)
                    self.markAsEnvelope(e, '(read)')

        if env.callMessage.is_offer():
            self.app.wMain.addValues([
                ('*', 'You are receiving an inbound call from {}'.format(env.source))
            ])
            npyscreen.notify_wait(
                'You are receiving an inbound call', title='Call from {}'.format(env.source))

        if env.callMessage.is_busy():
            self.app.wMain.addValues([
                ('*', 'The caller {} is busy'.format(env.source))
            ])
            npyscreen.notify_wait('The caller is busy',
                                  title='Call from {}'.format(env.source))

        if env.callMessage.is_hangup():
            self.app.wMain.addValues([
                ('*', 'The caller {} hung up'.format(env.source))
            ])
            npyscreen.notify_wait('The caller hung up',
                                  title='Call from {}'.format(env.source))