예제 #1
0
    def __init__(self, filename):
        self.connection = DBQueue()
        self.filename = filename
        self.items = {}
        self.dbhistory = history.DBHistory(self.connection, self.items, self.filename)

        # Enable multi-threading, as the database is protected with a queue
        self.connection.put(FileDB(filename, check_same_thread=False, name_based=True))
        qconn = self.connection.get()
        cursor = qconn.cursor()

        cursor.execute(queries.properties_select_history)
        softlimit = cursor.fetchone()[0]
        config = coreaux_api.get_configuration()("History")
        timelimit = config.get_int("time_limit")
        hardlimit = config.get_int("hard_limit")
        self.dbhistory.set_limits(softlimit, timelimit, hardlimit)

        dbitems = cursor.execute(queries.items_select_tree)
        self.connection.give(qconn)

        for item in dbitems:
            self.items[item["I_id"]] = items.Item(
                self.connection, self.dbhistory, self.items, self.filename, item["I_id"]
            )
예제 #2
0
    def __init__(self, filename):
        self.connection = DBQueue()
        self.filename = filename
        self.items = {}
        self.dbhistory = history.DBHistory(self.connection, self.items,
                                           self.filename)

        # Enable multi-threading, as the database is protected with a queue
        self.connection.put(
            FileDB(filename, check_same_thread=False, name_based=True))
        qconn = self.connection.get()
        cursor = qconn.cursor()

        cursor.execute(queries.properties_select_history)
        softlimit = cursor.fetchone()[0]
        config = coreaux_api.get_configuration()('History')
        timelimit = config.get_int('time_limit')
        hardlimit = config.get_int('hard_limit')
        self.dbhistory.set_limits(softlimit, timelimit, hardlimit)

        dbitems = cursor.execute(queries.items_select_tree)
        self.connection.give(qconn)

        for item in dbitems:
            self.items[item['I_id']] = items.Item(self.connection,
                                                  self.dbhistory, self.items,
                                                  self.filename, item['I_id'])
예제 #3
0
파일: about.py 프로젝트: xguse/outspline
    def compose_list(self, type_):
        # Do not use the configuration because it could have entries about
        # addons that aren't actually installed
        info = coreaux_api.get_components_info()["addons"]
        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('{}:\n'.format(type_))

        for addon in info[type_]:
            config = coreaux_api.get_configuration()(type_)(addon)

            if config.get_bool('enabled'):
                self.textw.SetDefaultStyle(self.STYLE_NORMAL)
                self.textw.AppendText('\t{}\n'.format(addon))
            else:
                self.textw.SetDefaultStyle(self.STYLE_ITALIC)
                self.textw.AppendText('\t{} [disabled]\n'.format(addon))
예제 #4
0
파일: about.py 프로젝트: xguse/outspline
    def compose_list(self, type_):
        # Do not use the configuration because it could have entries about
        # addons that aren't actually installed
        info = coreaux_api.get_components_info()["addons"]
        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('{}:\n'.format(type_))

        for addon in info[type_]:
            config = coreaux_api.get_configuration()(type_)(addon)

            if config.get_bool('enabled'):
                self.textw.SetDefaultStyle(self.STYLE_NORMAL)
                self.textw.AppendText('\t{}\n'.format(addon))
            else:
                self.textw.SetDefaultStyle(self.STYLE_ITALIC)
                self.textw.AppendText('\t{} [disabled]\n'.format(addon))
예제 #5
0
    def create(filename):
        if filename in dbs:
            raise exceptions.DatabaseAlreadyOpenError()
        else:
            try:
                db = open(filename, 'w')
            except IOError as e:
                if e.errno in (errno.EACCES, errno.ENOENT):
                    # errno.ENOENT happens when trying to to do a save as in
                    # a non-authorized folder
                    raise exceptions.AccessDeniedError()
                raise
            else:
                db.close()

                conn = FileDB(filename)
                cursor = conn.cursor()

                cursor.execute(queries.properties_create)

                limit = coreaux_api.get_configuration()('History').get_int(
                    'default_soft_limit')
                cursor.execute(queries.properties_insert_init, (limit, ))

                cursor.execute(queries.compatibility_create)
                # Only store major versions, as they are supposed to keep
                # backward compatibility
                # None must be used for core, because it must be safe in case
                # an extension is called 'core' for some reason
                cursor.execute(queries.compatibility_insert, (
                    None,
                    int(float(outspline.info.core.version)),
                ))

                cursor.execute(queries.items_create)
                cursor.execute(queries.history_create)

                conn.save_and_disconnect()

                extensions = coreaux_api.get_enabled_installed_addons(
                )['Extensions']
                dbdeps.Database(filename).add([
                    ext for ext in extensions
                    if coreaux_api.import_extension_info(ext).affects_database
                ])

                return filename
예제 #6
0
    def create(filename):
        if filename in dbs:
            raise exceptions.DatabaseAlreadyOpenError()
        else:
            try:
                db = open(filename, 'w')
            except IOError as e:
                if e.errno in (errno.EACCES, errno.ENOENT):
                    # errno.ENOENT happens when trying to to do a save as in
                    # a non-authorized folder
                    raise exceptions.AccessDeniedError()
                raise
            else:
                db.close()

                conn = FileDB(filename)
                cursor = conn.cursor()

                cursor.execute(queries.properties_create)

                limit = coreaux_api.get_configuration()('History').get_int(
                                                        'default_soft_limit')
                cursor.execute(queries.properties_insert_init, (limit, ))

                cursor.execute(queries.compatibility_create)
                # Only store major versions, as they are supposed to keep
                # backward compatibility
                # None must be used for core, because it must be safe in case
                # an extension is called 'core' for some reason
                cursor.execute(queries.compatibility_insert, (None,
                                    int(float(outspline.info.core.version)), ))

                cursor.execute(queries.items_create)
                cursor.execute(queries.history_create)

                conn.save_and_disconnect()

                extensions = coreaux_api.get_enabled_installed_addons()[
                                                                'Extensions']
                dbdeps.Database(filename).add([ext for ext in extensions
                                    if coreaux_api.import_extension_info(ext
                                    ).affects_database])

                return filename
예제 #7
0
파일: about.py 프로젝트: xguse/outspline
    def compose_addon_info(self, type_, addon):
        info = {
            "Extensions": coreaux_api.import_extension_info,
            "Interfaces": coreaux_api.import_interface_info,
            "Plugins": coreaux_api.import_plugin_info,
        }[type_](addon)

        config = coreaux_api.get_configuration()(type_)(addon)

        self.textw.SetDefaultStyle(self.STYLE_HEAD)
        self.textw.AppendText('{}\n'.format(addon))

        self.textw.SetDefaultStyle(self.STYLE_NORMAL)

        self.textw.AppendText('{}\n'.format(info.description))

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nEnabled: ')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)
        self.textw.AppendText('yes' if config.get_bool('enabled') else 'no')

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nVersion: ')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)
        self.textw.AppendText(info.version)

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nWebsite: ')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)
        self.textw.AppendText(info.website)

        self.textw.SetDefaultStyle(self.STYLE_BOLD)

        if len(info.authors) > 1:
            self.textw.AppendText('\nAuthors:')
            self.textw.SetDefaultStyle(self.STYLE_NORMAL)

            for a in info.authors:
                self.textw.AppendText('\n\t{}'.format(a))
        else:
            self.textw.AppendText('\nAuthor: ')
            self.textw.SetDefaultStyle(self.STYLE_NORMAL)
            self.textw.AppendText(info.authors[0])

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nContributors:')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)

        try:
            contributors = info.contributors
        except AttributeError:
            pass
        else:
            for c in contributors:
                self.textw.AppendText('\n\t{}'.format(c))

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nComponent: ')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)
        cinfo = coreaux_api.get_components_info()
        cname = cinfo["addons"][type_][addon]
        component = cinfo["info"][cname]
        self.textw.AppendText('{} {} ({})'.format(cname, component.version,
                                                    component.release_date))

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nDependencies:')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)

        try:
            deps = info.dependencies
        except AttributeError:
            pass
        else:
            for d in deps:
                self.textw.AppendText('\n\t{} {}.x'.format(*d))

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nOptional dependencies:')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)

        try:
            opts = info.optional_dependencies
        except AttributeError:
            pass
        else:
            for o in opts:
                self.textw.AppendText('\n\t{} {}.x'.format(*o))
예제 #8
0
파일: about.py 프로젝트: xguse/outspline
    def compose_addon_info(self, type_, addon):
        info = {
            "Extensions": coreaux_api.import_extension_info,
            "Interfaces": coreaux_api.import_interface_info,
            "Plugins": coreaux_api.import_plugin_info,
        }[type_](addon)

        config = coreaux_api.get_configuration()(type_)(addon)

        self.textw.SetDefaultStyle(self.STYLE_HEAD)
        self.textw.AppendText('{}\n'.format(addon))

        self.textw.SetDefaultStyle(self.STYLE_NORMAL)

        self.textw.AppendText('{}\n'.format(info.description))

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nEnabled: ')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)
        self.textw.AppendText('yes' if config.get_bool('enabled') else 'no')

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nVersion: ')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)
        self.textw.AppendText(info.version)

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nWebsite: ')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)
        self.textw.AppendText(info.website)

        self.textw.SetDefaultStyle(self.STYLE_BOLD)

        if len(info.authors) > 1:
            self.textw.AppendText('\nAuthors:')
            self.textw.SetDefaultStyle(self.STYLE_NORMAL)

            for a in info.authors:
                self.textw.AppendText('\n\t{}'.format(a))
        else:
            self.textw.AppendText('\nAuthor: ')
            self.textw.SetDefaultStyle(self.STYLE_NORMAL)
            self.textw.AppendText(info.authors[0])

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nContributors:')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)

        try:
            contributors = info.contributors
        except AttributeError:
            pass
        else:
            for c in contributors:
                self.textw.AppendText('\n\t{}'.format(c))

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nComponent: ')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)
        cinfo = coreaux_api.get_components_info()
        cname = cinfo["addons"][type_][addon]
        component = cinfo["info"][cname]
        self.textw.AppendText('{} {} ({})'.format(cname, component.version,
                                                  component.release_date))

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nDependencies:')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)

        try:
            deps = info.dependencies
        except AttributeError:
            pass
        else:
            for d in deps:
                self.textw.AppendText('\n\t{} {}.x'.format(*d))

        self.textw.SetDefaultStyle(self.STYLE_BOLD)
        self.textw.AppendText('\nOptional dependencies:')
        self.textw.SetDefaultStyle(self.STYLE_NORMAL)

        try:
            opts = info.optional_dependencies
        except AttributeError:
            pass
        else:
            for o in opts:
                self.textw.AppendText('\n\t{} {}.x'.format(*o))