def activate(self): self.edit() self.parentApp.setNextForm(None) def while_waiting(self): for service in yml_content['services']: current_service = self.SERVICES.get(service['name']) try: resp = requests.get(service['url']) if resp.status_code == 200: current_service.value = '[OK]' except RequestException as e: current_service.value = '[FAILED]' current_service.display() def create(self): self.SERVICES = {} for service in yml_content['services']: self.SERVICES.update({service['name']: self.add(npyscreen.TitleText, name=service['name'], value="Not started", editable=False)}) class MonitoringTUI(npyscreen.NPSAppManaged): def onStart(self): self.keypress_timeout_default = 10 self.addForm("MAIN", MainWidgetTUI, name="Monitoring TUI") if __name__ == "__main__": npyscreen.wrapper(MonitoringTUI().run())
self.showHost = self.add(npyscreen.TitleFixedText, editable=False, value='not updating') self.SniffType = self.add(npyscreen.TitleFixedText, editable=False, hidden=True) self.captureDevice = self.add(npyscreen.TitleFixedText, editable=False, hidden=True) self.SavePacket = self.add(npyscreen.Textfield, editable=False, hidden=True) self.Packet = self.add(npyscreen.Textfield, editable=False, hidden=True, value=self.SavePacket.value) def afterEditing(self): t = Thread(target=self.start_Sniff) t.start() def while_waiting(self): Timer(1.0, self.update_count()) def update_count(self): self.packetCount.value = str(Eavesdrop.pktCount) self.packetCount.update() self.showHost.value = str(Eavesdrop.host_count) self.showHost.update() self.showMalformed.value = str(Eavesdrop.malcount) self.showMalformed.update() def on_cancel(self): self.parentApp.switchForm(None) sys.exit() if __name__ == '__main__': npyscreen.wrapper(EavesdropApp().run())
if self.parentApp.current_point not in self.parentApp.data_dict.keys(): self.parentApp.data_dict[str(self.parentApp.current_point)] = {} self.parentApp.data_dict[str(self.parentApp.current_point)] = { 'timestamp': str(datetime.datetime.now().strftime("%Y/%m/%d.%H:%M:%S")), 'mag_data': point_data } self.logger.debug('self.parentApp.data_dict:{}'.format( self.parentApp.data_dict)) with open(self.parentApp.filename, 'w') as f: json.dump(self.parentApp.data_dict, f) self.load_current_point_data() def while_waiting(self): self.scrollBoxRawData.entry_widget.buffer( [" ".join(["{:.2f}".format(i) for i in self.mag.get_values()])]) self.scrollBoxRawData.display() def exit_application(self, optional=0): self.logger.debug('Exiting application code:{}'.format(optional)) self.mag.stop() exit(0) if __name__ == "__main__": npyscreen.wrapper(ManagerTUI().run())
toResult.Mcc.value= Mcc toResult.Yi.value= Yi self.parentApp.switchForm("RESULT") class Result(npyscreen.Form): def activate(self): self.edit() self.parentApp.setNextForm(None) def create(self): self.TP = self.add(npyscreen.TitleFixedText, name='True Positives:') self.TN = self.add(npyscreen.TitleFixedText, name='True Negatives:') self.FP = self.add(npyscreen.TitleFixedText, name='False Positives:') self.FN = self.add(npyscreen.TitleFixedText, name='False Negatives:') self.Ac = self.add(npyscreen.TitleFixedText, name='Accuracy:') self.Sp = self.add(npyscreen.TitleFixedText, name='Specificity:') self.Se = self.add(npyscreen.TitleFixedText, name='Sensitivity:') self.Pr = self.add(npyscreen.TitleFixedText, name='Precision:') self.Fm = self.add(npyscreen.TitleFixedText, name='F1-score:') self.Mcc = self.add(npyscreen.TitleFixedText,name='Matthews correlation coefficient:') self.Yi = self.add(npyscreen.TitleFixedText, name='Youden Index') if __name__ == "__main__": npyscreen.wrapper(TUI().run())
#------------------------------------------------------------------------------------------- ms = F.add(npyscreen.TitleSelectOne, max_height=4, value=[ 1, ], name="Pick One", values=["Option1", "Option2", "Option3"], scroll_exit=True) ms2 = F.add(npyscreen.TitleMultiSelect, max_height=-2, value=[ 1, ], name="Pick Several", values=["Option1", "Option2", "Option3"], scroll_exit=True) # This lets the user interact with the Form. F.edit() print(ms.get_selected_objects()) def getArgument(self): return argument if __name__ == "__main__": npyscreen.wrapper(ExampleTUI().run())
self.parentApp.switchForm("changeFolder") def cDate(self): toLog("Switching to changeDate form") self.parentApp.switchForm("changeDate") def changeColorP(self): toLog("Switching to theme picker form.") self.parentApp.switchForm("changeTheme") try: if __name__ == "__main__": npyscreen.wrapper(AppOne().run()) except KeyboardInterrupt: toLog("Keyboard Interrupt") with open(home + "/.DYGIdep/lastfolders.txt", "w") as lastfolders: with open(home +"/.DYGIdep/folders.txt", "r") as x: for l in x.readlines(): lastfolders.writelines(l) #print "File deleted." toLog("Copied new folders.") x.close() ''' with open(home +"/.DYGIdep/folders.txt", "w") as x: x.write(str("")) x.close()
import npyscreen class MyTestApp(npyscreen.NPSAppManaged): def onStart(self): self.addFormClass("MAIN", MainForm) class MainForm(npyscreen.FileSelector): pass def main(): TA = MyTestApp() TA.run() def test_function(scr): t = npyscreen.selectFile('~/',) npyscreen.notify_confirm(title='Selected File', message=t) if __name__ == '__main__': #main() print(npyscreen.wrapper(test_function))
import npyscreen class MyTestApp(npyscreen.NPSAppManaged): def onStart(self): self.addFormClass("MAIN", MainForm) class MainForm(npyscreen.FileSelector): pass def main(): TA = MyTestApp() TA.run() def test_function(scr): t = npyscreen.selectFile('~/', ) npyscreen.notify_confirm(title='Selected File', message=t) if __name__ == '__main__': #main() print(npyscreen.wrapper(test_function))
from s3holmes import S3Holmes import npyscreen if __name__ == "__main__": # Init the main class npyscreen.wrapper(S3Holmes().run())