Exemplo n.º 1
0
Arquivo: app.py Projeto: f0rk/cartman
    def run_comment(self, ticket_id):
        """Add a comment to the given ticket_id. This command does not return
        anything if successful. Command is cancelled if the content of the
        comment is empty.

        usage: cm comment ticket_id

        """
        ticket_id = text.validate_id(ticket_id)

        self.login()

        # Load the initial timestamp from the ticket page
        r = self.get("/ticket/%d" % ticket_id)
        timestamp = text.extract_timestamp(r.content)

        if self.message:
            comment = self.message
        else:
            comment = self._read_comment()

        if not comment.strip():
            raise exceptions.FatalError("empty comment, cancelling")

        r = self.post("/ticket/%d" % ticket_id, {
            "ts": timestamp,
            "comment": comment,
            "action": "leave",
        })

        if "system-message" in r.content or r.status_code != 200:
            raise exceptions.FatalError("unable to save comment")
Exemplo n.º 2
0
Arquivo: app.py Projeto: f0rk/cartman
    def run_open(self, ticket_id):
        """Open a ticket in your browser.

        usage: cm open ticket_id
        """
        ticket_id = text.validate_id(ticket_id)

        self.open_in_browser(ticket_id)
Exemplo n.º 3
0
Arquivo: app.py Projeto: f0rk/cartman
    def run_report(self, report_id=None):
        """List tickets from a given report number.

        usage: cm report ticket_id

        """
        report_id = text.validate_id(report_id)

        query_string = "/report/%d?format=tab" % report_id

        for t in self.get_tickets(query_string):
            print(t.format_title())
Exemplo n.º 4
0
Arquivo: app.py Projeto: f0rk/cartman
    def run_view(self, ticket_id):
        """Display a ticket summary.

        usage: cm view ticket_id

        """
        ticket_id = text.validate_id(ticket_id)

        query_string = "/ticket/%d?format=tab" % ticket_id

        t = self.get_tickets(query_string).next()
        title = t.format_title()

        print(ui.title(title))
        print("")

        print(t.description)
Exemplo n.º 5
0
Arquivo: app.py Projeto: f0rk/cartman
    def run_status(self, ticket_id, status=None):
        """Updates the status of a ticket.

        usage: cm status ticket_id [new_status]

        """
        ticket_id = text.validate_id(ticket_id)

        self.login()

        # Get all the available actions for this ticket
        r = self.get("/ticket/%d" % ticket_id)
        timestamp = text.extract_timestamp(r.content)
        statuses = text.extract_statuses(r.content)

        # A ``status`` was provided, try to find the exact match, else just
        # display the current status for this ticket, and the available ones.
        if status:
            status = text.fuzzy_find(status, statuses)

            if not status:
                raise exceptions.FatalError("bad status (for this ticket: %s)" % \
                                        ", ".join(statuses))
        else:
            status = text.extract_status_from_ticket_page(r.content)
            print("Current status: %s" % status)
            print("Available statuses: %s" % ", ".join(statuses))
            return

        if self.message:
            comment = self.message
        elif self.add_comment:
            comment = self._read_comment()
        else:
            comment = ""

        r = self.post("/ticket/%d" % ticket_id, {
            "ts": timestamp,
            "action": status,
            "comment": comment,
        })

        if "system-message" in r.content or r.status_code != 200:
            raise exceptions.FatalError("unable to set status")