bugreport.py :  » IDE » PIDA » pida-0.6beta3 » pida » services » bugreport » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » IDE » PIDA 
PIDA » pida 0.6beta3 » pida » services » bugreport » bugreport.py
# -*- coding: utf-8 -*-
"""
    :copyright: 2005-2008 by The PIDA Project
    :license: GPL 2 or later (see README/COPYING/LICENSE)
"""
import sys
from cgi import escape

import gtk
import gobject


# PIDA Imports
import pida

from pida.core.service import Service
from pida.core.features import FeaturesConfig
from pida.core.commands import CommandsConfig
from pida.core.events import EventsConfig
from pida.core.options import OptionsConfig
from pida.core.actions import ActionsConfig
from pida.core.actions import TYPE_NORMAL,TYPE_MENUTOOL,TYPE_RADIO,TYPE_TOGGLE

from pida.core.environment import on_windows
from pida.ui.views import PidaGladeView

from pida.utils.gthreads import AsyncTask,gcall

# locale
from pida.core.locale import Locale
locale = Locale('bugreport')
_ = locale.gettext

class BugreportView(PidaGladeView):

    key = 'bugreport.form'

    gladefile = 'bugreport'
    locale = locale

    icon_name = 'error'
    label_text = _('Bug Report')

    def on_ok_button__clicked(self, button):
        self.get_pass()
        if self.email is None:
            return
        self.progress_bar.set_text('')
        task = AsyncTask(self.report, self.report_complete)
        task.start()
        self._pulsing = True
        self.progress_bar.show()
        gobject.timeout_add(100, self._pulse)

    def on_close_button__clicked(self, button):
        self.svc.get_action('show_bugreport').set_active(False)

    def report(self):
        title = self.title_entry.get_text()
        buf = self.description_text.get_buffer()
        description = buf.get_text(buf.get_start_iter(), buf.get_end_iter())
        description = 'PIDA %s\n--\n%s' % (pida.version, description)
        #FIXME causes memleak and deadlock on win32
        if on_windows:
            return
        from pida.utils.launchpadder.lplib import report

        return report(None, self.email, self.password, 'pida', title, description)

    def report_complete(self, success, data):
        if success:
            self.svc.boss.cmd('notify', 'notify', title=_('Bug Reported'), data=data)
            self.title_entry.set_text('')
            self.description_text.get_buffer().set_text('')
            self.svc.boss.cmd('browseweb', 'browse', url=data.strip())
        else:
            self.svc.boss.cmd('notify', 'notify', title=_('Bug Report Failed'), data=data)
        self.progress_bar.hide()
        self._pulsing = False

    def _pulse(self):
        self.progress_bar.pulse()
        return self._pulsing

    def get_pass(self):
        #FIXME causes memleak and deadlock on win32
        if on_windows:
            return
        from pida.utils.launchpadder.gtkgui import PasswordDialog

        pass_dlg = PasswordDialog(self.svc.opt('launchpad_email_addr'))
        def pass_response(dlg, resp):
            dlg.hide()
            if resp == gtk.RESPONSE_ACCEPT:
                self.email, self.password = dlg.get_user_details()
                self.svc.set_opt('launchpad_email_addr', self.email)
            dlg.destroy()
        pass_dlg.connect('response', pass_response)
        pass_dlg.run()

    def can_be_closed(self):
        self.svc.get_action('show_bugreport').set_active(False)


class BugreportActions(ActionsConfig):
    
    def create_actions(self):
        self.create_action(
            'show_bugreport',
            TYPE_TOGGLE,
            _('Bug report'),
            _('Make a bug report'),
            'error',
            self.on_report
        )

    def on_report(self, action):
        if action.get_active():
            self.svc.show_report()
        else:
            self.svc.hide_report()


class BugreportOptions(OptionsConfig):

    def create_options(self):
        self.create_option(
            'launchpad_email_addr',
            _('Launchpad Email address'),
            str,
            '',
            _('Default Launchpad email address'),
            None,
        )


# Service class
class Bugreport(Service):
    """Describe your Service Here""" 

    actions_config = BugreportActions
    options_config = BugreportOptions

    def start(self):
        self._view = BugreportView(self)
    
    def show_report(self):
        self.boss.cmd('window', 'add_view', paned='Terminal', view=self._view)

    def hide_report(self):
        self.boss.cmd('window', 'remove_view', view=self._view)

# Required Service attribute for service loading
Service = Bugreport



# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.