Example #1
0
    def save(self, *args, **kw):
        if self.raw:
            for k, v in break_url(self.raw).items():
                setattr(self, k, v)

        if not self.title:
            self.title = trunc_string(self.description, 50)

        created = not getattr(self, "id", None)
        old = None
        if created:
            # there's a possible race condition here
            try:
                self.number = Issue.all().order("-number")[0].number + 1
            except IndexError:
                self.number = 1
            self.timestamp = datetime.now()
        else:
            old = Issue.get(self.id)

        self.put()
        if created:
            signals.issue_created.send(sender=self.__class__, instance=self)
        else:
            for key in ["status", "assigned", "priority"]:
                new_value = getattr(self, key)
                old_value = getattr(old, key)
                if new_value !=old_value:
                    signal = getattr(signals, "issue_%s_changed" % key)
                    signal.send(sender=self.__class__, instance=self, old=old_value, new=new_value)

            signals.issue_changed.send(sender=self.__class__, instance=self, old=old)
Example #2
0
    def save(self, *args, **kw):
        if self.raw:
            for k, v in break_url(self.raw).items():
                setattr(self, k, v)

        if not self.title:
            self.title = trunc_string(self.description, 50)

        created = not getattr(self, "id", None)
        old = None
        if created:
            self.number = Issue.all().count() + 1
            self.timestamp = datetime.now()
        else:
            old = Issue.get(self.id)

        self.put()
        if created:
            signals.issue_created.send(sender=self.__class__, instance=self)
        else:
            for key in ["status", "assigned", "priority"]:
                new_value = getattr(self, key)
                old_value = getattr(old, key)
                if new_value != old_value:
                    signal = getattr(signals, "issue_%s_changed" % key)
                    signal.send(sender=self.__class__,
                                instance=self,
                                old=old_value,
                                new=new_value)

            signals.issue_changed.send(sender=self.__class__,
                                       instance=self,
                                       old=old)
Example #3
0
    def _setup(self):
        self.project = Project(name="testing")
        self.project.save()

        self.url = ProjectURL(url="http://test.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.url = ProjectURL(url="http://www.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.error = Error()
        for k, v in break_url("http://test.areciboapp.com/an/other").items():
            setattr(self.error, k, v)
        self.error.save()
Example #4
0
    def _setup(self):
        self.project = Project(name="testing")
        self.project.save()

        self.url = ProjectURL(url="http://test.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.url = ProjectURL(url="http://www.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.error = Error()
        for k, v in break_url("http://test.areciboapp.com/an/other").items():
            setattr(self.error, k, v)
        self.error.save()
Example #5
0
def populate(incoming):
    """ Populate the error table with the incoming error """
    # special lookup the account
    err = Error()
    uid = incoming.get("account", "")
    if not settings.ANONYMOUS_POSTING:
        if not uid:
            raise ValueError, "Missing the required account number."

        if str(uid) != settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER:
            raise ValueError, "Account number does not match"

    # special
    if incoming.has_key("url"):
        for k, v in break_url(incoming["url"]).items():
            setattr(err, k, v)

    # check the status codes
    if incoming.has_key("status"):
        status = str(incoming["status"])
        try:
            valid_status(status)
            err.status = status
        except StatusDoesNotExist:
            err.errors += "Status does not exist, ignored.\n"

    # not utf-8 encoded
    for src, dest in [
        ("ip", "ip"),
        ("user_agent", "user_agent"),
        ("uid", "uid"),
        ]:
        actual = incoming.get(src, None)
        if actual is not None:
            setattr(err, dest, str(actual))

    try:
        priority = int(incoming.get("priority", 0))
    except ValueError:
        priority = 0
    err.priority = min(priority, 10)

    # possibly utf-8 encoding
    for src, dest in [
        ("type", "type"),
        ("msg", "msg"),
        ("server", "server"),
        ("traceback", "traceback"),
        ("request", "request"),
        ("username", "username")
        ]:
        actual = incoming.get(src, None)
        if actual is not None:
            try:
                setattr(err, dest, actual.encode("utf-8"))
            except UnicodeDecodeError:
                err.errors += "Encoding error on the %s field, ignored.\n" % src

    # timestamp handling
    if incoming.has_key("timestamp"):
        tmstmp = incoming["timestamp"].strip()
        if tmstmp.endswith("GMT"):
            tmstmp = tmstmp[:-3] + "-0000"
        tme = parsedate(tmstmp)
        if tme:
            try:
                final = datetime(*tme[:7])
                err.error_timestamp = final
                err.error_timestamp_date = final.date()
            except ValueError, msg:
                err.errors += 'Date error on the field "%s", ignored.\n' % msg
Example #6
0
def populate(err, incoming):
    """ Populate the error table with the incoming error """
    # special lookup the account
    uid = incoming.get("account", "")
    if not uid:
        raise ValueError, "Missing the required account number."
    if str(uid) != settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER:
        raise ValueError, "Account number does not match"

    # special
    if incoming.has_key("url"):
        for k, v in break_url(incoming["url"]).items():
            setattr(err, k, v)

    # check the status codes
    if incoming.has_key("status"):
        status = str(incoming["status"])
        try:
            valid_status(status)
            err.status = status
        except StatusDoesNotExist:
            err.errors += "Status does not exist, ignored.\n"

    # not utf-8 encoded
    for src, dest in [
        ("ip", "ip"),
        ("user_agent", "user_agent"),
        ("uid", "uid"),
    ]:
        actual = incoming.get(src, None)
        if actual is not None:
            setattr(err, dest, str(actual))

    try:
        priority = int(incoming.get("priority", 0))
    except ValueError:
        priority = 0
    err.priority = min(priority, 10)

    # possibly utf-8 encoding
    for src, dest in [("type", "type"), ("msg", "msg"), ("server", "server"),
                      ("traceback", "traceback"), ("request", "request"),
                      ("username", "username")]:
        actual = incoming.get(src, None)
        if actual is not None:
            try:
                setattr(err, dest, actual.encode("utf-8"))
            except UnicodeDecodeError:
                err.errors += "Encoding error on the %s field, ignored.\n" % src

    # timestamp handling
    if incoming.has_key("timestamp"):
        tmstmp = incoming["timestamp"].strip()
        if tmstmp.endswith("GMT"):
            tmstmp = tmstmp[:-3] + "-0000"
        tme = parsedate(tmstmp)
        if tme:
            try:
                final = datetime(*tme[:7])
                err.error_timestamp = final
            except ValueError, msg:
                err.errors += 'Date error on the field "%s", ignored.\n' % msg