Exemplo n.º 1
0
    def __init__(self, parse_args=True):
        super().__init__()
        if system.darwin:
            Application._osx_init()
        self._reported_tracebacks = []
        self._old_except_hook = sys.excepthook
        sys.excepthook = self._except_hook
        self._report_exception_requested.connect(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')
        self.app = QtWidgets.QApplication(sys.argv)
        if parse_args and not system.darwin:
            args = self.parse_args()
            verbose = args.verbose
            files = args.files
        else:
            verbose = False
            files = []
        logger.setup_logging(__version__, debug=verbose or Settings().verbose)
        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.view.show_perspective(Settings().perspective)
        self.view.show_home_page()

        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())
        # open specified files
        for f in files:
            self.file.open_file(f)
Exemplo n.º 2
0
    def __init__(self, parse_args=True):
        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')
        self.init_env()
        self.app = QtWidgets.QApplication(sys.argv)
        if parse_args and not system.darwin:
            args = self.parse_args()
            verbose = args.verbose
            files = args.files
        else:
            verbose = False
            files = []
        logger.setup_logging(__version__, debug=verbose or Settings().verbose)
        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.view.show_perspective(Settings().perspective)
        self.view.show_home_page()

        self.update_app_style()

        try:
            check_compiler()
        except CompilerNotFound as e:
            QtWidgets.QMessageBox.warning(
                self.win, 'COBOL compiler not found',
                'Failed to find GnuCOBOL compiler!\n\n%s\n\n'
                "The IDE will continue to work but you won't be able to "
                'compile any file...' % e)
        else:
            _logger().info('GnuCOBOL version: %s',
                           GnuCobolCompiler.get_version())
        # open specified files
        for f in files:
            self.file.open_file(f)
Exemplo n.º 3
0
    def __init__(self, parse_args=True):
        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')
        self.init_env()
        self.app = QtWidgets.QApplication(sys.argv)
        if parse_args and not system.darwin:
            args = self.parse_args()
            verbose = args.verbose
            files = args.files
        else:
            verbose = False
            files = []
        logger.setup_logging(__version__, debug=verbose or Settings().verbose)
        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.view.show_perspective(Settings().perspective)
        self.view.show_home_page()

        self.update_app_style()

        try:
            check_compiler()
        except CompilerNotFound as e:
            QtWidgets.QMessageBox.warning(
                self.win, 'COBOL compiler not found',
                'Failed to find GnuCOBOL compiler!\n\n%s\n\n'
                "The IDE will continue to work but you won't be able to "
                'compile any file...' % e)
        else:
            _logger().info('GnuCOBOL version: %s',
                           GnuCobolCompiler.get_version())
        # open specified files
        for f in files:
            self.file.open_file(f)
Exemplo n.º 4
0
    def handle_command_line_args(self):
        args = self.parse_args()
        files = args.files

        # setup logger
        debug = args.verbose or Settings().verbose
        logger.setup_logging(__version__, level=Settings().log_level)

        # show runtime env
        if args.runtime_env:
            print('OpenCobolIDE %s' % __version__)
            for k, v in sorted(DlgAbout.get_runtime_env().items(),
                               key=lambda x: x[0]):
                print('%s %s' % (k, v))
            sys.exit(0)

        # show cobc runtime env
        if args.cobc_runtime_env:
            print(DlgAbout.get_cobc_runtime_env())
            sys.exit(0)

        # import preferences
        if args.conf:
            try:
                with open(args.conf, 'rb') as f:
                    Settings().import_from_dict(pickle.load(f))
            except (ValueError, IOError, OSError):
                _logger().exception('failed to restore preferences from %r',
                                    args.conf)
            else:
                _logger().info('preferences imported from %r', args.conf)

        # compile specified files
        if args.compile:
            thread = CompilationThread()
            for path in files:
                if os.path.exists(path):
                    CobolController.clean_file(path)
                    thread.file_path = path
                    thread.run()
                else:
                    print('cannot compile %r, file not found')
            sys.exit(0)

        return files
Exemplo n.º 5
0
    def handle_command_line_args(self):
        args = self.parse_args()
        files = args.files

        # setup logger
        debug = args.verbose or Settings().verbose
        logger.setup_logging(__version__, level=Settings().log_level)

        # show runtime env
        if args.runtime_env:
            print(('OpenCobolIDE %s' % __version__))
            for k, v in sorted(list(DlgAbout.get_runtime_env().items()),
                               key=lambda x: x[0]):
                print(('%s %s' % (k, v)))
            sys.exit(0)

        # show cobc runtime env
        if args.cobc_runtime_env:
            print((DlgAbout.get_cobc_runtime_env()))
            sys.exit(0)

        # import preferences
        if args.conf:
            try:
                with open(args.conf, 'rb') as f:
                    Settings().import_from_dict(pickle.load(f))
            except (ValueError, IOError, OSError):
                _logger().exception('failed to restore preferences from %r',
                                    args.conf)
            else:
                _logger().info('preferences imported from %r', args.conf)

        # compile specified files
        if args.compile:
            thread = CompilationThread()
            for path in files:
                if os.path.exists(path):
                    CobolController.clean_file(path)
                    thread.file_path = path
                    thread.run()
                else:
                    print('cannot compile %r, file not found')
            sys.exit(0)

        return files
Exemplo n.º 6
0
"""
Configures the test suite and describe the global fixture that can be used
in functional tests.

"""
import pytest
import shutil
from open_cobol_ide import __version__, main
main.override_sys_path()
from open_cobol_ide.app import Application  # noqa
from open_cobol_ide.logger import setup_logging  # noqa
from open_cobol_ide.settings import Settings  # noqa

setup_logging(__version__)

_app = None

try:
    shutil.rmtree('test/testfiles/bin')
except OSError:
    pass


@pytest.fixture(scope="session")
def app(request):
    global _app
    # always starts with default settings
    s = Settings()
    s.clear()
    s.perspective = 'default'
    _app = Application(parse_args=False)
Exemplo n.º 7
0
"""
Configures the test suite and describe the global fixture that can be used
in functional tests.

"""
import pytest
import shutil
from open_cobol_ide import __version__
from open_cobol_ide.app import Application
from open_cobol_ide.logger import setup_logging
from open_cobol_ide.settings import Settings

setup_logging(__version__, debug=True)

_app = None

try:
    shutil.rmtree('test/testfiles/bin')
except OSError:
    pass


@pytest.fixture(scope="session")
def app(request):
    global _app
    # always starts with default settings
    s = Settings()
    s.clear()
    s.perspective = 'default'
    _app = Application(parse_args=False)
Exemplo n.º 8
0
    def __init__(self, parse_args=True):
        super().__init__()
        if system.darwin:
            Application._osx_init()
        self._reported_tracebacks = []
        self._old_except_hook = sys.excepthook
        sys.excepthook = self._except_hook
        self._report_exception_requested.connect(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')
        self.app = QtWidgets.QApplication(sys.argv)
        if parse_args and not system.darwin:
            args = self.parse_args()
            verbose = args.verbose
            files = args.files
        else:
            verbose = False
            files = []
        logger.setup_logging(__version__, debug=verbose or Settings().verbose)
        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.view.show_perspective(Settings().perspective)
        self.view.show_home_page()

        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())
        # open specified files
        for f in files:
            self.file.open_file(f)
Exemplo n.º 9
0
"""
Configures the test suite and describe the global fixture that can be used
in functional tests.

"""
import pytest
import shutil
from open_cobol_ide import __version__
from open_cobol_ide.app import Application
from open_cobol_ide.logger import setup_logging
from open_cobol_ide.settings import Settings

setup_logging(__version__, debug=True)

_app = None


try:
    shutil.rmtree('test/testfiles/bin')
except OSError:
    pass


@pytest.fixture(scope="session")
def app(request):
    global _app
    # always starts with default settings
    s = Settings()
    s.clear()
    s.perspective = 'default'
    _app = Application(parse_args=False)
Exemplo n.º 10
0
"""
Configures the test suite and describe the global fixture that can be used
in functional tests.

"""
import pytest
import shutil
from open_cobol_ide import __version__, main
main.override_sys_path()
from open_cobol_ide.app import Application  # noqa
from open_cobol_ide.logger import setup_logging  # noqa
from open_cobol_ide.settings import Settings  # noqa

setup_logging(__version__)

_app = None


try:
    shutil.rmtree('test/testfiles/bin')
except OSError:
    pass


@pytest.fixture(scope="session")
def app(request):
    global _app
    # always starts with default settings
    s = Settings()
    s.clear()
    s.perspective = 'default'