Exemplo n.º 1
0
Arquivo: gps.py Projeto: nano13/tambi
    def position(self, c, a):
        result_object = Result()

        try:
            data = self.getPosition()
        except NoFixError:
            result_object.category = "text"
            result_object.payload = "no gps fix available"
        else:
            if data:
                result_object.category = "table"
                result_object.payload = [
                    ['Latitude', data['latitude']],
                    ['Longitude', data['longitude']],
                    ['Altitude', data['altitude']],
                    ['Speed', data['speed']],
                    ['Track', data['track']],
                    ['Climb', data['climb']],
                    ['Time', data['time']],
                    ['Error Horizontal', data['error_horizontal']],
                    ['Error Vertical', data['error_vertical']],
                ]
            else:
                result_object.category = "text"
                result_object.payload = 'could not find any working position provider (like gpsd or geoclue)'
        return result_object
Exemplo n.º 2
0
Arquivo: gps.py Projeto: nano13/tambi
    def plot(self, c, args):
        result_object = Result()
        filename = self.__determineFilename(args)
        if not filename:
            result_object.error = 'a file matching to the specified one could not be found'
            return result_object

        filepath = os.path.join(self.logpath, filename)

        dbAdapter = DbAdapter(filepath)
        boundings = dbAdapter.selectMinMaxCoordinate()
        mapView = QMapView(boundings)

        data = dbAdapter.selectLatLon()
        points_list = []
        for pos in data:
            #mapView.addPoint(pos['longitude'], pos['latitude'])
            x, y = pos['latitude'], pos['longitude']
            points_list.append([x, y])
        mapView.addPointList(points_list)
        mapView.drawPointList()

        #mapView.scaleViewToContents()

        result_object.category = "qt_widget"
        result_object.payload = mapView
        return result_object
Exemplo n.º 3
0
Arquivo: gps.py Projeto: nano13/tambi
    def showHeightmap(self, c, args):

        lat_min = float(args[0])
        lat_max = float(args[1])
        lon_min = float(args[2])
        lon_max = float(args[3])

        delta_lat = vincenty([lat_min, lon_min], [lat_max, lon_min]).kilometers
        delta_lon = vincenty([lat_min, lon_min], [lat_min, lon_max]).kilometers

        print(delta_lat, delta_lon)

        import srtm
        geo_elevation_data = srtm.get_data()
        width = 1000
        height = (delta_lon * width) / delta_lat
        print(width, height)
        #image = geo_elevation_data.get_image((1000, 1000), (50, 51), (8, 9), 800)
        image = geo_elevation_data.get_image((round(width), round(height)),
                                             (lat_min, lat_max),
                                             (lon_min, lon_max), int(args[4]))

        result_object = Result()
        result_object.category = "image"
        result_object.payload = image
        return result_object
Exemplo n.º 4
0
Arquivo: gps.py Projeto: nano13/tambi
    def logs(self, c, a):
        base, dirs, files = next(iter(os.walk(self.logpath)))

        result_object = Result()
        result_object.category = "list"
        result_object.payload = sorted(files)
        return result_object
Exemplo n.º 5
0
 def search(self, c, args):
     try:
         pattern = args[0]
     except:
         result_object = Result()
         result_object.error = 'you have to specify a search-pattern'
         return result_object
     else:
         import fileinput, glob, string
         result = []
         for line in fileinput.input(glob.glob(MODULE_PATH + os.sep + '*.md')):
             
             num_matches = line.lower().count(pattern.lower())
             if num_matches:
                 filepath = fileinput.filename()
                 filename = filepath.replace(MODULE_PATH + os.sep, '').replace('.md', '')
                 if not filename in result:
                     result.append(filename)
                 else:
                     pass
                     # we could raise a counter here to show, how often the pattern was found in one module ...
         
         result_object = Result()
         result_object.category = 'list'
         result_object.payload = result
         return result_object
Exemplo n.º 6
0
    def wordHelper(self, args, header):
        self.initDbConnection()

        columns = ", ".join(header)
        if len(args) == 1:
            query = "SELECT {0} FROM quran WHERE surah=?".format(columns)
            self.cursor.execute(query, [int(args[0])])

        elif len(args) == 2:
            if args[1].find('-') == -1:
                query = "SELECT {0} FROM quran WHERE surah=? AND ayah=?".format(
                    columns)
                self.cursor.execute(query, [int(args[0]), int(args[1])])

            else:
                ayah_min, ayah_max = args[1].split('-')
                query = "SELECT {0} FROM quran WHERE surah=? AND ayah>=? AND ayah<=?".format(
                    columns)
                self.cursor.execute(
                    query,
                    [int(args[0]), int(ayah_min),
                     int(ayah_max)])

        result = self.cursor.fetchall()

        result_object = Result()
        result_object.category = "itemized"
        result_object.payload = result
        result_object.header = header
        result_object.name = "quran_word"
        return result_object
Exemplo n.º 7
0
    def structure(self, c, args):
        if len(args) == 0:
            query = """SELECT book_id, book_string, name_intern, chapter
            FROM structure
            JOIN books ON structure.book_id=books.id
            GROUP BY book_id"""
            head = ['book_id', 'book_string', 'name_intern', 'chapter']
        else:
            query = """SELECT book_id, book_string, name_intern, chapter, COUNT(*) AS number_verses
            FROM structure
            JOIN books ON structure.book_id=books.id
            WHERE name_intern = "{0}"
            GROUP BY chapter""".format(args[0])
            head = [
                'book_id', 'book_string', 'name_intern', 'chapter',
                'number_verses'
            ]

        self.initDbConnection()
        self.cursor.execute(query)
        result = self.cursor.fetchall()

        result_object = Result()
        result_object.category = 'table'
        result_object.payload = result
        result_object.header = head
        return result_object
Exemplo n.º 8
0
    def summary(self, c, args):
        result_object = Result()

        if len(args) == 0:
            result_object.error = "please specify a book. see bituza.books for the exact names"
            return result_object

        fobj = open("./modules/bituza/bible_summary/bible_summary.txt")

        lines_to_return = ""
        in_section = False
        for line in fobj:
            if line.find(args[0]) >= 0:
                in_section = True
                lines_to_return += line
            elif in_section and line.find("===") >= 0:
                in_section = False
            elif in_section:
                lines_to_return += line

        fobj.close()

        result_object.category = "text"
        result_object.payload = lines_to_return
        return result_object
Exemplo n.º 9
0
    def search(self, c, args):
        result_object = Result()

        try:
            key = '%' + args[0] + '%'
        except IndexError:
            result_object.error = 'ERROR: you have to specify a search pattern'

        else:
            query = """SELECT surah, ayah, arabic, transcription, de_DE
            FROM quran
            WHERE arabic LIKE ? OR transcription LIKE ? OR de_DE LIKE ?"""
            self.initDbConnection()
            self.cursor.execute(query, [key, key, key])

            result = self.cursor.fetchall()

            result_object.category = "itemized"
            result_object.payload = result
            result_object.header = [
                'surah', 'ayah', 'arabic', 'transcription', 'de_DE'
            ]
            result_object.name = "quran_search"

        return result_object
Exemplo n.º 10
0
    def textusReceptus(self, c, a):
        query = "SELECT verse, unicode FROM word NATURAL JOIN structure WHERE book_id=66 AND chapter=1 AND verse>=1 AND verse<=4"
        self.initDbConnection()
        self.cursor.execute(query)
        result = self.cursor.fetchall()

        current_verse_number = int(result[0][0])
        #print(current_verse_number)
        result_list = []
        result_line = ""
        j = 1
        for i in range(len(result)):
            #print(current_verse_number)#, result_line
            if result[i][0] == current_verse_number:
                result_line += result[i][1] + " "
            else:
                j += 1
                current_verse = int(result[j][0])

                result_list.append(result_line)
                #print(i, current_verse_number)
                result_line = result[i][1] + " "

        result_object = Result()
        result_object.category = 'list'
        result_object.payload = result_list
        return result_object
Exemplo n.º 11
0
    def setCurrentModule(self, c, args):
        self.current_module = args[0]

        result_object = Result()
        result_object.category = "list"
        result_object.payload = 'sword bible-module set to: ' + args[0]
        return result_object
Exemplo n.º 12
0
    def listModules(self, c, args):
        modules = SwordModules()
        result = []
        try:
            found_modules = modules.parse_modules()
        except FileNotFoundError:
            category = 'list'
        else:
            for key in found_modules:
                row = []
                row.append(key)

                #for item in found_modules[key]:
                #    row.append(found_modules[key][item])
                row.append(found_modules[key]['lang'])
                row.append(found_modules[key]['about'].replace('\par', "\n"))
                row.append(found_modules[key]['version'])

                if len(args) == 1:
                    category = "itemized"
                    if found_modules[key]['lang'] == args[0]:
                        result.append(row)
                else:
                    category = "table"
                    result.append(row)

        result_object = Result()
        result_object.category = category
        result_object.payload = sorted(result)
        return result_object
Exemplo n.º 13
0
 def read(self, c, args):
     if len(args) <= 0:
         result_object = Result()
         result_object.error = 'please specify the chapter you want to read. see for the command "survival.toc"'
         return result_object
     
     filepath = MODULE_PATH + os.sep + args[0]+".md"
     
     if not os.path.exists(filepath):
         result_object = Result()
         result_object.error = 'chapter '+args[0]+' not found'
         return result_object
     
     input_file = input_file = codecs.open(filepath, mode="r", encoding="utf-8")
     md_file = input_file.read()
     html = '<h1>'+args[0]+'</h1>'
     html += markdown.markdown(md_file, extensions=[
         'markdown.extensions.sane_lists',
         'markdown.extensions.nl2br',
         'markdown.extensions.extra',
         'markdown.extensions.tables',
     ])
     
     folderpath = '/modules/survival/guide/'.replace('/', os.sep)
     html = html.replace('src="', 'src="' + MODULE_PATH + os.sep)
     html = html.replace('<table>', '<table border="1">')
     
     #fobj = open("/tmp/mktest.html", "w")
     #fobj.write(html)
     #fobj.close()
     
     result_object = Result()
     result_object.category = "html"
     result_object.payload = html
     return result_object
Exemplo n.º 14
0
    def order(self, c, args):
        order = [
            96, 68, 73, 74, 1, 111, 81, 87, 92, 89, 93, 94, 103, 100, 108, 102,
            107, 109, 105, 113, 114, 112, 53, 80, 97, 91, 85, 95, 106, 101, 75,
            104, 77, 50, 90, 86, 54, 38, 7, 72, 36, 25, 35, 19, 20, 56, 26, 27,
            28, 17, 10, 11, 12, 15, 6, 37, 31, 34, 39, 40, 41, 42, 43, 44, 45,
            46, 51, 88, 18, 16, 71, 14, 21, 23, 32, 52, 67, 69, 70, 78, 79, 82,
            84, 30, 29, 83, 2, 8, 3, 33, 60, 4, 99, 57, 47, 13, 55, 76, 65, 98,
            59, 24, 22, 63, 58, 49, 66, 64, 61, 62, 48, 5, 9, 110
        ]
        result = []
        for item in order:
            result.append(str(item))

        if args:
            try:
                index = result.index(str(args[0]))
            except ValueError:
                pass
            else:
                if index == 0:
                    result = result[:2]
                elif index == 113:
                    result = result[-2:]
                else:
                    result = result[index - 1:index + 2]

        result_object = Result()
        result_object.category = "list"
        result_object.payload = result
        result_object.header = ""
        result_object.name = "quran_order"
        return result_object
Exemplo n.º 15
0
Arquivo: deck.py Projeto: nano13/tambi
    def count(self, c, args):
        result_object = Result()

        deck_prefix = None
        try:
            deck_prefix = args[0]
        except IndexError:
            """ everything is fine, we just do not have an argument """
            pass

        deckpath = self.config.readPath("vocable", "deckpath")
        root, dirs, path = next(iter(os.walk(deckpath)))
        dirs.sort()

        counter = 0
        for directory in dirs:
            try:
                if directory.startswith(deck_prefix):
                    db_path = os.path.join(root, directory, "database.sqlite")
                    self.dbAdapter.initialize(db_path)
                    result = self.dbAdapter.count()
                    counter += int(result)
            except TypeError:
                db_path = os.path.join(root, directory, "database.sqlite")
                self.dbAdapter.initialize(db_path)
                result = self.dbAdapter.count()
                counter += int(result)

        result_object.category = "string"
        result_object.payload = str(counter)

        return result_object
Exemplo n.º 16
0
Arquivo: gps.py Projeto: nano13/tambi
    def stop_log(self, c, a):
        self.terminate_log_thread = True
        self.log_thread_running = False

        result_object = Result()
        result_object.category = "text"
        result_object.payload = "gps logging stopped"
        return result_object
Exemplo n.º 17
0
    def history(self, c, args):
        history = History("history_sword")
        if len(args) < 1:
            result = history.historyReadAll()
        else:
            result = history.historyReadAllWithFilter(args[0])

        result_object = Result()
        result_object.payload = result[::-1]
        result_object.category = "list"
        return result_object
Exemplo n.º 18
0
    def listCanons(self, c, a):
        canons = pysword_canons.canons

        result = []
        for key, value in canons.items():
            result.append(key)

        result_object = Result()
        result_object.category = 'list'
        result_object.payload = result
        return result_object
Exemplo n.º 19
0
    def word(self, command, args):
        connection = sqlite3.connect(
            os.path.join(MODULE_PATH, 'TRi.bbl.mybible'))
        cursor = connection.cursor()

        try:
            book_id = self.booksDict(args[0])
        except:
            result_object = Result()
            result_object.error = 'ERROR: You have to specify a book! See command "bituza.books" for a list of the possible book names!'
            return result_object
        else:
            if len(args) == 1:
                result_object = Result()
                result_object.error = 'ERROR: You have to specify at least a chapter!'
                return result_object
            elif len(args) == 2:
                query = "SELECT Chapter, Verse, Scripture FROM Bible WHERE Book=? AND Chapter=?"
                cursor.execute(query, [book_id, args[1]])
            elif len(args) == 3:
                if args[2].find('-') == -1:
                    query = "SELECT Chapter, Verse, Scripture FROM Bible WHERE Book=? AND Chapter=? AND Verse=?"
                    cursor.execute(query, [book_id, args[1], args[2]])
                else:
                    verse_min, verse_max = args[2].split('-')
                    query = "SELECT Chapter, Verse, Scripture FROM Bible WHERE Book=? AND Chapter=? AND Verse>=? AND Verse<=?"
                    cursor.execute(query,
                                   [book_id, args[1], verse_min, verse_max])

            result = cursor.fetchall()

            if command == 'esword.word' or command == 'esword':
                payload = []
                for i, verse in enumerate(result):
                    payload.append(
                        [verse[0], verse[1],
                         self.parseText(verse[2])])
                category = 'text'
            elif command == 'esword.interlinear':
                payload = []
                for i, verse in enumerate(result):
                    parsed = self.parseInterlinear(result[i][2])
                    """ flatten the output:"""
                    for item in parsed:
                        """ to show the chapter, verse, greek, english ..."""
                        payload.append(
                            [result[i][0], result[i][1], item[0], item[1]])
                    #payload.append(parsed)
                category = 'table'

            result_object = Result()
            result_object.category = category
            result_object.payload = payload
            return result_object
Exemplo n.º 20
0
    def chord(self, c, args):
        from modules.frets.chords import Chords

        chords = Chords()
        result = chords.getAkkorde('dur')
        print(result)

        result_object = Result()
        result_object.category = "table"
        result_object.payload = result
        result_object.header = ['grundton', 'terz', 'quinte']
        return result_object
Exemplo n.º 21
0
    def capo(self, c, args):
        scale = [
            "c", "cis", "d", "dis", "e", "f", "fis", "g", "gis", "a", "ais",
            "b"
        ]
        result = self.frets("frets", scale[::-1])

        if len(args) == 0:
            #result.Payload.TableColorVertical = None
            return result
        else:
            if not args[0].isdigit():
                result_object = Result()
                result_object.error = 'invalid parameter: parameter has to be a number!'
                return result_object

            args = args[::-1]
            args.append("0")
            args = args[::-1]

            table = result.payload
            head = result.header

            table_new = []
            row_new = []
            head_new = []

            for fret in args:
                head_new.append(fret)

                for row_num, row in enumerate(table):

                    #for item in row:
                    #    row_new.append(item[5])
                    row_new.append(row[int(fret)])

                    if len(table_new) < len(scale):
                        table_new.append(row_new)
                    else:
                        row_a = table_new[row_num]
                        row_a.append(row[int(fret)])

                    row_new = []

            #self.ResultObject.Payload.Table = table_new
            #self.ResultObject.Payload.TableHeader = head_new
            #self.ResultObject.Payload.TableColorVertical = None
            #return self.ResultObject
            result_object = Result()
            result_object.category = "table"
            result_object.payload = table_new
            result_object.header = head_new
            return result_object
Exemplo n.º 22
0
    def books(self, c, a):
        query = "SELECT name_intern FROM books"
        self.initDbConnection()
        self.cursor.execute(query)
        result = self.cursor.fetchall()

        result_object = Result()
        result_object.category = "table"
        result_object.header = ["name_intern"]
        result_object.payload = result
        result_object.name = "bituza.books"
        return result_object
Exemplo n.º 23
0
    def setCanon(self, c, args):
        result_object = Result()

        canons = self.listCanons(None, None)
        if len(args) > 0 and args[0] in canons.payload:
            self.canon = args[0]
            result_object.payload = 'canon changed to: ' + args[0]
        else:
            result_object.error = 'no canon specified or canon unknown'

        result_object.category = 'list'
        return result_object
Exemplo n.º 24
0
 def fonts(self, c, args):
     filter_str = None
     if len(args) > 0:
         filter_str = str(args[0])
     
     fonts = UnicodeFonts()
     available_fonts = fonts.printFonts(filter_str)
     
     result_object = Result()
     result_object.category = 'list'
     result_object.payload = available_fonts
     return result_object
Exemplo n.º 25
0
Arquivo: gps.py Projeto: nano13/tambi
    def __logging(self, log_db_name):
        result_object = Result()

        dbpath = os.path.join(self.logpath, log_db_name)
        dbAdapter = DbAdapter(dbpath)

        try:
            position = self.getPosition()
        except NoFixError:
            result_object.category = "text"
            result_object.payload = "no gps fix available"
        else:
            if position:
                dbAdapter.insertLogEntryWithTimestamp(position)
                result_object.payload = 'position logging started'
            else:
                result_object.payload = 'no working position provider found'

            result_object.category = "text"

        return result_object
Exemplo n.º 26
0
    def stats(self, c, a):
        dictOT = self.booksDictOT()
        dictAT = self.booksDictNT()

        try:
            book_id = dictOT[a[0]]
        except:
            try:
                book_id = dictAT[a[0]]
            except:
                result = Result()
                result.error = "FEHLER: bitte Buch angeben!"
                return result
        try:
            chapter = a[1]
        except:
            result = Result()
            result.error = "FEHLER: bitte Kapitel angeben!"
            return result

        query_head = "SELECT book_string, chapter, verse, stats_verse, total_v, total_k, total_b, sum_v, sum_k, sum_b FROM stats NATURAL JOIN structure "

        if len(a) == 2:
            query_tail = "WHERE book_id=? AND chapter=?"
            values = book_id, chapter
        elif len(a) == 3:
            if a[2].find("-") > -1:
                start_verse, end_verse = a[2].split("-")
                query_tail = "WHERE book_id=? AND chapter=? AND verse>=? AND verse<=?"
                values = book_id, chapter, start_verse, end_verse
            else:
                query_tail = "WHERE book_id=? AND chapter=? AND verse=?"
                verse = a[2]
                values = book_id, chapter, verse

        query = query_head + query_tail

        self.initDbConnection()
        self.cursor.execute(query, values)
        result = self.cursor.fetchall()

        head = "buch", "kapitel", "vers", "stats_verse", "total_v", "total_k", "total_b", "sum_v", "sum_k", "sum_b"
        metaLang = "de", "de", "de", "de", "de", "de", "de", "de", "de", "de"
        name = "stats"

        result_object = Result()
        result_object.category = "table"
        result_object.header = head
        result_object.payload = result
        result_object.metaload = metaLang
        result_object.name = name
        return result_object
Exemplo n.º 27
0
 def modules(self, c, a):
     base, dirs, files = next(iter(os.walk('./modules')))
     dirs.sort()
     try:
         dirs.remove('__pycache__')
     except ValueError:
         # if __pycache__ does not exists, we do not have do do here anything
         pass
     
     result_object = Result()
     result_object.category = "list"
     result_object.payload = dirs
     return result_object
Exemplo n.º 28
0
    def listLanguages(self, c, a):
        result_object = Result()

        result = []
        modules = SwordModules()
        try:
            found_modules = modules.parse_modules()
        except FileNotFoundError:
            result_object.category = "error"
            result_object.error = "no sword modules could be found!"
        else:
            for main_key in found_modules:
                language = found_modules[main_key]['lang']

                if not language in result:
                    result.append(language)

            result = sorted(result)
            result_object.category = "list"
            result_object.payload = result

        return result_object
Exemplo n.º 29
0
 def tableOfContents(self, c, a):
     base, dirs, files = next(iter(os.walk(MODULE_PATH)))
     
     result = []
     for f in files:
         splitted = f.split('.')
         if splitted[1] == 'md':
             result.append(splitted[0])
     
     result_object = Result()
     result_object.category = 'list'
     result_object.payload = sorted(result)
     return result_object
Exemplo n.º 30
0
    def commands(self, none1, none2):
        dic = self.getCommands()

        commands = sorted(dic.items())

        all_commands = []
        for key in commands:
            line = str(key).split(",")[0]
            all_commands.append(str(line[2:-1]))

        result_object = Result()
        result_object.category = "list"
        result_object.payload = all_commands
        return result_object