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
def _init_dependencies(self): self.propgrid.Append(wxpg.PropertyCategory("Extensions support", "dependencies")) extensions = coreaux_api.get_enabled_installed_addons()['Extensions'] self.dependencies = core_api.get_database_dependencies(self.filename, ignored=True) del self.dependencies[None] for ext in extensions: if coreaux_api.import_extension_info(ext).affects_database: propname = "dependencies.{}".format(ext) prop = wxpg.EnumProperty(ext, propname, ('Enabled', 'Disabled (remind)', 'Disabled (ignore)')) prop.SetClientData(ext) self.onchange_actions[propname] = self._change_dependencies self.propgrid.Append(prop) self.refresh_dependency(ext)
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
def __init__(self, filename): # I have to import here, or a circular import will happen from outspline.core.databases import FileDB self.FileDB = FileDB self.filename = filename connection = FileDB(filename) cursor = connection.cursor() cursor.execute(queries.compatibility_select) # ABORT - If a dependency is not installed # ABORT - If a dependency is installed with a lesser version number # OK - If a dependency is installed with the correct version number # IGNORE - If a dependency is disabled and set to be ignored in the # CoMpatibility table # UPDATE - If a dependency is installed with a greater version number # ADD - If an extension is not present in the dependencies extensions = coreaux_api.get_enabled_installed_addons()['Extensions'] self.dependencies = { 'ignore': {}, 'add': {}, 'update': {}, 'abort': {}, } self.fdeps = [] # Only compare major versions, as they are supposed to keep backward # compatibility # Core must be stored as None in the database to avoid clashes with a # possible extension called 'core' self.dependencies['add'][None] = [ int(float(outspline.info.core.version)), None ] for ext in extensions: info = coreaux_api.import_extension_info(ext) if info.affects_database: # Core will never end up staying in the 'add' key, however # initialize it here so that it can be moved like the # extensions # Only compare major versions, as they are supposed to keep # backward compatibility self.dependencies['add'][ext] = [ int(info.version.split(".", 1)[0]), None ] for row in cursor: # 'row[2] == None' means that the addon is not a dependency, but if # installed it shouldn't trigger a reminder to enable it # Don't just test `if row[2]:` because '0' should not pass try: dep = self.dependencies['add'][row[1]] except KeyError: if row[2] is None: pass else: self.dependencies['abort'][row[1]] = [None, row[2]] else: if row[2] is None: self.dependencies['ignore'][row[1]] = dep[:] else: dep[1] = row[2] if row[2] > dep[0]: self.dependencies['abort'][row[1]] = dep[:] elif row[2] < dep[0]: self.dependencies['update'][row[1]] = dep[:] else: version = row[2] if row[1] is None: self.fdeps.append(('core', version)) else: self.fdeps.append(('.'.join( ('extensions', row[1])), version)) del self.dependencies['add'][row[1]] connection.disconnect()
def __init__(self, filename): # I have to import here, or a circular import will happen from outspline.core.databases import FileDB self.FileDB = FileDB self.filename = filename connection = FileDB(filename) cursor = connection.cursor() cursor.execute(queries.compatibility_select) # ABORT - If a dependency is not installed # ABORT - If a dependency is installed with a lesser version number # OK - If a dependency is installed with the correct version number # IGNORE - If a dependency is disabled and set to be ignored in the # CoMpatibility table # UPDATE - If a dependency is installed with a greater version number # ADD - If an extension is not present in the dependencies extensions = coreaux_api.get_enabled_installed_addons()['Extensions'] self.dependencies = { 'ignore': {}, 'add': {}, 'update': {}, 'abort': {}, } self.fdeps = [] # Only compare major versions, as they are supposed to keep backward # compatibility # Core must be stored as None in the database to avoid clashes with a # possible extension called 'core' self.dependencies['add'][None] = [int(float( outspline.info.core.version)), None] for ext in extensions: info = coreaux_api.import_extension_info(ext) if info.affects_database: # Core will never end up staying in the 'add' key, however # initialize it here so that it can be moved like the # extensions # Only compare major versions, as they are supposed to keep # backward compatibility self.dependencies['add'][ext] = [int(info.version.split( ".", 1)[0]), None] for row in cursor: # 'row[2] == None' means that the addon is not a dependency, but if # installed it shouldn't trigger a reminder to enable it # Don't just test `if row[2]:` because '0' should not pass try: dep = self.dependencies['add'][row[1]] except KeyError: if row[2] is None: pass else: self.dependencies['abort'][row[1]] = [None, row[2]] else: if row[2] is None: self.dependencies['ignore'][row[1]] = dep[:] else: dep[1] = row[2] if row[2] > dep[0]: self.dependencies['abort'][row[1]] = dep[:] elif row[2] < dep[0]: self.dependencies['update'][row[1]] = dep[:] else: version = row[2] if row[1] is None: self.fdeps.append(('core', version)) else: self.fdeps.append(('.'.join(('extensions', row[1])), version)) del self.dependencies['add'][row[1]] connection.disconnect()