Ejemplo n.º 1
0
 def __init__(self, oldid, name, posts, date, colour):
     User.__init__(self, oldid, name, None, posts, date, 0, colour)
     self.trust = 0
     self.img = os.path.join("usermails", "{}.png".format(clean_filename(self.name)))
Ejemplo n.º 2
0
 def __init__(self, oldid, name, posts, date, colour):
     User.__init__(self, oldid, name, None, posts, date, 0, colour)
     self.trust = 0
     self.img = os.path.join("usermails",
                             "{}.png".format(clean_filename(self.name)))
Ejemplo n.º 3
0
    def _export_(self):
        self.logger.info('Récupération du membre %d', self.oldid)

        User._export_(self)

        # Search for this user in the administration panel
        try:
            encodedname = self.name.encode("latin1")
        except UnicodeEncodeError:
            encodedname = self.name

        params = {
            "part" : "users_groups",
            "sub" : "users",
            "username" : encodedname,
            "submituser" : "Ok",
            "sort" : "user_id",
            "order" : "ASC"
        }
        response = self.session.get_admin("/admin/index.forum", params=params)

        document = PyQuery(response.text)
        for element in document('tbody tr'):
            e = PyQuery(element)
            if e("td a").eq(0).text() == self.name:
                # The user was found
                self.mail = e("td a").eq(1).text()

                if self.mail == "" and e("td a").eq(0).is_('img'):
                    # The administration panel has been blocked, the
                    # email is replaced by an image, download it
                    response = self.session.get(e("td a img").eq(0).attr("src"))
                    with open(self.img, "wb") as fileobj:
                        fileobj.write(response.content)

                    # Use the OCR on it
                    try:
                        self.mail = subprocess.check_output([self.config["gocr"], "-i", self.img],
                                                            universal_newlines=True).strip()
                    except FileNotFoundError:
                        raise GocrNotInstalled(self.config["gocr"])

                    if toolong(self.img):
                        # The image seems to be too small for the
                        # email, the user will have to confirm it
                        self.trust = 1
                    elif self.validate_email():
                        self.trust = 3
                    else:
                        # The email could not be validated, the user
                        # will have to confirm
                        self.trust = 2
                else:
                    # The administration panel hasn't been blocked
                    # yet, the email is available
                    self.trust = 3

                lastvisit = e("td").eq(4).text()
                if lastvisit != "":
                    lastvisit = lastvisit.split(" ")
                    self.lastvisit = int(time.mktime(time.struct_time(
                        (int(lastvisit[2]), month(lastvisit[1]), int(lastvisit[0]), 0, 0, 0, 0, 0,
                         0))))
                else:
                    self.lastvisit = 0
Ejemplo n.º 4
0
    def _export_(self):
        self.logger.info('Récupération du membre %d', self.oldid)

        User._export_(self)

        # Search for this user in the administration panel
        try:
            encodedname = self.name.encode("latin1")
        except UnicodeEncodeError:
            encodedname = self.name

        params = {
            "part": "users_groups",
            "sub": "users",
            "username": encodedname,
            "submituser": "******",
            "sort": "user_id",
            "order": "ASC"
        }
        response = self.session.get_admin("/admin/index.forum", params=params)

        document = PyQuery(response.text)
        for element in document('tbody tr'):
            e = PyQuery(element)
            if e("td a").eq(0).text() == self.name:
                # The user was found
                self.mail = e("td a").eq(1).text()

                if self.mail == "" and e("td a").eq(0).is_('img'):
                    # The administration panel has been blocked, the
                    # email is replaced by an image, download it
                    response = self.session.get(
                        e("td a img").eq(0).attr("src"))
                    with open(self.img, "wb") as fileobj:
                        fileobj.write(response.content)

                    # Use the OCR on it
                    try:
                        self.mail = subprocess.check_output(
                            [self.config["gocr"], "-i", self.img],
                            universal_newlines=True).strip()
                    except FileNotFoundError:
                        raise GocrNotInstalled(self.config["gocr"])

                    if toolong(self.img):
                        # The image seems to be too small for the
                        # email, the user will have to confirm it
                        self.trust = 1
                    elif self.validate_email():
                        self.trust = 3
                    else:
                        # The email could not be validated, the user
                        # will have to confirm
                        self.trust = 2
                else:
                    # The administration panel hasn't been blocked
                    # yet, the email is available
                    self.trust = 3

                lastvisit = e("td").eq(4).text()
                if lastvisit != "":
                    lastvisit = lastvisit.split(" ")
                    self.lastvisit = int(
                        time.mktime(
                            time.struct_time(
                                (int(lastvisit[2]), month(lastvisit[1]),
                                 int(lastvisit[0]), 0, 0, 0, 0, 0, 0))))
                else:
                    self.lastvisit = 0