Esempio n. 1
0
File: ocr.py Progetto: spammer23/MAD
    def get_screens(self):
        screens = []

        for file in glob.glob(str(self._args.raidscreen_path) + "/raidscreen_*.png"):
            creationdate = datetime.datetime.fromtimestamp(
                creation_date(file)).strftime(self._datetimeformat)

            screenJson = ({'filename': file[4:], 'creation': creationdate})
            screens.append(screenJson)

        return jsonify(screens)
Esempio n. 2
0
File: ocr.py Progetto: spammer23/MAD
    def get_gyms(self):
        gyms = []
        data = self._db.get_gym_infos()

        hashdata = json.loads(getAllHash('gym', self._db))

        for file in glob.glob("ocr/www_hash/gym_*.jpg"):
            unkfile = re.search(r'gym_(-?\d+)_(-?\d+)_((?s).*)\.jpg', file)
            hashvalue = (unkfile.group(3))

            if str(hashvalue) in hashdata:

                gymid = hashdata[str(hashvalue)]["id"]
                count = hashdata[hashvalue]["count"]
                modify = hashdata[hashvalue]["modify"]

                creationdate = datetime.datetime.fromtimestamp(
                    creation_date(file)).strftime(self._datetimeformat)

                modify = datetime.datetime.strptime(
                    modify, '%Y-%m-%d %H:%M:%S').strftime(self._datetimeformat)

                name = 'unknown'
                lat = '0'
                lon = '0'
                description = ''

                gymImage = 'gym_img/_' + str(gymid) + '_.jpg'

                if str(gymid) in data:
                    name = data[str(gymid)]["name"].replace(
                        "\\", r"\\").replace('"', '')
                    lat = data[str(gymid)]["latitude"]
                    lon = data[str(gymid)]["longitude"]
                    if data[str(gymid)]["description"]:
                        description = data[str(gymid)]["description"].replace(
                            "\\", r"\\").replace('"', '').replace("\n", "")

                gymJson = ({'id': gymid, 'lat': lat, 'lon': lon, 'hashvalue': hashvalue,
                            'filename': file[4:], 'name': name, 'description': description,
                            'gymimage': gymImage, 'count': count, 'creation': creationdate, 'modify': modify})
                gyms.append(gymJson)

            else:
                self.logger.debug("File: " + str(file) + " not found in Database")
                os.remove(str(file))
                continue

        return jsonify(gyms)
Esempio n. 3
0
File: ocr.py Progetto: spammer23/MAD
    def get_unknowns(self):
        unk = []
        for file in glob.glob("ocr/www_hash/unkgym_*.jpg"):
            unkfile = re.search(
                r'unkgym_(-?\d+\.?\d+)_(-?\d+\.?\d+)_((?s).*)\.jpg', file)
            creationdate = datetime.datetime.fromtimestamp(
                creation_date(file)).strftime(self._datetimeformat)
            lat = (unkfile.group(1))
            lon = (unkfile.group(2))
            hashvalue = (unkfile.group(3))

            hashJson = ({'lat': lat, 'lon': lon, 'hashvalue': hashvalue,
                         'filename': file[4:], 'creation': creationdate})
            unk.append(hashJson)

        return jsonify(unk)
Esempio n. 4
0
    def take_screenshot(self, origin=None, adb=False):
        origin = request.args.get('origin')
        useadb = request.args.get('adb', False)
        self._logger.info('MADmin: Making screenshot ({})', str(origin))

        devicemappings = self._mapping_manager.get_all_devicemappings()
        adb = devicemappings.get(origin, {}).get('adb', False)
        filename = generate_device_screenshot_path(origin, devicemappings, self._args)

        if useadb == 'True' and self._adb_connect.make_screenshot(adb, origin, "jpg"):
            self._logger.info('MADMin: ADB screenshot successfully ({})', str(origin))
        else:
            self.generate_screenshot(origin)

        creationdate = datetime.datetime.fromtimestamp(
            creation_date(filename)).strftime(self._datetimeformat)

        return creationdate
Esempio n. 5
0
def uploaded_files(datetimeformat, jobs):
    files = []
    for file in glob.glob(str(mapping_args.upload_path) + "/*.apk"):
        creationdate = datetime.datetime.fromtimestamp(
            creation_date(file)).strftime(datetimeformat)
        fileJson = ({
            'jobname': os.path.basename(file),
            'creation': creationdate,
            'type': 'jobType.INSTALLATION'
        })
        files.append(fileJson)

    for command in jobs:
        files.append({
            'jobname': command,
            'creation': '',
            'type': 'jobType.CHAIN'
        })

    processJson = ({
        'jobname': 'Reboot-Device',
        'creation': '',
        'type': 'jobType.REBOOT'
    })
    files.append(processJson)
    processJson = ({
        'jobname': 'Restart-Pogo',
        'creation': '',
        'type': 'jobType.RESTART'
    })
    files.append(processJson)
    processJson = ({
        'jobname': 'Stop-Pogo',
        'creation': '',
        'type': 'jobType.STOP'
    })
    files.append(processJson)
    processJson = ({
        'jobname': 'Start-Pogo',
        'creation': '',
        'type': 'jobType.START'
    })
    files.append(processJson)
    return files
Esempio n. 6
0
    def take_screenshot(self, origin=None, adb=False):
        origin = request.args.get('origin')
        useadb = request.args.get('adb', False)
        self._logger.info('MADmin: Making screenshot ({})', str(origin))
        devicemappings = self._mapping_manager.get_all_devicemappings()

        adb = devicemappings.get(origin, {}).get('adb', False)

        if useadb == 'True' and self._adb_connect.make_screenshot(
                adb, origin, "jpg"):
            self._logger.info('MADMin: ADB screenshot successfully ({})',
                              str(origin))
        else:

            screenshot_type: ScreenshotType = ScreenshotType.JPEG
            if devicemappings.get(origin, {}).get("screenshot_type",
                                                  "jpeg") == "png":
                screenshot_type = ScreenshotType.PNG

            screenshot_quality: int = devicemappings.get(origin, {}).get(
                "screenshot_quality", 80)

            temp_comm = self._ws_server.get_origin_communicator(origin)
            temp_comm.get_screenshot(
                generate_device_screenshot_path(origin, devicemappings,
                                                self._args),
                screenshot_quality, screenshot_type)

        filename = generate_device_screenshot_path(origin, devicemappings,
                                                   self._args)
        image_resize(filename,
                     os.path.join(self._args.temp_path, "madmin"),
                     width=250)

        creationdate = datetime.datetime.fromtimestamp(
            creation_date(filename)).strftime(self._datetimeformat)

        return creationdate
Esempio n. 7
0
File: ocr.py Progetto: spammer23/MAD
    def get_raids(self):
        raids = []
        eggIdsByLevel = [1, 1, 2, 2, 3]

        data = self._db.get_gym_infos()

        mondata = open_json_file('pokemon')

        hashdata = json.loads(getAllHash('raid', self._db))

        for file in glob.glob("ocr/www_hash/raid_*.jpg"):
            unkfile = re.search(r'raid_(-?\d+)_(-?\d+)_((?s).*)\.jpg', file)
            hashvalue = (unkfile.group(3))

            if str(hashvalue) in hashdata:
                monName = 'unknown'
                raidjson = hashdata[str(hashvalue)]["id"]
                count = hashdata[hashvalue]["count"]
                modify = hashdata[hashvalue]["modify"]

                raidHash_ = decodeHashJson(raidjson)
                gymid = raidHash_[0]
                lvl = raidHash_[1]
                mon = int(raidHash_[2])
                monid = int(raidHash_[2])
                mon = "%03d" % mon

                if mon == '000':
                    type = 'egg'
                    monPic = ''
                else:
                    type = 'mon'
                    monPic = 'asset/pokemon_icons/pokemon_icon_' + mon + '_00.png'
                    if str(monid) in mondata:
                        monName = i8ln(mondata[str(monid)]["name"])

                eggId = eggIdsByLevel[int(lvl) - 1]
                if eggId == 1:
                    eggPic = 'asset/static_assets/png/ic_raid_egg_normal.png'
                if eggId == 2:
                    eggPic = 'asset/static_assets/png/ic_raid_egg_rare.png'
                if eggId == 3:
                    eggPic = 'asset/static_assets/png/ic_raid_egg_legendary.png'

                creationdate = datetime.datetime.fromtimestamp(
                    creation_date(file)).strftime(self._datetimeformat)

                modify = datetime.datetime.strptime(
                    modify, '%Y-%m-%d %H:%M:%S').strftime(self._datetimeformat)

                name = 'unknown'
                lat = '0'
                lon = '0'
                description = ''

                gymImage = 'gym_img/_' + str(gymid) + '_.jpg'

                if str(gymid) in data:
                    name = data[str(gymid)]["name"].replace(
                        "\\", r"\\").replace('"', '')
                    lat = data[str(gymid)]["latitude"]
                    lon = data[str(gymid)]["longitude"]
                    if data[str(gymid)]["description"]:
                        description = data[str(gymid)]["description"].replace(
                            "\\", r"\\").replace('"', '').replace("\n", "")

                raidJson = ({'id': gymid, 'lat': lat, 'lon': lon, 'hashvalue': hashvalue, 'filename': file[4:],
                             'name': name, 'description': description, 'gymimage': gymImage,
                             'count': count, 'creation': creationdate, 'modify': modify, 'level': lvl,
                             'mon': mon, 'type': type, 'eggPic': eggPic, 'monPic': monPic, 'monname': monName})
                raids.append(raidJson)
            else:
                self._logger.debug("File: " + str(file) + " not found in Database")
                os.remove(str(file))
                continue

        return jsonify(raids)