Exemple #1
0
def test_show_report_dialog(qtbot):
    api._backends[:] = []
    assert len(api.get_backends()) == 0
    b1 = api.backends.GithubBackend('ColinDuquesnoy', 'TestQCrash')
    b2 = api.backends.EmailBackend('*****@*****.**', 'TestQCrash')
    api.install_backend(b1, b2)
    assert len(api.get_backends()) == 2

    dlg = api.show_report_dialog(modal=True)

    assert len(dlg.buttons) == 2

    # force email backend to return True to close the dialog
    b2.old_send_report = b2.send_report

    qtbot.wait(1000)

    def send_report(*args, **kwargs):
        b2.old_send_report(*args, **kwargs)
        return True

    b2.send_report = send_report
    dlg.buttons[1].clicked.emit(True)

    dlg.reject()
Exemple #2
0
    def __init__(self, parse_args=True):
        super().__init__()
        if system.darwin:
            Application._osx_init()
        self.app = QtWidgets.QApplication(sys.argv)

        self._reported_tracebacks = []
        qcrash.get_system_information = system.get_system_infos
        qcrash.get_application_log = logger.get_application_log
        qcrash.install_backend(
            qcrash.backends.GithubBackend(QCRASH_GH_OWNER, QCRASH_GH_REPO),
            qcrash.backends.EmailBackend(QCRASH_EMAIL, 'OpenCobolIDE'))
        qcrash.set_qsettings(Settings()._settings)
        qcrash.install_except_hook(except_hook=self._report_exception)
        # if hasattr(sys, 'frozen') and sys.platform == 'win32':
        #     sys.stdout = open(os.path.join(system.get_cache_directory(),
        #                                    'ocide_stdout.log'), 'w')
        #     sys.stderr = open(os.path.join(system.get_cache_directory(),
        #                                    'ocide_stderr.log'), 'w')
        if parse_args and not system.darwin:
            files = self.handle_command_line_args()
        else:
            files = []
        _logger().info('files to open: %r' % files)
        self.name = 'OpenCobolIDE'
        self.version = __version__
        self.title = '%s %s' % (self.name, self.version)

        self.apply_mimetypes_preferences()

        self.win = MainWindow()
        self.win.setWindowTitle(self.title)
        self.file = FileController(self)
        self.view = ViewController(self)
        self.home = HomeController(self)
        self.edit = EditController(self)
        self.cobol = CobolController(self)
        self.help = HelpController(self)
        self.win.app = self

        self.view.show_perspective(Settings().perspective)

        self.update_app_style()

        try:
            check_compiler()
        except CompilerNotFound:
            msg = 'Failed to find a working GnuCOBOL compiler!\n' \
                "The IDE will continue to work but you won't be able to " \
                'compile...'
            if system.windows:
                msg += '\n\nTip: Ensure that there is no additional ' \
                    'installation of MinGW in %s:\MinGW' % sys.executable[0]
            QtWidgets.QMessageBox.warning(
                self.win, 'COBOL compiler not found or not working', msg)
        else:
            _logger().info('GnuCOBOL version: %s',
                           GnuCobolCompiler.get_version(include_all=False))
        self._files = files
Exemple #3
0
    def __init__(self, parse_args=True):
        super().__init__()
        if system.darwin:
            Application._osx_init()
        self.app = QtWidgets.QApplication(sys.argv)

        self._reported_tracebacks = []
        qcrash.get_system_information = system.get_system_infos
        qcrash.get_application_log = logger.get_application_log
        qcrash.install_backend(
            qcrash.backends.GithubBackend(QCRASH_GH_OWNER, QCRASH_GH_REPO),
            qcrash.backends.EmailBackend(QCRASH_EMAIL, 'OpenCobolIDE'))
        qcrash.set_qsettings(Settings()._settings)
        qcrash.install_except_hook(except_hook=self._report_exception)
        # if hasattr(sys, 'frozen') and sys.platform == 'win32':
        #     sys.stdout = open(os.path.join(system.get_cache_directory(),
        #                                    'ocide_stdout.log'), 'w')
        #     sys.stderr = open(os.path.join(system.get_cache_directory(),
        #                                    'ocide_stderr.log'), 'w')
        if parse_args and not system.darwin:
            files = self.handle_command_line_args()
        else:
            files = []
        _logger().info('files to open: %r' % files)
        self.name = 'OpenCobolIDE'
        self.version = __version__
        self.title = '%s %s' % (self.name, self.version)

        self.apply_mimetypes_preferences()

        self.win = MainWindow()
        self.win.setWindowTitle(self.title)
        self.file = FileController(self)
        self.view = ViewController(self)
        self.home = HomeController(self)
        self.edit = EditController(self)
        self.cobol = CobolController(self)
        self.help = HelpController(self)
        self.win.app = self

        self.view.show_perspective(Settings().perspective)

        self.update_app_style()

        try:
            check_compiler()
        except CompilerNotFound:
            msg = 'Failed to find a working GnuCOBOL compiler!\n' \
                "The IDE will continue to work but you won't be able to " \
                'compile...'
            if system.windows:
                msg += '\n\nTip: Ensure that there is no additional ' \
                    'installation of MinGW in %s:\MinGW' % sys.executable[0]
            QtWidgets.QMessageBox.warning(
                self.win, 'COBOL compiler not found or not working', msg)
        else:
            _logger().info('GnuCOBOL version: %s',
                           GnuCobolCompiler.get_version(include_all=False))
        self._files = files
Exemple #4
0
    def _setup_except_hook(self):
        qcrash.get_system_information = versions.get_system_infos
        qcrash.get_application_log = logger.get_application_log
        qcrash.install_backend(
            qcrash.backends.GithubBackend(QCRASH_GH_OWNER, QCRASH_GH_REPO),
            qcrash.backends.EmailBackend(QCRASH_EMAIL, 'HackEdit'))
        qcrash.set_qsettings(QtCore.QSettings())

        qcrash.install_except_hook(except_hook=self._report_exception)
    def _setup_except_hook(self):
        qcrash.get_system_information = versions.get_system_infos
        qcrash.get_application_log = logger.get_application_log
        qcrash.install_backend(
            qcrash.backends.GithubBackend(QCRASH_GH_OWNER, QCRASH_GH_REPO),
            qcrash.backends.EmailBackend(QCRASH_EMAIL, 'HackEdit'))
        qcrash.set_qsettings(QtCore.QSettings())

        qcrash.install_except_hook(except_hook=self._report_exception)
Exemple #6
0
def setup_qcrash():

    github = qcrash.backends.GithubBackend("tmontes", "qtcrashme")
    qcrash.install_backend(github)

    email = qcrash.backends.EmailBackend("*****@*****.**", "qtcrashme")
    qcrash.install_backend(email)

    qcrash.get_application_log = lambda: "line1\nline2\n"
    qcrash.get_system_information = lambda: "system information here"

    qcrash.install_except_hook()
Exemple #7
0
def test_install_backend():
    api._backends[:] = []
    assert len(api.get_backends()) == 0
    b1 = api.backends.GithubBackend('ColinDuquesnoy', 'TestQCrash')
    b2 = api.backends.EmailBackend('*****@*****.**', 'TestQCrash')
    api.install_backend(b1, b2)
    assert len(api.get_backends()) == 2
    b1 = api.backends.GithubBackend('ColinDuquesnoy', 'TestQCrash')
    b2 = api.backends.EmailBackend('*****@*****.**', 'TestQCrash')
    api.install_backend(b1)
    assert len(api.get_backends()) == 3
    api.install_backend(b2)
    assert len(api.get_backends()) == 4

def get_application_log():
    return "Blabla"


app = QtWidgets.QApplication(sys.argv)
my_settings = QtCore.QSettings()


# use own qsettings to remember username,... (password stored via keyring)
qcrash.set_qsettings(my_settings)


# configure backends
qcrash.install_backend(qcrash.backends.GithubBackend(
    GITHUB_OWNER, GITHUB_REPO))
qcrash.install_backend(qcrash.backends.EmailBackend(EMAIL, 'TestApp'))


# setup our own function to collect system info and application log
qcrash.get_application_log = get_application_log
qcrash.get_system_information = get_system_info


# show report dialog manually
qcrash.show_report_dialog()


# create a window
win = QtWidgets.QMainWindow()
label = QtWidgets.QLabel()
Exemple #9
0
def get_system_info():
    return 'OS: %s\nPython: %r' % (sys.platform, sys.version_info)


def get_application_log():
    return "Blabla"


app = QtGui.QApplication(sys.argv)
my_settings = QtCore.QSettings()

# use own qsettings to remember username,... (password stored via keyring)
qcrash.set_qsettings(my_settings)

# configure backends
qcrash.install_backend(qcrash.backends.GithubBackend(GITHUB_OWNER,
                                                     GITHUB_REPO))
qcrash.install_backend(qcrash.backends.EmailBackend(EMAIL, 'TestApp'))

# setup our own function to collect system info and application log
qcrash.get_application_log = get_application_log
qcrash.get_system_information = get_system_info

# show report dialog manually
qcrash.show_report_dialog()

# create a window
win = QtGui.QMainWindow()
label = QtGui.QLabel()
label.setText('Wait a few seconds for an unhandled exception to occur...')
label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
win.setCentralWidget(label)
Exemple #10
0
import Flux.ucd

from Flux.project import FluxProject
from Flux.editor import FluxEditor
from PyQt5.QtWidgets import QApplication

import qcrash.api as qcrash

app = QApplication(sys.argv)
app.setApplicationName("Flux")
app.setOrganizationDomain("corvelsoftware.co.uk")
# app.setOrganizationName("Corvel Software")

email = qcrash.backends.EmailBackend('*****@*****.**', 'flux')
github = qcrash.backends.GithubBackend('simoncozens', 'flux')
qcrash.install_backend(github)
qcrash.install_backend(email)
qcrash.install_except_hook()

proj = None
if len(sys.argv) > 1:
    if sys.argv[1].endswith(".fluxml"):
        proj = FluxProject(sys.argv[1])
    else:
        proj = FluxProject.new(sys.argv[1])
f = FluxEditor(proj)
f.show()

sys.exit(app.exec_())