Example #1
0
import time
import SimpleHTTPServer
import SocketServer
import helper

HOST_NAME = '127.0.0.1'
PORT_NUMBER = 6446
h = helper.Helper()


class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_HEAD(s):
        s.send_response(200)
        s.end_headers()

    def do_GET(s):
        responseCode = 200
        response = h.doCommand(s.path)
        s.send_response(responseCode)
        s.end_headers()
        s.wfile.write(response)

    def version_string(s):
        return "Minecraft & Openstack"


if __name__ == '__main__':
    f = open("mc2os_config.txt", "r")
    for line in f:
        line = line.replace("\n", "")
        if line.startswith("LISTEN"):
Example #2
0
 def do_showfav(self, args):
     search = helper.Helper(args, "showfav")
     search.process()
Example #3
0
 def do_search(self, args):
     """ Search """
     search = helper.Helper(args, "search")
     search.process()
Example #4
0
        "trials": 1,
        "merging_thr": [1.0],
        "merging_iter": [1],
        "min_tweets": [9],
        "min_gradient": [0.0],
        "entropy_thr": [0],
        "named_entities": [11]
    }


'''
    This is the main method, where we apply all filters and merge clusters.
'''

if __name__ == "__main__":
    helper = helper.Helper()
    number_trials = Constants.PARAMS["trials"]
    sys.setrecursionlimit(
        10000
    )  # had to do that because neighbour calculation is too deeply nested for default value

    # returns a list for all tweets and a dict of initial clusters
    init_tweets, init_clusters = helper.read_clusters_sorted_by_time(
        DataFiles.CLUSTERS_SORTED_BY_TIME, DataFiles.NAMED_ENTITIES)

    # We iterate to perform event detection with different set of parameters in order to find highest
    # accuracy/recall and f-values
    for i in range(number_trials):
        print i
        min_tweets = Constants.PARAMS["min_tweets"][i]
        named_ent_thr = Constants.PARAMS["named_entities"][i]
Example #5
0
 def __init__(self, dataSpreadsheetName, numModelSteps):
     import helper
     self.dataSpreadsheetName = dataSpreadsheetName
     self.numModelSteps = numModelSteps
     self.helper = helper.Helper()
Example #6
0
    def create(self, Sql, send, sleep, cfg, gmt):

        ### can be configured custom ###

        limit = 40  # Raid Limit

        ################################

        Help = helper.Helper()
        overview = ""
        team = ""
        ex_raid = ""
        lvl_icon = ""
        clock = cfg.clockformat
        raid_level = cfg.level
        l8 = ""
        l7 = ""
        l6 = ""
        l5 = ""
        l4 = ""
        l3 = ""
        l2 = ""
        l1 = ""

        i = 0  # all found raids
        x = 0  # raids that will be send
        x_old = 0  # old raids
        id = 0

        now = datetime.datetime.now()
        print("\n\n####################==========\\ *** Raid *** Update " +
              cfg.areaName + cfg.areaNumber + " " +
              now.strftime("%m/%d/%Y, %H:%M:%S") +
              " /==========####################\n")

        try:
            for encounter in Sql.gym_id:
                name = "Unknown Area" if Sql.name[i] is None else Sql.name[i]
                level = Sql.level[i]
                zeit_start = Sql.start[i]
                zeit_end = Sql.end[i]

                zeit_start = zeit_start + datetime.timedelta(hours=gmt)
                zeit_end = zeit_end + datetime.timedelta(hours=gmt)

                if clock == 12:
                    t_start = time.strptime(
                        str(zeit_start.hour) + ":" +
                        Help.nice_time(str(zeit_start.minute)), "%H:%M")
                    t_end = time.strptime(
                        str(zeit_end.hour) + ":" +
                        Help.nice_time(str(zeit_end.minute)), "%H:%M")
                    raid_start = time.strftime("%I:%M %p", t_start)
                    raid_end = time.strftime("%I:%M %p", t_end)
                else:
                    raid_start = str(zeit_start.hour) + ":" + \
                        str(Help.nice_time(str(zeit_start.minute)))
                    raid_end = str(zeit_end.hour) + ":" + \
                        str(Help.nice_time(str(zeit_end.minute)))

                ex_raid = " \u274C " if Sql.ex_raid[i] == 1 else " "

                # set team ICONS
                if Sql.team_id[i] == 2:
                    team = "\u2764"  # red
                elif Sql.team_id[i] == 3:
                    team = "\U0001F49B"  # yellow
                elif Sql.team_id[i] == 1:
                    team = "\U0001F499"  # blue
                else:
                    team = "\U0001F90D"  # none

                # set raid level ICONS
                if level == 8:
                    lvl_icon = "\u0038\uFE0F\u20E3"
                    mega = "Mega "
                elif level == 7:
                    lvl_icon = "\u0037\uFE0F\u20E3"
                    mega = "Mega "
                elif level == 6:
                    lvl_icon = "\u0036\uFE0F\u20E3"
                    mega = "Mega " if Sql.evolution[i] > 0 else " "
                elif level == 5:
                    lvl_icon = "\u0035\uFE0F\u20E3"
                    mega = " "
                elif level == 4:
                    lvl_icon = "\u0034\uFE0F\u20E3"
                    mega = " "
                elif level == 3:
                    lvl_icon = "\u0033\uFE0F\u20E3"
                    mega = " "
                elif level == 2:
                    lvl_icon = "\u0032\uFE0F\u20E3"
                    mega = " "
                elif level == 1:
                    lvl_icon = "\u0031\uFE0F\u20E3"
                    mega = " "

                # set pokemon form name
                if self.getForm(Sql.form[i], cfg.language):
                    getform = "(" + \
                        self.getForm(Sql.form[i], cfg.language) + ")"
                else:
                    getform = ""

                # set pokemon costume name
                if self.getCostume(Sql.costume[i], cfg.language):
                    getcostume = "(" + \
                        self.getCostume(Sql.costume[i], cfg.language) + ")"
                else:
                    getcostume = ""

                # get mega evolution
                if Sql.evolution[i] == 3:
                    evolution = " Y"
                elif Sql.evolution[i] == 2:
                    evolution = " X"
                else:
                    evolution = ""

                if Sql.pokemon_id[i] is None:
                    kurzattacke = ""
                    ladeattacke = ""
                    move = ""
                    moveV = ""
                    raid = self.getText("egg", cfg.language) + " \U0001F95A "
                else:
                    kurzattacke = "\n├ " + \
                        self.getShortAttack(Sql.move_1[i], cfg.language)
                    ladeattacke = self.getLoadAttack(Sql.move_2[i],
                                                     cfg.language)
                    move = kurzattacke + "/" + ladeattacke
                    moveV = "\u2694 " + self.getShortAttack(
                        Sql.move_1[i],
                        cfg.language) + "/" + self.getLoadAttack(
                            Sql.move_2[i], cfg.language)
                    raid = str(mega) + self.getPokemon(
                        Sql.pokemon_id[i],
                        cfg.language) + getform + getcostume + str(
                            evolution) + " " + self.getGeschlecht(
                                Sql.gender[i]) + " "

                if Sql.level[i] in (raid_level):
                    with open(cfg.areaName + cfg.areaNumber +
                              "/eggs.txt") as input:
                        data = input.read()
                        data = data.replace("[",
                                            "").replace("'",
                                                        "").replace("]", "")
                        data = data.split(', ')

                    bolt_line = str(lvl_icon) + " " + str(raid) + \
                        raid_start + " - " + raid_end
                    normal_line = str(team) + " " + str(name) + ex_raid + moveV

                    if send.list_output.__contains__(encounter):
                        f = open(cfg.areaName + cfg.areaNumber + "/output.txt",
                                 "r")
                        # Split the string based on space delimiter
                        list_string = f.read()
                        list_string = list_string[1:len(list_string) - 1]
                        f.close()
                        list_string = list_string.split(', ')
                        id = list_string[send.list_output.index(encounter)]

                        pos = list_string.index(id)
                        egg = data[pos]
                        send.eggs.__contains__(encounter)

                        print("\n" + str(name) + " (ID: " + str(id) +
                              ", index: " + str(pos) + ")")
                        print("egg: " + str(egg))

                        x_old += 1

                        if egg == encounter and not Sql.pokemon_id[
                                i] == None and cfg.singlechatId:
                            send.changeBossEgg(bolt_line, normal_line,
                                               encounter, Sql.latitude[i],
                                               Sql.longitude[i], id, pos)

                    else:
                        print("===> found [" + str(i) + "] level " +
                              str(level) + " " + str(raid))
                        if cfg.singlechatId:
                            try:
                                id = send.send(bolt_line, normal_line,
                                               encounter, Sql.latitude[i],
                                               Sql.longitude[i],
                                               Sql.pokemon_id[i])
                            except:
                                print(
                                    "Fehler beim senden... Warte 60 Sekunden")
                                time.sleep(60)
                                id = send.send(bolt_line, normal_line,
                                               encounter, Sql.latitude[i],
                                               Sql.longitude[i],
                                               Sql.pokemon_id[i])
                    x += 1

                    header = "\n<b>## Level " + \
                        str(lvl_icon) + " Raids</b> \U0001F44A\n"

                    if cfg.singlechatId:
                        linked = cfg.singlechatUrl + "/" + str(id)
                    else:
                        linked = "https://maps.google.de/?q=" + \
                            str(Sql.latitude[i]) + ", " + str(Sql.longitude[i])

                    if x <= limit:
                        if not l8 and level == 8:
                            l8 = header
                            overview = overview + l8
                        if not l7 and level == 7:
                            l7 = header
                            overview = overview + l7
                        if not l6 and level == 6:
                            l6 = header
                            overview = overview + l6
                        if not l5 and level == 5:
                            l5 = header
                            overview = overview + l5
                        if not l4 and level == 4:
                            l4 = header
                            overview = overview + l4
                        if not l3 and level == 3:
                            l3 = header
                            overview = overview + l3
                        if not l2 and level == 2:
                            l2 = header
                            overview = overview + l2
                        if not l1 and level == 1:
                            l1 = header
                            overview = overview + l1

                        overview += "<b>" + str(team) + str(
                            raid
                        ) + raid_start + " - " + raid_end + "</b>" + str(
                            move) + "\n└ <a href='" + linked + "'>" + str(
                                name) + "</a>" + str(ex_raid) + "\n"
                    elif x == limit + 1:
                        overview += "\n\U00002514 Limit der Liste erreicht...\n"
                i += 1
            send.sendOverview(overview, self.getText("noRaids", cfg.language),
                              x, x_old)
            print("\nAktuell " + str(x) + " Raids (old: " + str(x_old) +
                  ", DB: " + str(i) + ")\n")

            # DEBUG:
            #f = open("TEST.txt", "a")
            # f.writelines("\n\n####################==========\\ " + str(datetime.datetime.now()) + " /==========####################")
            #f.writelines("len ==> " + str(len(overview)) + "\n")
            # f.writelines(str(overview))
            # f.close()

        except Exception as e:
            outF = open(Sql.areaName + cfg.areaNumber + "/error.txt", "w")
            ausgabe = "Passierte in der CreateMessage.py\n"
            ausgabe += "gym_id: " + str(Sql.gym_id.__len__) + "\n"
            ausgabe += "team_id: " + str(Sql.team_id.__len__) + "\n"
            ausgabe += "name: " + str(Sql.name.__len__) + "\n"
            ausgabe += "latitude: " + str(Sql.latitude.__len__) + "\n"
            ausgabe += "longitude: " + str(Sql.longitude.__len__) + "\n"
            ausgabe += "level: " + str(Sql.level.__len__) + "\n"
            ausgabe += "start: " + str(Sql.start.__len__) + "\n"
            ausgabe += "end: " + str(Sql.end.__len__) + "\n"
            ausgabe += "pokemon_id: " + str(Sql.pokemon_id.__len__) + "\n"
            ausgabe += "move_1: " + str(Sql.move_1.__len__) + "\n"
            ausgabe += "move_2: " + str(Sql.move_2.__len__) + "\n"
            ausgabe += "gender: " + str(Sql.gender.__len__) + "\n"
            ausgabe += "ex_raid: " + str(Sql.ex_raid.__len__) + "\n"
            ausgabe += "form: " + str(Sql.form.__len__) + "\n"
            ausgabe += "costume: " + str(Sql.costume.__len__) + "\n"
            ausgabe += "Wert i" + str(i) + "\n"
            outF.writelines(ausgabe + str(e))
            outF.close()
Example #7
0
import helper

help = helper.Helper()

help.fibonacci(5)
print("=============")
helper.Helper.fibonacci(10)
Example #8
0
import unittest

import helper as h

helper = h.Helper()


class TestGetMaxOverRange(unittest.TestCase):
    def test_normal_range(self):
        test_array = list(range(4))
        self.assertEqual(
            helper.get_max_over_range(test_array, 0, len(test_array)), 3)

    def test_restrictive_range(self):
        test_array = list(range(5))
        self.assertEqual(
            helper.get_max_over_range(test_array, 0,
                                      len(test_array) - 1), 3)


class TestGetDiffs(unittest.TestCase):
    def test_normal_array(self):
        test_array = list(range(3))
        expected_array = [(0, -1), (1, -1), (1, 0)]
        self.assertEqual(helper.get_diffs(test_array), expected_array)


if __name__ == '__main__':
    unittest.main()
Example #9
0
    def __init__(self, message):
        self.hasher = helper.Helper(message)

        self.msg = message
        self.message_length = len(message)
Example #10
0
import helper
object = helper.Helper()
object.plot_original()
object.change_basis()
object.show_changed()
object.full_reconstruction()
object.show_full_reconstructed()
Example #11
0
# starting server
import os
import helper as help_modules


def server_trigger():
    aux.update_bot_repo_path(f'{aux.bot_repo_path}\\bot-server')
    aux.change_working_path()
    os.system("python main.py")


aux = help_modules.Helper()
aux.reset_dir_to_parent_dir()
server_trigger()
Example #12
0
    def create(self, send, sql, cfg, timer, newMessageAfter, gmt):

        ### can be configured custom ###

        rb_limit = 48  # Boss Limit
        rr_limit = 45  # Rüpel Limit
        lm_limit = 48  # Lockmodul Limit
        rb_types = [41, 42, 43, 44]  # Boss Types
        lm_types = [501, 502, 503, 504, 505]  # Lockmodul Types
        newSortAfterLimit = True  # True or False

        ################################

        Help = helper.Helper()
        stop = stopType.stopType()
        i = 0
        rb_sum = 0
        rr_sum = 0
        rb = 0
        rr = 0
        old_rr = 0
        lm = 0
        boss_message = send.oldBossMessage
        message = ""
        lockmodul_message = ""
        changed = True

        if timer > newMessageAfter:
            timer = 0

        if cfg.chatId != cfg.singlechatId:
            newSend = newMessageAfter - timer
            print("Rüpel Liste neu Senden in " + str(newSend) + " Sekunden")

        if newSortAfterLimit == 1:
            with open(cfg.areaName + cfg.areaNumber + "/output.txt") as input:
                arrays = json.load(input)
                anzahl_rr = len(arrays)
            rr_list_limit = rr_limit - 1

        #now time
        now = datetime.datetime.now()
        print("\n\n####################==========\\ *** Rocket *** Update " +
              cfg.areaName + " " + now.strftime("%m/%d/%Y, %H:%M:%S") +
              " /==========####################\n")
        print("gefundene Pokestops: " + str(len(sql.name)) + "\n")

        for name in sql.Lname:
            stop.getType(sql.Lincident_grunt_type[lm])
            lm += 1

        # Output for Console
        for typ in sql.incident_grunt_type:
            if typ in (rb_types):
                rb_sum += 1
            else:
                rr_sum += 1

        for name in sql.name:
            stopName = "Unknown Stop" if name is None else name
            if send.list_output.__contains__(name) and cfg.rocketStops == True:
                f = open(cfg.areaName + cfg.areaNumber + "/output.txt", "r")
                # Split the string based on space delimiter
                list_string = f.read()
                list_string = list_string[1:len(list_string) - 1]
                f.close()
                list_string = list_string.split(', ')
                zeit = sql.incident_expiration[i]
                zeit = zeit + datetime.timedelta(hours=gmt)
                stop.getType(sql.incident_grunt_type[i])
                id = list_string[send.list_output.index(name)]

                if cfg.singlechatId:
                    linked = cfg.singlechatUrl + "/" + str(id)
                else:
                    linked = "https://maps.google.de/?q=" + str(
                        sql.latitude[i]) + ", " + str(sql.longitude[i])

                # update nachricht
                if sql.incident_grunt_type[i] not in (rb_types):
                    if newSortAfterLimit == True:
                        if anzahl_rr > rr_limit:
                            message = "\u270BLimit der Liste erreicht...\n\U00002514 <b>" + str(
                                rr_limit -
                                rr_list_limit) + "</b> Stops ausgeblendet\n\n"
                            rr_limit += 1
                        else:
                            message += stop.Emoji + "<a href='" + linked + "'>" + str(
                                stopName) + "</a>" + "\n\U00002514 <b>" + str(
                                    zeit.hour) + ":" + str(
                                        Help.nice_time(str(zeit.minute))
                                    ) + "</b> " + stop.Infotext + "\n"
                    else:
                        if rr < rr_limit:
                            message += stop.Emoji + "<a href='" + linked + "'>" + str(
                                stopName) + "</a>" + "\n\U00002514 <b>" + str(
                                    zeit.hour) + ":" + str(
                                        Help.nice_time(str(zeit.minute))
                                    ) + "</b> " + stop.Infotext + "\n"
                        elif rr == rr_limit + 1:
                            message += "\n\U00002514 Limit der Liste erreicht...\n"
                    rr += 1
                    old_rr += 1
            elif send.list_boss_output.__contains__(name):
                stop.getType(sql.incident_grunt_type[i])
                if sql.incident_grunt_type[i] in (rb_types):
                    rb += 1
            else:
                if cfg.rocketStops == True or sql.incident_grunt_type[i] in (
                        rb_types):
                    latitude = sql.latitude[i]
                    longitude = sql.longitude[i]
                    stop.getType(sql.incident_grunt_type[i])
                    zeit = sql.incident_expiration[i]
                    zeit = zeit + datetime.timedelta(hours=gmt)
                    #print("... verarbeite Pokestop: " + str(stopName))

                    bolt_line = str(zeit.hour) + ":" + str(
                        Help.nice_time(str(
                            zeit.minute))) + " " + stop.Emoji + stop.Infotext

                    if cfg.singlechatId:
                        id = send.singleStops(bolt_line, name, latitude,
                                              longitude,
                                              sql.incident_grunt_type[i],
                                              lm_types, rb_types)
                        linked = cfg.singlechatUrl + "/" + str(id)
                    else:
                        linked = "https://maps.google.de/?q=" + str(
                            sql.latitude[i]) + ", " + str(sql.longitude[i])

                    # erste Nachricht
                    if sql.incident_grunt_type[i] in (rb_types):
                        print("Send " + str(rb + 1) + "/" + str(rb_sum) +
                              " ===> " + "Rocket BOSSE: " + str(stopName))
                        rb += 1
                    else:
                        if rr < rr_limit:
                            message += stop.Emoji + "<a href='" + linked + "'>" + str(
                                stopName) + "</a>" + "\n\U00002514 <b>" + str(
                                    zeit.hour) + ":" + str(
                                        Help.nice_time(str(zeit.minute))
                                    ) + "</b> " + stop.Infotext + "\n"
                        #elif rr == rr_limit+1:
                        #  message += "\n\U00002514 Limit der Liste erreicht...\n"
                        print("Send " + str(rr + 1) + "/" + str(rr_sum) +
                              " ===> " + "Rocket RÜPEL: " + str(stopName))
                        rr += 1
            i += 1

        if rb == send.list_boss_output.__len__():
            changed = False
            print("Finish !\n")
            if rb > 0:
                print("Rocket Bosse: " + str(rb))
            if rr > 0:
                print("Rocket Rüpel: " + str(rr))
        if changed:
            print("changed: " + str(rb))
        boss_message = self.list_boss(send, sql, cfg, rb_types, rb_limit, gmt)
        bossid = send.sendBoss(boss_message, rb)

        if cfg.lureModule == True:
            lockmodul_message = self.list_lockmodul(send, sql, cfg, lm_types,
                                                    rb_types, lm_limit, gmt)
            send.sendLockmodul(True, lockmodul_message)

        # define lists
        listLM = stop.Sstandard + stop.Sgletscher + stop.Smoos + stop.Smagnet + stop.Sregen
        listRR = stop.Srelaxo + stop.Skarpador + stop.Skanto + stop.Snormal + stop.Swasser + stop.Sfeuer + stop.Sdrache + stop.Sflug + stop.Spflanze + stop.Skaefer + stop.Sboden + stop.Sgestein + stop.Sgift + stop.Spsycho + stop.Skampf + stop.Seis + stop.Sgeist + stop.Selektro + stop.Sfee + stop.Sstahl + stop.Sunlicht
        listRB = stop.Scliff + stop.Sarlo + stop.Ssierra + stop.Sgiovanni

        print("\nListen:\n")

        print("LM: " + listLM)
        print("RR: " + listRR)
        print("RB: " + listRB + "\n")

        if listLM:
            listLM = "L: " + listLM + "\n"

        if listRR:
            listRR = "R: " + listRR + "\n"

        if listRB:
            listRB = "B: " + listRB + "\n"

        message_overview_rocket = listLM + listRR + listRB + "\n" + "<b>Aktuell " + str(
            rr
        ) + " <a href='" + cfg.chatUrl + "/'>Team Rocket Stops:</a></b> \n\n"

        if not rb == 0:
            message += "\n <a href='" + cfg.chatUrl + "/" + str(
                bossid) + "'>" + "<b>Hier gehts zu den Bossen</b></a>"

        if cfg.rocketStops == True:
            #lockmodul_message = self.list_lockmodul(send,sql,cfg,lm_types,rb_types,lm_limit,gmt)
            send.sendOverview(message_overview_rocket + message, rb, rr,
                              old_rr, lockmodul_message, lm, timer,
                              newMessageAfter)
Example #13
0
    def list_lockmodul(self, send, sql, cfg, lm_types, rb_types, lm_limit,
                       gmt):
        lockmodul_message = ""
        message_overview_lockmodul = ""
        Help = helper.Helper()
        stop = stopType.stopType()
        i = 0
        lm = 0
        for name in sql.Lname:
            stopName = "Unknown Stop" if name is None else name
            if send.list_lockmodul_output.__contains__(name):
                f = open(
                    cfg.areaName + cfg.areaNumber + "/lockmodul-output.txt",
                    "r")
                # Split the string based on space delimiter
                list_string = f.read()
                list_string = list_string[1:len(list_string) - 1]
                f.close()
                list_string = list_string.split(', ')
                zeit = sql.Lincident_expiration[i]
                zeit = zeit + datetime.timedelta(hours=gmt)
                stop.getType(sql.Lincident_grunt_type[i])
                id = list_string[send.list_lockmodul_output.index(name)]

                if cfg.singlechatId:
                    linked = cfg.singlechatUrl + "/" + str(id)
                else:
                    linked = "https://maps.google.de/?q=" + str(
                        sql.Llatitude[i]) + ", " + str(sql.Llongitude[i])

                if lm < lm_limit:
                    lockmodul_message += stop.Emoji + "<a href='" + linked + "'>" + str(
                        stopName) + "</a>" + "\n\U00002514 <b>" + str(
                            zeit.hour) + ":" + str(
                                Help.nice_time(str(zeit.minute))
                            ) + "</b> " + stop.Infotext + "\n"
                elif lm == lm_limit + 1:
                    lockmodul_message += "\n\U00002514 Limit der Liste erreicht...\n"
                lm += 1
                text_modul = "Modul:" if lm == 1 else "Module:"
            else:
                stop.getType(sql.Lincident_grunt_type[i])
                zeit = sql.Lincident_expiration[i]
                zeit = zeit + datetime.timedelta(hours=gmt)
                bolt_line = str(zeit.hour) + ":" + str(
                    Help.nice_time(str(
                        zeit.minute))) + " " + stop.Emoji + stop.Infotext

                if cfg.singlechatId:
                    id = send.singleStops(bolt_line, name, sql.Llatitude[i],
                                          sql.Llongitude[i],
                                          sql.Lincident_grunt_type[i],
                                          lm_types, rb_types)
                    linked = cfg.singlechatUrl + "/" + str(id)
                else:
                    linked = "https://maps.google.de/?q=" + str(
                        sql.Llatitude[i]) + ", " + str(sql.Llongitude[i])

                if lm < lm_limit:
                    lockmodul_message += stop.Emoji + "<a href='" + linked + "'>" + str(
                        stopName) + "</a>" + "\n\U00002514 <b>" + str(
                            zeit.hour) + ":" + str(
                                Help.nice_time(str(zeit.minute))
                            ) + "</b> " + stop.Infotext + "\n"
                elif lm == lm_limit + 1:
                    lockmodul_message += "\n\U00002514 Limit der Liste erreicht...\n"
                lm += 1
                text_modul = "Modul:" if lm == 1 else "Module:"
            i += 1
            message_overview_lockmodul = stop.Sstandard + stop.Sgletscher + stop.Smoos + stop.Smagnet + stop.Sregen + "\n\n" + "<b>Aktuell " + str(
                lm
            ) + " <a href='" + cfg.chatUrl + "/'>Lock " + text_modul + "</a></b> \n\n"
        return message_overview_lockmodul + lockmodul_message
Example #14
0
    def list_boss(self, send, sql, cfg, rb_types, rb_limit, gmt):
        boss_message = ""
        message_overview_boss = ""
        Help = helper.Helper()
        stop = stopType.stopType()
        i = 0
        rb = 0
        for name in sql.name:
            stopName = "Unknown Stop" if name is None else name
            if send.list_boss_output.__contains__(name):
                f = open(cfg.areaName + cfg.areaNumber + "/boss-output.txt",
                         "r")
                # Split the string based on space delimiter
                list_string = f.read()
                list_string = list_string[1:len(list_string) - 1]
                f.close()
                list_string = list_string.split(', ')
                zeit = sql.incident_expiration[i]
                zeit = zeit + datetime.timedelta(hours=gmt)
                stop.getType(sql.incident_grunt_type[i])
                id = list_string[send.list_boss_output.index(name)]

                if cfg.singlechatId:
                    linked = cfg.singlechatUrl + "/" + str(id)
                else:
                    linked = "https://maps.google.de/?q=" + str(
                        sql.latitude[i]) + ", " + str(sql.longitude[i])

                if sql.incident_grunt_type[i] in (rb_types):
                    if rb < rb_limit:
                        boss_message += stop.Emoji + "<a href='" + linked + "'>" + str(
                            stopName) + "</a>" + "\n\U00002514 <b>" + str(
                                zeit.hour) + ":" + str(
                                    Help.nice_time(str(zeit.minute))
                                ) + "</b> " + stop.Infotext + "\n"
                    elif rb == rb_limit + 1:
                        boss_message += "\n\U00002514 Limit der Liste erreicht...\n"
                    rb += 1
            elif not cfg.singlechatId:
                stop.getType(sql.incident_grunt_type[i])
                zeit = sql.incident_expiration[i]
                zeit = zeit + datetime.timedelta(hours=gmt)

                linked = "https://maps.google.de/?q=" + str(
                    sql.latitude[i]) + ", " + str(sql.longitude[i])

                if sql.incident_grunt_type[i] in (rb_types):
                    if rb < rb_limit:
                        boss_message += stop.Emoji + "<a href='" + linked + "'>" + str(
                            stopName) + "</a>" + "\n\U00002514 <b>" + str(
                                zeit.hour) + ":" + str(
                                    Help.nice_time(str(zeit.minute))
                                ) + "</b> " + stop.Infotext + "\n"
                    elif rb == rb_limit + 1:
                        boss_message += "\n\U00002514 Limit der Liste erreicht...\n"
                    rb += 1
            i += 1
            if not rb == 0:
                message_overview_boss = stop.Scliff + stop.Sarlo + stop.Ssierra + stop.Sgiovanni + "\n\n" + "<b>Aktuell " + str(
                    rb
                ) + " <a href='" + cfg.chatUrl + "/'>Rocket Boss Stops:</a></b> \n\n"
        return message_overview_boss + boss_message
Example #15
0
#! python3
#coding=utf8

import output_manager as OM
import ut
import helper
from feature_pipline import fpipline

# MODE = 'develop'
# MODE = 'test'
MODE = 'run'

SOURCE_FOLDER = u'd:/BaiduYunDownload/课程源数据/'
RESEARCH_FILE = SOURCE_FOLDER + 'mooc_research.txt'
om = OM.output_manager(MODE)
hp = helper.Helper(om)


def datapipline(folder, courseID):
    om.runtimel('ready to start data-pipline for ' + courseID)
    ut.columnFilter(folder, om)
    om.runtimel('finish column filter for ' + courseID)
    hp.loadCourseTerm(courseID)
    om.runtimel('successful load Course Term Mapping for ' + courseID)
    # ut.fillMissing(folder, om)
    # om.runtimel('successful filling missing columns for ' + courseID)
    om.runtimel('successful finish data-pipline for ' + courseID)


def featurepipline(courseID):
    om.runtimel('ready to start feature-pipline for ' + courseID)
Example #16
0
 def do_doc(self, args):
     """ Display Script Documentaion"""
     doc = helper.Helper(args)
     doc.displayDoc()
Example #17
0
    # Initialize Auth
    config.authenticator.add_discord_client(client)

    # Initialize Merbs List
    t_start = timer()
    merbs = npc.MerbList(config.FILE_ENTITIES, config.FILE_TIMERS,
                         config.FILE_TARGETS, config.DATE_FORMAT,
                         config.DATE_FORMAT_PRINT)
    merbs.order()
    t_end = timer()
    logger_sirken.info("Loading Merbs. Done in %s seconds" %
                       (round(t_end - t_start, 5)))

    # Load Helper
    t_start = timer()
    helper = helper.Helper(config.HELP_DIR)
    t_end = timer()
    logger_sirken.info("Loading Help. Done in %s seconds" %
                       (round(t_end - t_start, 5)))

    # Load Watcher
    t_start = timer()
    watch = watch.Watch(config.FILE_WATCH)
    t_end = timer()
    logger_sirken.info("Loading Watcher. Done in %s seconds" %
                       (round(t_end - t_start, 5)))

    # Load Trackers
    t_start = timer()
    trackers = trackers.Trackers(config.FILE_TRACKERS, merbs)
    t_end = timer()
Example #18
0
 def do_last(self, args):
     """ last help"""
     search = helper.Helper()
     search.printlastResult()
Example #19
0
class Ui_Dialog(object):
    def __init__(self, MW_Dlg):
        self.mwD = MW_Dlg

    tName = "placeholder"
    nName = "placeholder"
    h = helper.Helper()
    Dlg = None

    #This function runs when the user clicks 'OK' and confirms that they are
    #done with name entry.  It removes the name from the appropriate list
    #on which the checkboxes rely, then refreshes the visible checkboxes.
    def okClicked(self):
        self.nName = self.lineEdit.text()
        #print 'nName : ' + self.nName
        if not (self.nName == ""):
            self.h.removeEmployee(str(self.nName))
        self.Dlg.accept()
        for entry in self.mwD.employees:
            self.tName = entry[0]
            #print 'compared to : ' + self.tName
            if self.tName == self.nName:
                #print 'found'
                self.mwD.employees.remove(entry)
        self.mwD.refreshCheckboxes()

    #Used for debug only
    def forCallback(self, D):
        return D

    #Qt code to set-up the visual modal dialog box
    def setupUi(self, Dialog):
        self.Dlg = Dialog
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.setWindowModality(QtCore.Qt.ApplicationModal)
        Dialog.resize(366, 133)
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(10, 90, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(10, 20, 200, 17))
        self.label.setObjectName(_fromUtf8("label"))
        self.lineEdit = QtGui.QLineEdit(Dialog)
        self.lineEdit.setGeometry(QtCore.QRect(10, 40, 341, 21))
        self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
        myIcon = QtGui.QIcon()
        myIcon.addPixmap(QtGui.QPixmap(_fromUtf8("./data/bobafett_icon.png")),
                         QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Dialog.setWindowIcon(myIcon)

        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.buttonBox,
                               QtCore.SIGNAL(_fromUtf8("accepted()")),
                               self.okClicked)
        QtCore.QObject.connect(self.buttonBox,
                               QtCore.SIGNAL(_fromUtf8("rejected()")),
                               Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    #Qt code to refresh the visual modal dialog box
    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(_translate("Dialog", "Remove Employee", None))
        self.label.setText(_translate("Dialog", "Employee to remove:", None))
Example #20
0
 def do_modfav(self, args):
     search = helper.Helper(args, "modfav")
     search.process()
Example #21
0
class Ui_Dialog(object):
    def __init__(self, MW_Dlg):
        self.mwD = MW_Dlg

    nColor = QtGui.QColor()
    nName = "placeholder"
    h = helper.Helper()
    Dlg = None

    #This function handles the selection of the colors from
    #a QColorDialog and sets the class's color to the result.
    def pickColor(self):
        p = self.frame.palette()
        newColor = QtGui.QColorDialog.getColor()
        p.setColor(self.frame.backgroundRole(), newColor)
        self.frame.setPalette(p)
        self.nColor = newColor

    #This function registers the user as having finished and
    #having clicked the 'OK' button.  It saves the color and
    #name string in the appropriate lists readable by the
    #rest of the program.
    def okClicked(self):
        self.nName = self.lineEdit.text()
        if not (self.nName == ""):
            rgb_vals = [000, 000, 000, 000]
            rgb_vals[0] += self.nColor.alpha()
            rgb_vals[1] += self.nColor.red()
            rgb_vals[2] += self.nColor.green()
            rgb_vals[3] += self.nColor.blue()
            self.h.addEmployee(
                str(self.nName),
                str((rgb_vals[0], rgb_vals[1], rgb_vals[2], rgb_vals[3])))
            self.Dlg.accept()
            self.mwD.employees.append([
                str(self.nName),
                str((rgb_vals[0], rgb_vals[1], rgb_vals[2], rgb_vals[3]))
            ])
            self.mwD.refreshCheckboxes()

    #This function exists only for debugging.
    def forCallback(self, D):
        return D

    #This function is Qt dynamically generated code which sets up the
    #visual look of the modal dialog window.
    def setupUi(self, Dialog):
        self.Dlg = Dialog
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.setWindowModality(QtCore.Qt.ApplicationModal)
        Dialog.resize(366, 133)
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(10, 90, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(10, 20, 121, 17))
        self.label.setObjectName(_fromUtf8("label"))
        self.label_2 = QtGui.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(10, 70, 191, 17))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.lineEdit = QtGui.QLineEdit(Dialog)
        self.lineEdit.setGeometry(QtCore.QRect(10, 40, 341, 21))
        self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
        self.pushButton = QtGui.QPushButton(Dialog)
        self.pushButton.setGeometry(QtCore.QRect(10, 90, 95, 27))
        self.pushButton.setObjectName(_fromUtf8("pushButton"))
        self.frame = QtGui.QFrame(Dialog)
        self.frame.setGeometry(QtCore.QRect(110, 89, 51, 31))
        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtGui.QFrame.Raised)
        self.frame.setObjectName(_fromUtf8("frame"))
        self.frame.setAutoFillBackground(True)
        myIcon = QtGui.QIcon()
        myIcon.addPixmap(QtGui.QPixmap(_fromUtf8("./data/bobafett_icon.png")),
                         QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Dialog.setWindowIcon(myIcon)

        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.buttonBox,
                               QtCore.SIGNAL(_fromUtf8("accepted()")),
                               self.okClicked)
        QtCore.QObject.connect(self.buttonBox,
                               QtCore.SIGNAL(_fromUtf8("rejected()")),
                               Dialog.reject)
        QtCore.QObject.connect(self.pushButton,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.pickColor)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    #Qt dynamically generated function to update the visual window
    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(_translate("Dialog", "Add Employee", None))
        self.label.setText(_translate("Dialog", "Employee to add:", None))
        self.label_2.setText(_translate("Dialog", "Preferred Color:", None))
        self.pushButton.setText(_translate("Dialog", "Select Color", None))
Example #22
0
 def complete_modfav(self, text, line, begidx, endidx):
     """ Autocomplete over the last result """
     resultitems = helper.Helper()
     return [i for i in resultitems.resultitems() if i.startswith(text)]
Example #23
0
        time.sleep(10.0)


def check_internet():
    try:
        response = requests.get("http://www.google.com")
        return True
    except Exception as e:
        print("No Internet!!")
        return False


config_load()

#Use helper to work with connection and generation os SAS tokens
help = helper.Helper(hubAddress, deviceId, sharedAccessKey)

#Creating MQTT client with desired specifications
client = mqtt.Client(deviceId, mqtt.MQTTv311)

#Define functions to deal with events
client.on_connect = on_connect
client.on_disconnect = on_disconnect
client.on_message = on_message
client.on_publish = on_publish

#Setup credentials for IoT Hub access
client.username_pw_set(help.hubUser,
                       help.generate_sas_token(help.endpoint, sharedAccessKey))

#Use cert builtin on pi
Example #24
0
from flask import Flask
from flask import request
from flask import jsonify
import graph as g
import helper as hl
from pprint import pprint

graph = g.Graph(hl.Helper().load_structure('data.json'))
app = Flask(__name__)


@app.route('/')
def index():
    return ok('Welcome to wiki-scrappy Web API!')


@app.errorhandler(400)
def not_found(error=None):
    message = {'status': 400, 'message': 'Bad Request: ' + request.url}
    response = jsonify(message)
    response.status_code = 400
    return response


def ok(data):
    response = jsonify(data)
    response.status_code = 200
    return response


def created(data):