コード例 #1
0
    def _secondPass(self, clients, loop):

        error_clients = {}

        for client, value in clients.items():

            print(client)
            client_dict = {client: None}
            name, number, button, url = clients[client]['Connect']
            website = Website(name, number, button, url)
            loop.run_until_complete(website.addWebsite())
            check = website.runCheck()

            first_check = clients[client]['Check']
            second_check = self._compare(check, name)

            if first_check == second_check:
                client_dict[client] = value
                error_clients.update(client_dict)

        return error_clients
コード例 #2
0
    def main(self):

        row = self._row
        client_links = {}
        error_clients = {}
        unreachable_clients = {'404s': [], 'Missing_Info': [], 'Selenium': []}
        keys = []
        frames = []

        loop = asyncio.get_event_loop()

        try:
            for row in self._clients:

                    name = str(row[self._columns[0]])
                    number = str(row[self._columns[1]])
                    button = str(row[self._columns[2]])
                    url = str(row[self._columns[3]])

                    if (name and number and button and url and
                        number[:3].isdigit() is True and re.search('eventplicity', button) is not None):

                        client = Website(name, number, button, url)
                        connected = loop.run_until_complete(client.addWebsite())

                        if connected != 0:
                            check = client.runCheck()

                            if check == {name: {'Index': {'Phone_Number': 0, 'Eventplicity_Link': 0}}}:
                                if len(client._extensions) > 1:
                                    compare = self._compare(check, name)
                                    if compare is not None:
                                        error_clients[name] = {'Website': client, 'Check': compare, 'Connect': [name, number, button, url]}
                                    for key, value in check.items():
                                        keys.append(key)
                                        frame = pd.DataFrame.from_dict(value, orient='index')
                                        frames.append(frame)
                                else:
                                    unreachable_clients['Selenium'].append(name)
                            else:
                                compare = self._compare(check, name)
                                if compare is not None:
                                    error_clients[name] = {'Website': client, 'Check': compare, 'Connect': [name, number, button, url]}
                                for key, value in check.items():
                                    keys.append(key)
                                    frame = pd.DataFrame.from_dict(value, orient='index')
                                    frames.append(frame)

                        else:
                            unreachable_clients['404s'].append(name)

                        links = {name: client._links}
                        client_links.update(links)

                    else:
                        unreachable_clients['Missing_Info'].append(name)

            error_clients = self._secondPass(error_clients, loop)

        finally:
            loop.close()

        self._generateData(keys, frames, client_links, unreachable_clients)
        subject, message = self._composeEmail(error_clients, unreachable_clients)

        return subject, message