def load(proj_n): # function to load a project global current c = conn.cursor() c.execute("SELECT * FROM project;") rows = c.fetchall() current = rows[int(proj_n)] print_logo() print("load project") print("------------------------------------------") print("project: " + current[1] + " loaded") print("") print("options: ") print("") print("0 : scan all") print("1 : resume") print("2 : nmap only") print("3 : create report") print("------------------------------------------") i_nr = input("option: ") # choose one option if i_nr == "0": # scan all nmap_hack.run_nmap() scan.scan() ########### elif i_nr == "1": # resume scan.scan() elif i_nr == "2": # nmap only nmap_hack.run_nmap() elif i_nr == "3": # create report report.create(current[1]) elif (i_nr != "0" or "1" or "2" or "3"): print("enter a valid value!")
def main(): os.environ[ "GOOGLE_APPLICATION_CREDENTIALS"] = "./resources/credentials/e3682f457e02.json" os.system("cls") project_id = "recruitertest-dd3ab" session_id = str(uuid.uuid4().hex[:12]) language_code = "en-US" input_file_path = "./resources/audio/subject_input.wav" # [START DIALOG] complete_transcript = [[], []] # [QUICK DIALOG] # complete_transcript = detect_intent_texts(project_id, session_id, [ # "DEMO_START", "Diana Moon", "18", "Adaptable , ambitious, clever and blunt", "I have a bachelor in mathematics", # "I have worked for Google as a data scientist of the past 3 years", "I am good at analysis and computers", "My communication is not great", "40 hours", "No"], language_code) # [NORMAL DIALOG] detect_intent_texts(project_id, session_id, ["DEMO_START"], language_code) while True: # text_input = input("Text input: ") # partial_transcript = detect_intent_texts(project_id, session_id, [ # text_input], language_code) audio.record(input_file_path) partial_transcript = detect_intent_audio(project_id, session_id, input_file_path, language_code) # audio.record(input_file_path) # partial_transcript = detect_intent_stream(project_id, session_id, # input_file_path, language_code) complete_transcript[0] = complete_transcript[0] + partial_transcript[0] complete_transcript[1] = complete_transcript[1] + partial_transcript[1] if poke(project_id, session_id, language_code): break # [END DIALOG] # [DATA] subject_info = get_subject_info(project_id, session_id, language_code) clean_subject_info = data.clean(subject_info) match_scores = data.match(subject_info) report.create(clean_subject_info, match_scores, complete_transcript, session_id)
def partial(**kwargs): if kwargs.get('gather'): # If we want to gather data (or we're running everything), call the # Twitter API and gather as much as we can. gather_data(kwargs.get('woeid'), kwargs.get('num_topics')) if kwargs.get('purify'): # If we want to clean data (or we're running everything), grab a target # and feed it through the data cleaning algorithm. If a target isn't # specified, the most recent file is used. purify.cleanse(kwargs['purify']) if kwargs.get('summarize'): # Same as above, but for text summarization. if not os.path.exists(str(DATA_DIR / kwargs['summarize']) + '.csv'): purify.cleanse(kwargs['summarize']) try: summary = summarize.summarize_tweets(kwargs['summarize'], kwargs['mock']) if DEBUG: log(summary) except MemoryError: log('WARN: Not enough memory to perform summarization!') summary = '' if kwargs.get('cluster'): # Find representative tweets using agglomerative clustering. if not os.path.exists(str(DATA_DIR / kwargs['cluster']) + '.csv'): purify.cleanse(kwargs['cluster']) cluster_reps = cluster.find_cluster_reps(kwargs['cluster'], kwargs['mock']) deref([rep[2] for rep in cluster_reps], kwargs['cluster']) if DEBUG: log_reps(cluster_reps) if kwargs.get('sentiment'): # Same as above, but for sentiment analysis sent_reps = sentiment.find_sentiment_cluster_reps( kwargs['sentiment'], kwargs['mock']) deref([rep[2] for rep in sent_reps], kwargs['sentiment']) if DEBUG: log_reps(sent_reps) if kwargs.get('report'): # Use the target for sentiment here (it is the same as the targets for # the other submodules when args.full or args.process is run). report.create( kwargs.get('report'), summary, cluster_reps, sent_reps, kwargs.get('seed'), kwargs.get('label'), )
def callback_function(gap): """The call back function to call in order to save result.""" LOG.info("Saving reports to %s", self.reportname) info = gap.metadata() content = report.create(gap.ranked_articles, articles=info['articles'], filtered_articles=info['filtered']) report.save(self.site, self.reportname, content)
def create_report(name, start_datetime, end_datetime, selectedJobs, filter_by, allWords, anyWords, noneWords, username): """ This function creates a new report on the database then redirects :param name: The name of the report to be created :param start_datetime: start date_time :param end_datetime: end date_time :param selectedJobs: selected jobs for report :param filter_by: The sources for which the report should be filtered :param allWords: all words to be searched :param anyWords: any word from this list :param noneWords: none of these words should come in the report results :param username: The username of user for which this Job is being created for :return: A redirect response to view the new report """ report_id = report.create(name, start_datetime, end_datetime, selectedJobs, filter_by, allWords, anyWords, noneWords, username_to_id(username)) if report_id is None: abort(400) log = logging.getLogger() log.error(username + ' ' + 'Report_Creation ' + str(name)) return jsonify({"status": "ok", "id": report_id})
def parse_txt(self, txt): if not txt: return self.logger.info("%r" % txt) if "Setting up the instrument" in txt: self.Pulse(lang.getstr("instrument.initializing")) if "Spot read failed" in txt: self.last_error = txt if "Result is XYZ:" in txt: # Result is XYZ: d.dddddd d.dddddd d.dddddd, D50 Lab: d.dddddd d.dddddd d.dddddd # CCT = ddddK (Delta E d.dddddd) # Closest Planckian temperature = ddddK (Delta E d.dddddd) # Closest Daylight temperature = ddddK (Delta E d.dddddd) XYZ = re.search("XYZ:\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)", txt) self.results[self.index].append( {"XYZ": [float(value) for value in XYZ.groups()]}) self.last_error = None loci = {"t": "Daylight", "T": "Planckian"} for locus in list(loci.values()): if locus in txt: CT = re.search( "Closest\s+%s\s+temperature\s+=\s+(\d+)K" % locus, txt, re.I) self.results[self.index][-1]["C%sT" % locus[0]] = int( CT.groups()[0]) if "key to take a reading" in txt and not self.last_error: safe_print("%s: Got 'key to take a reading'" % appname) if not self.is_measuring: self.enable_buttons() return if len(self.results[self.index]) < len(self.colors): # Take readings at 5 different brightness levels per swatch safe_print("%s: About to take next reading" % appname) self.measure() else: self.is_measuring = False self.show_cursor() self.enable_buttons() self.buttons[self.index].Show() self.buttons[self.index].SetFocus() self.buttons[self.index].SetBitmap( getbitmap("theme/icons/16x16/checkmark")) self.panels[self.index].SetBackgroundColour(BGCOLOUR) self.panels[self.index].Refresh() self.panels[self.index].Update() if len(self.results) == self.rows * self.cols: # All swatches have been measured, show results # Let the user choose a location for the results html display_no, geometry, client_area = self.get_display() # Translate from wx display index to Argyll display index geometry = "%i, %i, %ix%i" % tuple(geometry) for i, display in enumerate(getcfg("displays")): if display.find("@ " + geometry) > -1: safe_print("Found display %s at index %i" % (display, i)) break display = display.replace(" [PRIMARY]", "") defaultFile = "Uniformity Check %s — %s — %s" % ( appversion, re.sub(r"[\\/:*?\"<>|]+", "_", display), strftime("%Y-%m-%d %H-%M.html")) defaultDir = get_verified_path( None, os.path.join(getcfg("profile.save_path"), defaultFile))[0] dlg = wx.FileDialog(self, lang.getstr("save_as"), defaultDir, defaultFile, wildcard=lang.getstr("filetype.html") + "|*.html;*.htm", style=wx.SAVE | wx.FD_OVERWRITE_PROMPT) dlg.Center(wx.BOTH) result = dlg.ShowModal() if result == wx.ID_OK: path = dlg.GetPath() if not waccess(path, os.W_OK): from worker import show_result_dialog show_result_dialog( Error( lang.getstr("error.access_denied.write", path)), self) return save_path = os.path.splitext(path)[0] + ".html" setcfg("last_filedialog_path", save_path) dlg.Destroy() if result != wx.ID_OK: return locus = loci.get(getcfg("whitepoint.colortemp.locus")) try: report.create( save_path, { "${REPORT_VERSION}": appversion, "${DISPLAY}": display, "${DATETIME}": strftime("%Y-%m-%d %H:%M:%S"), "${ROWS}": str(self.rows), "${COLS}": str(self.cols), "${RESULTS}": str(self.results), "${LOCUS}": locus }, getcfg("report.pack_js"), "uniformity") except (IOError, OSError) as exception: from worker import show_result_dialog show_result_dialog(exception, self) else: launch_file(save_path) if getcfg("uniformity.measure.continuous"): self.measure(event=Event(self.buttons[self.index]))
def create_report(): _id, platform, doc_type = create() tasks.process.delay(_id, platform, doc_type) return jsonify(_id)
def main(): experiments.make() report.create()