def on_ok(self): self.deb['p_name'] = self.p_name.get_value() self.deb['p_version'] = self.p_version.get_value() self.deb['p_arch'] = self.archs[self.p_arch.get_value()[0]] self.deb['m_name'] = self.m_name.get_value() self.deb['m_mail'] = self.m_mail.get_value() self.deb['source_format'] = self.formats[ self.source_format.get_value()[0]] self.deb['release'] = self.releases[self.release.get_value()[0]] os.mkdir('debian') os.mkdir('debian/source') self.debianize() with open('debian/source/format', 'w') as f: mako = os.path.join(self.tmpl_dir, 'format.mako') f.write(template(mako, self.deb)) copyfile('COPYING', 'debian/copyright') with open('debian/compat', 'w') as f: f.write('9') if self.hint: notify(self.hint, title='Hint') sleep(10) sys.exit(0)
def c_update_all(self, *args, **keywords): npyscreen.notify("Updating all feeds...", title = 'Status') with session_scope() as session: updates = md.update_all_feeds(session) npyscreen.notify("{} updates applied.".format(updates), title = 'Status') time.sleep(0.75) self.c_show_feeds()
def trigger_receiver(self): try: self.TG.receiver.start() self.TG.receiver.message(self.message_loop()) except TypeError: npyscreen.notify("Sorry, An error occurred please restart the app :(") self.on_ok(direct=True)
def check_version(self, **keywords): if not self.version_checked: loop = keywords.get('loop') result = loop.run_until_complete(check_version()) if not result: npyscreen.notify("New version released please check.") self.version_checked = True
def beforeEditing(self): if self.value: self.preexisting_item = True record = self.parentApp.application_logic.query_item_by_uuid( self.value) self.name = record.item_uuid self.wg_last_modified.value = record.last_modified self.wg_uuid.value = record.item_uuid self.wg_description.value = record.description try: associated_box_value = self.parentApp.application_logic.query_boxids( ).index(record.in_box) except ValueError: npyscreen.notify( message= "It looks like the box this item as associated with has been deleted. " "No worries, though - the box assignment of this item has now been zeroed.", title="Data integrity error", form_color="STANDOUT") associated_box_value = "" self.wg_in_box.value = associated_box_value else: self.preexisting_item = False self.name = "New item" self.wg_uuid.value = generate_UUID("item") self.wg_description.value = "" self.wg_in_box.value = "" self.wg_last_modified.value = "Just now" self.wg_in_box.values = self.parentApp.application_logic.query_boxids()
def beforeEditing(self): if self.value: self.preexisting_item=True record = self.parentApp.application_logic.query_item_by_uuid(self.value) self.name = record.item_uuid self.wg_last_modified.value = record.last_modified self.wg_uuid.value = record.item_uuid self.wg_description.value = record.description try: associated_box_value = self.parentApp.application_logic.query_boxids().index(record.in_box) except ValueError: npyscreen.notify(message="It looks like the box this item as associated with has been deleted. " "No worries, though - the box assignment of this item has now been zeroed.", title="Data integrity error", form_color="STANDOUT") associated_box_value = "" self.wg_in_box.value = associated_box_value else: self.preexisting_item=False self.name = "New item" self.wg_uuid.value = generate_UUID("item") self.wg_description.value = "" self.wg_in_box.value = "" self.wg_last_modified.value = "Just now" self.wg_in_box.values = self.parentApp.application_logic.query_boxids()
def afterEditing(self): try: product = self.mem.data.products.arr[self.cmbProducts.value[0]] except: product = None try: amount = Decimal(self.txtAmount.value) except: amount = None try: user = self.mem.data.users.arr[self.cmbUsers.value[0]] except: user = None self.parentApp.log.append([product, amount, user]) if product == None or user == None or amount == None: self.edit() return self.parentApp.setNextForm(None) self.editing = False self.parentApp.object = Meal(self.mem, datetime.now(), product, amount, user, product.system_product, None) self.parentApp.object.save() self.mem.con.commit() notify("Meal added") sleep(2)
def while_editing(self, current_widget): if (self.search_text != self.search or self.selected_resolution != self.resolution): notify("Getting episodes", title="Busy") self.search_text = self.search self.selected_resolution = self.resolution self.episodes = fetch_episodes(self.search_text, self.resolution)
def c_update_all(self, *args, **keywords): npyscreen.notify("Updating all feeds...", title='Status') with session_scope() as session: updates = md.update_all_feeds(session) npyscreen.notify("{} updates applied.".format(updates), title='Status') time.sleep(0.75) self.c_show_feeds()
def onSubmitPressed(self): if not self.__validateFields(): self.__displayConfirmation('One or more Input Fields missing', 'VALIDATION ERROR') return npyscreen.notify('Loading Data, Please Wait', title='In Progress') shotcharts = self.api.getData(self.player.value, Output(self.fileTypePicker.value[0])) self.writeData(shotcharts) self.display()
def on_ok(self): """ Carried out when OK button is pressed """ npyscreen.notify("Please wait", "Searching...") self.search = Scraper(self.rom.value, parent=self) self.results = clean_results_list(self.search.fill_in_form()) self.clean_results = self.results[0] self.parentApp.SCRAPER_OBJ = self.search self.parentApp.CLEAN_RESULTS = self.clean_results self.parentApp.RESULTS = self.results[1]
def track_object(self, *args, **keywords): if self.selected_object == None: #Sanity Check return self.parentApp.set_tracked_object( trackable_object=self.selected_object, trackable_object_key=self.w_object_selection.values[ self.w_object_selection.value], trackable_object_type=self.api_type) npyscreen.notify("Now Tracking {}".format(self.selected_object.name), title="Object Selected") time.sleep(1)
def on_ok(self, *args, **keywords): npyscreen.notify("Adding new feed...", title = "Status") with session_scope() as session: feed_id = md.add_feed(session, self.feedurl.value) if feed_id == -1: npyscreen.notify_ok_cancel("Failed to add feed.", title = "Error") else: md.update_feeditems(session, feed_id) npyscreen.notify('Feed added!') time.sleep(0.75) self.parentApp.switchFormPrevious()
def on_ok(self): selectedFolder = self.folderList.values[self.folderList.value[0]] #global foldername foldername = selectedFolder foldername = foldername.replace("\n", "").replace("'", '"') toLog("Changing Folders...") with open(home + ".DYGIdep/currentFolder.txt", "w") as f: f.write(str(foldername)) toLog("Writing data to currentFolder.txt") server.login(gmail.value, gmailpass.value) with open(home + "/.DYGIdep/currentFolder.txt", "r") as f: toLog("Reading data from currentFolder.txt") foldername = f.read() # print foldername with open(home + "/.DYGIdep/DEBUG.txt", "w") as fd: foldername = foldername.replace("\n", "").replace("'", '"') stat, cnt = conn.select(foldername) #fd.write(foldername) fd.close() with open(home + "/.DYGIdep/Date.txt", "r") as f: dateback = f.read() f.close() with open(home+ "/.DYGIdep/emailNum.txt", "r") as f: numberOfEmails = int(f.read()) f.close() rv, data = conn.search(None, "(SINCE \""+ str(dateback) +"\")") count = 0 npyscreen.notify("Changing Folders. This may take a while depending on how many emails are in the folder...", title="Changing Folders") with open(home +"/.DYGIdep/email.txt", "w") as f: with open(home +"/.DYGIdep/ID.txt", "w") as ids: for num in data[0].split(): count += 1 rv, data = conn.fetch(num, '(RFC822)') msg = email.message_from_string(data[0][1]) dta = "[" + str(num) + "]" + msg['From'].replace("\n", "") + "\n" IDoMessage = msg['message-id'] ids.write(IDoMessage + "\n") #stat, dta = conn.fetch(cnt[0], '(BODY[HEADER.FIELDS (FROM)])') f.write(dta) if count >= numberOfEmails: break ids.close() f.close() # (retcode, messages) = conn.search(None, '(UNSEEN)') server.login(gmail.value, gmailpass.value) toLog("Folder changed.") toSend = self.parentApp.getForm("Inbox") self.parentApp.switchForm("Inbox") self.parentApp.setNextFormPrevious("SendMail") pass
def on_ok(self, *args, **keywords): npyscreen.notify("Adding new feed...", title="Status") with session_scope() as session: feed_id = md.add_feed(session, self.feedurl.value) if feed_id == -1: npyscreen.notify_ok_cancel("Failed to add feed.", title="Error") else: md.update_feeditems(session, feed_id) npyscreen.notify('Feed added!') time.sleep(0.75) self.parentApp.switchFormPrevious()
def afterEditing(self): selected_option = self.parentApp.SELECTED_RESULT try: selection = self.parentApp.RESULTS[selected_option] self.search = self.parentApp.SCRAPER_OBJ self.download_link = self.search.get_link(selection) npyscreen.notify("Please wait while Romulus downloads this ROM...", "Downloading") self.d = Download(self.search) self.d.download(self.download_link) 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')
def onStart(self): #npyscreen.setTheme(npyscreen.Themes.TransparentThemeDarkText) npyscreen.notify("""Aeromanger 1.0 2014/ by zerodine GmbH""") self.repository = Repository() self.addForm("MAIN", FlightplanListDisplay, name="Available Flightplans") self.addForm("FLIGHTPLAN", FlightplanForm, name="Flightplan Editor") self.addForm("PERFORMANCE_TAKEOFF", TakeoffForm, name="Takeoff Performance") self.addForm("AERODROME", AerodromeForm, name="Aerodrome") self.addForm("AIRPLANE", AirplaneForm, name="Airplane") self.addForm("AIRPLANECHART", AirplaneChartForm, name="Airplane") self.addForm("PERFORMANCE_WEIGHTBALANCE", WeightbalanceForm, name="Weight and Balance")
def on_ok(self): npyscreen.notify("Logging in..", title="Please Wait") self.get_emails() email_list = [] for c, i in enumerate(self.emails): single_rec = "{count: <{width}}- {subject:80.74} {from_addr}".format( count=c + 1, width=3, subject=i['subject'], from_addr=i['from']) email_list.append(single_rec) self.parentApp.email_list_form.email_list.values = email_list self.parentApp.switchForm('EMAIL_LIST')
def spawn_notify_popup(self, key_press): message_to_display = 'Now loading bulb...' npyscreen.notify(message_to_display, title='Loading') init_success = bulb_manager.init_bulb() time.sleep(2) if init_success: control = self.parentApp.addForm("FORM_CONTROLLER", ControllerForm, name="Bulb Controller UI") self.parentApp.changeForms("FORM_CONTROLLER") else: message_to_display = 'Could not connect to bulb...' npyscreen.notify(message_to_display, title='Connection Error') time.sleep(1) self.exit_application
def a_add(self, *args): npyscreen.notify("Loading NFC") with Nfc() as nfc: devs = nfc.get_devices() if len(devs) == 0: popup = InputLinePopup("No NFC Devices Found", "Enter UID:", "", self._add_uid) popup.edit() return nfc.select_device(devs[0]) npyscreen.notify("Scan a card now") uids = [] while len(uids) == 0: uids = list(nfc.poll_uids()) self._add_uid(uids[0])
def onStart(self): self.app_title = 'H1 Report Browser' self.myDB = ReportDatabase() self.addForm('MAIN', FmReportSelect) npyscreen.notify('Generating list of reports.', self.app_title) self.getForm('MAIN').update_list() self.getForm('MAIN').wStatus1.value = self.app_title self.getForm( 'MAIN' ).wStatus2.value = 'Press Enter to read the highlighted report. Q or q to quit.' self.addForm('READ', FmReportView) self.getForm('READ').wStatus1.value = 'Report ' self.getForm( 'READ' ).wStatus2.value = 'Press q, Q, or Enter to return to report list. ' self.getForm('READ').wMain.autowrap = True
def export_selected_row_grid(self, info): """ Export to a yml file the instance selected in the grid, its use the variable service_selected to evaluate the actions to do. :param info: :return: """ object_id = self.tw_aws_grid.entry_widget.selected_row() npyscreen.notify("Exporting data to " + object_id[0] + ".yml", title="Information") try: if self.service_selected == "EC2": self.ec2.export_instance_yaml(object_id[1]) elif self.service_selected == "Buckets": self.s3.export_s3_yaml(object_id[0]) elif self.service_selected == "VPC": self.Network.export_vpc_yaml(object_id[0]) elif self.service_selected == "Subnets": self.Network.export_subnets_yaml(object_id[0]) elif self.service_selected == "ACLs Network": self.Network.export_acls_yaml(object_id[0]) elif self.service_selected == "Security Groups": self.Security.export_security_group_yaml(object_id[0]) elif self.service_selected == "Network interfaces": self.Network.export_network_interface_yaml(object_id[0]) elif self.service_selected == "EBS": self.ec2.export_ebs_yml(object_id[0]) elif self.service_selected == "EFS": self.EFS.export_efs_yaml(object_id[0]) elif self.service_selected == "Users": self.IAM.export_user_yaml(object_id[0]) elif self.service_selected == "Groups": self.IAM.export_group_yaml(object_id[0]) elif self.service_selected == "Roles": self.IAM.export_role_yaml(object_id[0]) elif self.service_selected == "Policies": self.IAM.export_policy_yaml(object_id[3], object_id[0]) elif self.service_selected == "Lambda": self.LAMBDA.export_funcion_yaml(object_id[0]) except Exception as e: print(str(e)) print("error exporting to yml in GRID")
def on_ok(self): if re.match(r'^Private_key_', self.fp.value.split('/')[-1]): fp = self.fp.value fp2 = self.fp2.value filename = self.filename.value npyscreen.notify("Loading") global LogUser diff = client.diff(LogUser, filename, fp, fp2) values = [] try: while 1: values.append(diff.next()) except: pass self.parentApp.getForm("FileDiffDisplay").values = values self.parentApp.switchForm("FileDiffDisplay") else: npyscreen.notify_wait('Invalid Private key location/format (Private_key_<username>)')
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')
def afterEditing(self): try: activity = self.mem.data.activities.arr[ self.cmbActivities.value[0]] except: activity = None try: weightwish = self.mem.data.weightwishes.arr[ self.cmbWeightWishes.value[0]] except: weightwish = None try: height = Decimal(self.txtHeight.value) except: height = None try: weight = Decimal(self.txtWeight.value) except: weight = None try: user = self.mem.data.users.arr[self.cmbUsers.value[0]] except: user = None if user == None or weight == None or height == None or activity == None or weightwish == None: self.edit() return self.parentApp.setNextForm(None) self.editing = False self.parentApp.object = Biometrics(self.mem, datetime.now(), height, weight, user, activity, weightwish, None) self.parentApp.object.save() self.mem.con.commit() notify("Biometric data added") sleep(2)
def set_api_type(self, api_type): """ Sets the API type and populates the current API Page """ if type(api_type) != const.API_TYPES: raise TypeError("{} not in API_TYPES".format(api_type)) self.api_type = api_type try: npyscreen.notify("Fetching {}\nPlease Wait...".format( api_type.value), title="INTIALIZING", wide=True) self.parentApp.api_man.getters_dict.get(self.api_type)() self.api_page = self.parentApp.api_man.pages.get(self.api_type) except requests.exceptions.ConnectionError: npyscreen.notify_wait(const.MSG_CONNECTION_ERROR, title="Connection Error", form_color='WARNING') self.api_page = Api_Page()
def get_version(self): with open('Makefile', 'r') as f: for line in f: if line.startswith('VERSION = '): version = line.split('=')[1].strip() elif line.startswith('PATCHLEVEL = '): patchlevel = line.split('=')[1].strip() break self.verstr = version + '.' + patchlevel # With v2014.04 the u-boot Makefile knows the 'tools-only' target. if V(self.verstr) < V('2014.04'): notify("Only U-Boot >= 2014.04 is supported.\n" "This is version '%s'" % self.verstr, title='Warning') sleep(10) if V(self.verstr) >= V('2017.09'): self.deb['envtools'] = 'envtools' else: self.deb['envtools'] = 'env'
def create(self): # Show splash screen npyscreen.notify(LOGO, wide=True) time.sleep(1) # Wait 1 second # URL Field self.url = self.add(npyscreen.TitleText, name="Target:") # AWS Keys optional self.profile = self.add(AskAWSKeysWidget, max_height=4, value=[ 0, ], name="Use AWS Keys?", values=["No", "Yes"], scroll_exit=True, rely=4) # Reload screen, because of splash screen self.refresh()
def whenPressed(self): entryComment = self.parent.newcomment.value entryDate = self.parent.newdate.value if not isinstance(entryDate, date): npyscreen.notify("Please select a date.", title="No date selected") time.sleep(2) self.parent.display() return try: entryAmount = float(self.parent.newamount.value.replace(",", ".")) except: npyscreen.notify("Value for amount of hours is not a number.", title="Error in input") time.sleep(2) self.parent.display() return try: entryCode = self.parent.idList[self.parent.newcode.value[0]] except: npyscreen.notify("Please select a code.", title="No code selected") time.sleep(2) self.parent.display() return # If we reach here, all information should be valid. self.parent.parentApp.db.addHours(entryDate, entryCode, entryAmount, entryComment) self.parent.newamount.value = "" self.parent.newcode.value = "" self.parent.newcomment.value = "" self.parent.parentApp.switchForm('MAIN') self.parent.editw = 2 self.parent.editing = False
def while_waiting(self): # Проверяем, завершились ли процессы с АЦП if self.ltr11_run and self.ltr11_p.poll(): msg = None if self.ltr11_p.returncode < 0 or self.ltr11_p.returncode != 0: msg = self.ltr11_p.stderr.read().decode('utf-8') else: msg = self.ltr11_p.stdout.read().decode('utf-8') npyscreen.notify(msg, \ title="Message", form_color='STANDOUT') self.ltr11_run = False if self.ltr210_run and self.ltr210_p.poll(): msg = None if self.ltr210_p.returncode < 0 or self.ltr210_p.returncode != 0: msg = self.ltr210_p.stderr.read().decode('utf-8') else: msg = self.ltr210_p.stdout.read().decode('utf-8') npyscreen.notify(msg, \ title="Message", form_color='STANDOUT') self.ltr210_run = False pass
def spawn_notify_popup(self, entity): index = values_list.index(entity) func = None if (index == 0): func = analysis.get_popular_title_words elif (index == 1): func = analysis.get_time elif (index == 2): func = analysis.get_weekdays elif (index == 3): func = analysis.get_posting_stat elif (index == 4): func = database.import_collection elif (index == 5): func = database.export_collection elif (index == 6): self.parent.parentApp.switchForm(None) sys.exit(0) message_to_display = 'Processing...\nPicture will be opened in new window...' npyscreen.notify(message_to_display, title='Wait...') func() self.parent.parentApp.switchForm("MAIN")
def download_file(self, prefix): try: # Get arguments current_path = str(os.getcwd()) filename = str(prefix).rsplit("/", maxsplit=1)[-1] # Open Pop up npyscreen.notify("Downloading...") # Download the file self.__s3.download_file(self.bucket, prefix, f"{current_path}/{filename}") except botocore.exceptions.ClientError as e: # Init error message error_text = "An error ocurred while downloading the file." # Check error type if e.response['Error']['Code'] == "404": error_text = "The object does not exist." elif e.response['Error']['Code'] == "403": error_text = "Forbidden Operation." # Show error message npyscreen.notify_confirm(error_text, 'Download File Error')
def c_update_feed (self, *args, **keywords): npyscreen.notify(message = "Retrieving new feed items...", title = 'Status') with session_scope() as session: feed = md.get_feed(session, self.parent.value[1]['feed_id'])[0] item_count = md.update_feeditems(session, feed['feed_id']) if item_count > 0: npyscreen.notify("Feed updated", title = 'Status') else: npyscreen.notify("No new, or updated, items", title = 'Status') time.sleep(0.75) self.parent.c_show_feed_items()
def c_update_feed(self, *args, **keywords): npyscreen.notify(message="Retrieving new feed items...", title='Status') with session_scope() as session: feed = md.get_feed(session, self.parent.value[1]['feed_id'])[0] item_count = md.update_feeditems(session, feed['feed_id']) if item_count > 0: npyscreen.notify("Feed updated", title='Status') else: npyscreen.notify("No new, or updated, items", title='Status') time.sleep(0.75) self.parent.c_show_feed_items()
def spawn_notify_popup(self, code_of_key_pressed): message_to_display = 'I popped up \n passed: {}'.format( code_of_key_pressed) npyscreen.notify(message_to_display, title='Popup Title') time.sleep(1) # needed to have it show up for a visible amount of time
def c_send_to_pocket(self, *args, **keywords): npyscreen.notify('Sending to Pocket...') response = send_to_pocket(dict(self.value)['url']) if response['status'] == 1: npyscreen.notify('Sent!') time.sleep(1)
def beforeEditing(self): npyscreen.notify('Generating report.', self.parentApp.app_title) self.update_list()
def c_add_feed(self, command_line, widget_proxy, live): npyscreen.notify("Adding new feed...", title = 'Status') with session_scope() as session: msg = md.add_feed(session, command_line) self.c_show_feeds()
def on_cancel(self): npyscreen.notify("Ticked died :(", "You are cruel man")
def on_cancel(self): npyscreen.notify("Not not nothing")