def __do_js(self, event): self.__vertexes.clear() self.__canvas.delete("all") self.__draw_points() if len(self.__points) < 3: return js = Jarvis(self.__points, self.__canvas.winfo_height()) self.__vertexes = js.solver() self.__draw_lines()
def main(): """ Basic loop, listen and execute. """ bot = Jarvis() bot.say(f"Hello, {parameters.NAME}.") is_running = True while is_running: phrase = bot.listen() bot.process(phrase.lower())
def main_cli(): from ui.cmd_interpreter import CmdInterpreter from language import snips language_parser = snips.LanguageParser() plugin_manager = build_plugin_manager() jarvis_server = server.JarvisServer() jarvis = Jarvis(language_parser, plugin_manager, jarvis_server) cmd_interpreter = CmdInterpreter(jarvis) command = " ".join(sys.argv[1:]).strip() cmd_interpreter.executor(command)
def main_gui(): from ui.gui.application import JarvisApp from kivy.utils import platform if platform == 'android': import ui.gui.android_plugins plugin_manager = ui.gui.android_plugins.build_plugin_manager() else: plugin_manager = build_plugin_manager() language_parser = default.DefaultLanguageParser() jarvis_server = server.JarvisServer() jarvis = Jarvis(language_parser, plugin_manager, jarvis_server) jarvis_gui = JarvisApp(jarvis) jarvis_gui.run()
def start_server(self): print("Starting a thread for home server!") from main import build_plugin_manager plugin_manager = build_plugin_manager() language_parser = snips.LanguageParser() jarvis_server = JarvisServer() self.io = ServerIO() self.jarvis = Jarvis(language_parser, plugin_manager, jarvis_server) self.jarvis.register_io(self.io) self.server_app.run(host=self.host_name, port=self.port, threaded=True, debug=True, use_reloader=False)
def __init__(self): #Jarvis self.Jarvis = Jarvis() #Variables self.targets = None self.file = None self.interface = None self.gateway = None self.port = 80 self.domain = None self.redirect = None self.script = None self.filter = None self.arpmode = "rep" #Status manager self.jarvis_status = 0 self.arpspoof_status = False self.inject_status = False self.dnsspoof_status = False self.mitmdrop_status = 0
def run(mother): category = mother.categories['Study'] for page in category: oldtext = page.text() p = mwparserfromhell.parse(oldtext) template = study_template(p) if template: logging.debug( "Page {} has template {} with these params: {}".format( page.name, template.name.rstrip(), template.params)) try: jarvis_id = template.get("JARVIS ID").value.rstrip() except ValueError: # Skip JARVIS integration if there's no id logging.warning("No JARVIS ID on study page %s" % page.name) pass else: try: # Pull stuff out of JARVIS and put it into the template params j = Jarvis() logging.info("JARVIS id for %s is %s" % (page.name, jarvis_id)) irb_exp = j.irb_expirations(jarvis_id) if irb_exp: template.add("JARVIS IRB Expiration", irb_exp) quota = j.total_active_quota(jarvis_id) if quota: template.add("JARVIS Study Drive Quota", quota) # Personnel is a different section of the document, so replace that personnel = j.personnel(jarvis_id) old_sections = p.get_sections(matches="JARVIS Personnel") if len(old_sections) > 0: old_personnel = old_sections[0] p.replace(old_personnel, personnel) except Exception as e: # Print the error and keep going logging.error( f"Problem fetching from JARVIS on study page {page.name}: {traceback.print_exc()}" ) pass try: nih_id = template.get("NIH RePORTER ID").value.rstrip() except ValueError: # We just skip NIH integration if there's no id or we fail in any way logging.warning("No NIH ID on study page %s" % page.name) pass else: # award date, NIH start / end dates, break out official NIH title logging.info("NIH id for %s is %s" % (page.name, nih_id)) nih_url = "https://api.federalreporter.nih.gov/v1/Projects?nihApplId=" + nih_id resp = requests.get(nih_url) if resp.status_code != 200: logging.warning("GET {} {}".format(nih_url, resp.status_code)) else: data = resp.json() template.add("NIH Title", data['title']) template.add("NIH Fiscal Year", data['fy']) template.add("NIH Budget Start Date", jsondate_to_str(data['budgetStartDate'])) template.add("NIH Budget End Date", jsondate_to_str(data['budgetEndDate'])) template.add("NIH Project Start Date", jsondate_to_str(data['projectStartDate'])) template.add("NIH Project End Date", jsondate_to_str(data['projectEndDate'])) newtext = str(p) newtext = newtext.replace( "<noinclude>NOTE: This is prefab content inserted in new study pages</noinclude>", "") if oldtext.strip() != newtext.strip(): logging.warning("Updating study page %s, change detected", page.name) page.save( newtext, "Automated edit to update study values from JARVIS and NIH") else: logging.info("Not updating study page %s, text identical", page.name)
def __init__(self): self.Jarvis = Jarvis()
import sys from colorama import Fore, Back from features.calendar_feature import Calendar from jarvis import Jarvis features = ["calendar", "weather", "wiki"] if __name__ == "__main__": j = Jarvis() while True: typed = input("What do you want to do?: ").lower() cmd = typed.split(' ')[0] if cmd.strip() == 'list': j.say("Features available:") for feature in features: j.say("\t{}".format(feature), Fore.LIGHTBLUE_EX) elif cmd.strip() == 'exit' or cmd.strip() == 'close': j.say("G O O D B Y E") exit(0) elif j.cal.valid_inputs.get(cmd, 0) > 0: action = j.cal.do_action(typed) elif j.weather.valid_inputs.get(cmd, 0) > 0: if any(typed.strip('weather ')): j.weather.get_weather(typed.replace('weather ', '')) else: j.weather.get_weather() elif j.wiki.valid_inputs.get(cmd, 0) > 0:
from flask import Flask, request, jsonify from jarvis import Jarvis import json jarvis = Jarvis() app = Flask(__name__) # Create URL route in our application for "/" @app.route('/v1') def home(): """ This is the main page. """ return "This is a rest service for Jarvis. Jarvis is a AI text classification agent. He will try to predict the correct queue for the email you pass to it." @app.route('/v1/predict',methods = ['POST', 'GET']) def predict(): """ This fuction is to create the post and get method for prediction """ if request.method == 'POST': data = request.get_json() query = data["email"] result = jarvis.predict(query) return jsonify(result) else: query = request.args.get('email') result = jarvis.predict(query) return jsonify(result)
def __init__(self): # Config File os.path.abspath("config/NetGUARD.cfg") self.config = ConfigParser.ConfigParser() self.config.read("config/netguard.cfg") # Call Jarvis self.Jarvis = Jarvis() # Log file os.path.abspath("log/NetGUARD.log") # Jail self.jail = [] try: # Network Interface from config self.interface = self.configmap("NetworkSettings")['interface'] # Gateway IP address from config self.gateway_ip = self.configmap("NetworkSettings")['gateway_ip'] # Gateway MAC address from config self.gateway_mac = self.configmap("NetworkSettings")['gateway_mac'] except Exception as e: print "[-] Check your config file in NetGUARD/config/netguard.cfg" print "[!] Exception caught: ".format(e) exit(0) # My Network Interface MAC_Address self.mymac = get_mymac(self.interface) # My LAN IP Address self.myip = get_myip(self.interface) # If we are ARP spoofing status self.myspoof_status = False # If someone is ARP spoofing status self.spoof_status = False # ICMP request for this host - DDoS avoid. self.icmp_count = 0 # Network ICMP sources in 5s self.icmpsenders = {} # TCP != from gateway connections - DDoS avoid. self.tcp_count = 0 # Network UDP sources in 5s self.tcpsenders = {} # UDP != from gateway connections - DDoS avoid. self.udp_count = 0 # Network UDP sources in 5s self.udpsenders = {} # SSH client attempts and brute status self.ssh_count = 0 self.ssh_brute = False # MySQL client attempts and brute status self.sql_count = 0 self.sql_brute = False # FTP client attempts and brute status self.ftp_count = 0 self.ftp_brute = False # Time variables self.start_time = time.time() self.current_time = 0 #ICMP time auxiliary self.itt = 0 self.itt2 = 0 #TCP time auxiliary self.ttt = 0 self.ttt2 = 0 #UDP time auxiliary self.utt = 0 self.utt2 = 0 #SSH time auxiliary self.sst = 0 self.sst2 = 0 #SQL time auxiliary self.sqt = 0 self.sqt2 = 0 #FTP time auxiliary self.ftt = 0 self.ftt2 = 0
def __init__(self, gid=TEST_GROUP_ID): data = json.load(open("creds.json", 'r')) self.jarvis = Jarvis(data['id'], data['password'], gid)
def run(mother): category = mother.categories['Study'] all_studies = set() status = {} has_status = set() missing_status = set() missing_jarvis = set() jarvis_ids = set() for page in category: logging.debug("Checking study", page.name) all_studies.add(page.name) text = page.text() p = mwparserfromhell.parse(text) template = study_template(p) if template: if template.has("Study Status"): s = template.get("Study Status").value.strip() if s == "": continue words = re.split(r',\s*', s) for c in words: status[c] = status.get(c, set()) status[c].add(page.name) has_status.add(page.name) if not template.has("JARVIS ID") or \ template.get("JARVIS ID").value.strip() == "": missing_jarvis.add(page.name) else: jarvis_ids.add(int(template.get("JARVIS ID").value.strip())) if not page.name in has_status: missing_status.add(page.name) logging.debug("Got status: ", status) # Now statuses contains a hash of construct -> list of pages. # NOTE: This re-uses MediaWiki's category CSS classes to get three-column display. Maybe weird to do that? oldtext = category.text() cat = mwparserfromhell.parse(oldtext) sections = cat.get_sections() title = "== Sorted by Study Status ==" newtext = title + "\n\nPlease note: this section is created automatically based on the status in each study's infobox. To edit, go to the study's page and choose 'Edit with form'.\n\n" newtext += "<div class='mw-category'>" # Build up an index by status # Sort by certain rules sort_order = [ "In Development", "Piloting", "Collecting", "Data Collection Complete", "Analyzing", "Publishing", "IRB Closed" ] for k in sort_order: if not k in status: continue newtext += "<div class='mw-category-group'><h3>" + k + "</h3>\n" for study in sorted(list(status[k])): newtext += "* [[" + study + "]]\n" newtext += "</div>" # List out things that are missing statuses newtext += "<div class='mw-category-group'><h3>No statuses listed</h3>\n" for m in missing_status: newtext += "* [[" + m + "]]\n" newtext += "</div>" newtext += "</div>\n\n" # Replace the "Sorted by Study Status" section with our new text old_section = cat.get_sections(matches="Sorted by Study Status")[0] cat.replace(old_section, newtext) newpage = str(cat) if oldtext != newpage: logging.warning("Updating study category page, change detected") category.save( newpage, "Automated edit to build status categories on study library") # Now we use the statuses and dates we pulled to edit the "missing Jarvis" and "studies not edited for the longest" missing = mother.pages['Study pages missing JARVIS IDs'] oldtext = missing.text() newpage = "This page is automatically generated. See also [[JARVIS IDs missing study pages]]\n\n" newpage += "== Pages missing JARVIS IDs ==\n\n" for page in sorted(missing_jarvis): newpage += f"* [[{page}]]\n" if oldtext != newpage: logging.warning("Updating missing JARVIS IDs page, change detected") missing.save(newpage, "Automated edit") # Now we build the opposite thing missing = mother.pages['JARVIS IDs missing study pages'] oldtext = missing.text() newpage = "This page is automatically generated and only includes more recent entries in JARVIS. See also [[Study pages missing JARVIS IDs]]\n\n" newpage += "== JARVIS IDs missing study pages ==\n\n" j = Jarvis() all_studies = j.select( "SELECT id, folder, name, created_at FROM studies ORDER BY created_at DESC LIMIT 30" ) for s in all_studies: jarvis_id, folder, name, created_at = s if not jarvis_id in jarvis_ids: newpage += f"* ID {jarvis_id} in /study/{folder}: \"{name}\" (created at {created_at})\n" if oldtext != newpage: logging.warning("Updating missing study pages page, change detected") missing.save(newpage, "Automated edit")
from jarvis import Jarvis jarvis_speech_assitant = Jarvis() jarvis_speech_assitant.get_user_name() jarvis_speech_assitant.vocal_assistant()