示例#1
0
 def get_classes(self):
     results = []
     con = dbapi2.connect(Infrastructure().get_db_path())
     res = con.execute("Select module_name, class_name from commands  where active='1' group by class_name")
     for r in res:
         results.append(r)
     return results
示例#2
0
    def lookup(self, command_name, limit):
        results = []
        con = dbapi2.connect(Infrastructure().get_db_path()) 
        phrases = command_name.split()
        if len(phrases) == 1:
            res = con.execute('SELECT class_name, entry_name, command_name\
                        from commands where command_name like "%'+phrases[0]+'%"\
                        ORDER BY command_name LIMIT '+str(limit)+'')
        elif len(phrases) == 2:
            res = con.execute('SELECT class_name, entry_name, command_name\
                        from commands where command_name like "%'+phrases[0]+'%" and command_name like "%'+phrases[1]+'%"\
                        ORDER BY command_name LIMIT '+str(limit)+'')
        elif len(phrases) > 2:
            res = con.execute('SELECT class_name, entry_name, command_name\
                        from commands where command_name like "%'+phrases[0]+'%"\
                            and command_name like "%'+phrases[1]+'%"\
                            and command_name like "%'+phrases[2]+'%"\
                        ORDER BY command_name LIMIT '+str(limit)+'')
        else:
            res = con.execute('SELECT class_name, entry_name, command_name\
                        from commands\
                        ORDER BY command_name LIMIT '+str(limit)+'')

        for r in res:
            results.append(r)

        return results 
示例#3
0
    def __init__(self):
        if not Infrastructure().db_file_exists():
            Infrastructure().build_path()
            self.build_default_db()

        self.gui = AssistantGUI()
        self.gui.set_empty_title("[enter command]")
        self.gui.hide()
        self.executor = Executor()
        self.executor.set_content_listener(self.content_changed)
        self.executor.set_command_listener(self.command_changed)
        self.executor.start()
        self.visible = False
        self.lastKeyPressed = "left ctrl"
        self.lastPressedTime = time.time()
        self.updateContent(self.executor.get_commands())

        self.showTriggerLastTime = 0.0
示例#4
0
 def reinit(self):
     con = dbapi2.connect(Infrastructure().get_db_path())
     con.execute("DROP TABLE IF EXISTS commands")
     con.execute("CREATE TABLE commands (\
             id INTEGER PRIMARY KEY, \
             module_name TEXT,\
             class_name TEXT,\
             entry_name TEXT,\
             command_name TEXT UNIQUE,\
             active INTEGER)")
示例#5
0
def closest(lat, lon, n_samples):
    df = Infrastructure.get_instance().get_all_data().copy()

    df["distance"] = df.apply(
        lambda row: haversine_distance(lat, lon, row["lat"], row["lon"]),
        axis=1
    )
    df.sort_values("distance", inplace=True)

    return df.groupby("type").head(n_samples)
示例#6
0
 def show_all(self):
     con = dbapi2.connect(Infrastructure().get_db_path())
     res = con.execute("Select * from commands")
     for r in res:
         iden, module_name, class_name, entry_name, command_name, active = r
         print("{}\t{}\t{}\t{}\t{}\t{}".format(iden, module_name, class_name, entry_name, command_name, active))
示例#7
0
 def delete_module(self, module_name):
     con = dbapi2.connect(Infrastructure().get_db_path())
     con.execute("DELETE FROM commands WHERE module_name='"+module_name+"'")
     con.execute("COMMIT")
示例#8
0
 def insert(self, data):
     module_name, class_name, entry_name, command_name = data
     con = dbapi2.connect(Infrastructure().get_db_path())
     con.execute("INSERT INTO commands  (module_name, class_name, entry_name, command_name, active)\
      VALUES ('"+module_name+"', '"+class_name+"', '"+entry_name+"', '"+command_name+"', '1')")
     con.execute("COMMIT")
示例#9
0
 def open_pyssistant_home(self):
     self.open_folder(Infrastructure().get_root_path())
示例#10
0
 def __init__(self):
     self.db_loc = Infrastructure().get_module_data_path("prompter")