Example #1
0
def init_db(store, use_single_lang=False):
    db_create_tables(store)
    appdata_dict = db_update_appdata(store)

    log.debug("Performing database initialization...")

    config.system_cfg_init(store)

    if GLSettings.skip_wizard:
        NodeFactory(store).set_val('wizard_done', True)

    log.debug("Inserting internationalized strings...")

    if not use_single_lang:
        EnabledLanguage.add_all_supported_langs(store, appdata_dict)
    else:
        EnabledLanguage.add_new_lang(store, u'en', appdata_dict)

    with open(os.path.join(GLSettings.client_path, 'logo.png'),
              'r') as logo_file:
        data = logo_file.read()
        files.db_add_file(store, data, u'logo')

    with open(os.path.join(GLSettings.client_path, 'favicon.ico'),
              'r') as favicon_file:
        data = favicon_file.read()
        files.db_add_file(store, data, u'favicon')
Example #2
0
    def epilogue(self):
        old_node = self.store_old.find(self.model_from['Node']).one()
        old_notif = self.store_old.find(self.model_from['Notification']).one()

        with open(os.path.join(GLSettings.client_path, 'favicon.ico'),
                  'r') as favicon_file:
            data = favicon_file.read()
            files.db_add_file(self.store_new, data, u'favicon')
            self.entries_count['File'] += 1

        file_path = os.path.join(GLSettings.static_path,
                                 'custom_homepage.html')
        if os.path.exists(file_path):
            if files.db_get_file(self.store_new, u'homepage') == '':
                with open(file_path, 'r') as homepage_file:
                    data = homepage_file.read()
                    files.db_add_file(self.store_new, data, u'homepage')
                    self.entries_count['File'] += 1

            os.remove(file_path)

        #### Create ConfigL10N table and rows ####
        for lang in old_node.languages_enabled:
            self.store_new.add(l10n.EnabledLanguage(lang))

        self._migrate_l10n_static_config(old_node, 'node')
        self._migrate_l10n_static_config(old_notif, 'templates')

        # TODO assert that localized_keys matches exactly what is stored in the DB

        #### Create Config table and rows ####

        # Migrate Config saved in Node
        for var_name, item_def in GLConfig['node'].iteritems():
            old_val = getattr(old_node, var_name)

            # XXX this can throw errors if the validators run
            item = Config('node', var_name, old_val)
            self.store_new.add(item)

        # Migrate Config saved in Notification
        for var_name, item_def in GLConfig['notification'].iteritems():
            old_val = getattr(old_notif, var_name)

            if var_name == 'exception_email_pgp_key_expiration' and old_val is not None:
                old_val = properties.iso_strf_time(old_val)

            # NOTE this will throw errors if the validators run
            item = Config('notification', var_name, old_val)
            self.store_new.add(item)

        # Migrate private fields
        self.store_new.add(
            Config('private', 'receipt_salt', old_node.receipt_salt))
        self.store_new.add(
            Config('private', 'smtp_password', old_notif.password))

        # Set old verions that will be then handled by the version update
        self.store_new.add(Config('private', 'version', 'X.Y.Z'))
        self.store_new.add(Config('private', 'version_db', 0))
Example #3
0
def init_db(store, use_single_lang=False):
    db_create_tables(store)
    appdata_dict = db_update_appdata(store)

    log.debug("Performing database initialization...")

    config.system_cfg_init(store)

    if GLSettings.skip_wizard:
        NodeFactory(store).set_val('wizard_done', True)

    log.debug("Inserting internationalized strings...")

    if not use_single_lang:
        EnabledLanguage.add_all_supported_langs(store, appdata_dict)
    else:
        EnabledLanguage.add_new_lang(store, u'en', appdata_dict)

    with open(os.path.join(GLSettings.client_path, 'logo.png'), 'r') as logo_file:
        data = logo_file.read()
        files.db_add_file(store, data, u'logo')

    with open(os.path.join(GLSettings.client_path, 'favicon.ico'), 'r') as favicon_file:
        data = favicon_file.read()
        files.db_add_file(store, data, u'favicon')
Example #4
0
    def epilogue(self):
        old_node = self.store_old.find(self.model_from['Node']).one()
        old_notif = self.store_old.find(self.model_from['Notification']).one()

        with open(os.path.join(GLSettings.client_path, 'favicon.ico'), 'r') as favicon_file:
            data = favicon_file.read()
            files.db_add_file(self.store_new, data, u'favicon')
            self.entries_count['File'] += 1

        file_path = os.path.join(GLSettings.static_path, 'custom_homepage.html')
        if os.path.exists(file_path):
            if files.db_get_file(self.store_new, u'homepage') == '':
                with open(file_path, 'r') as homepage_file:
                    data = homepage_file.read()
                    files.db_add_file(self.store_new, data, u'homepage')
                    self.entries_count['File'] += 1

            os.remove(file_path)

        #### Create ConfigL10N table and rows ####
        for lang in old_node.languages_enabled:
            self.store_new.add(l10n.EnabledLanguage(lang))

        self._migrate_l10n_static_config(old_node, 'node')
        self._migrate_l10n_static_config(old_notif, 'templates')

        # TODO assert that localized_keys matches exactly what is stored in the DB

        #### Create Config table and rows ####

        # Migrate Config saved in Node
        for var_name, item_def in GLConfig['node'].iteritems():
            old_val = getattr(old_node, var_name)

            # XXX this can throw errors if the validators run
            item = Config('node', var_name, old_val)
            self.store_new.add(item)

        # Migrate Config saved in Notification
        for var_name, item_def in GLConfig['notification'].iteritems():
            old_val = getattr(old_notif, var_name)

            if var_name == 'exception_email_pgp_key_expiration' and old_val is not None:
                old_val = properties.iso_strf_time(old_val)

            # NOTE this will throw errors if the validators run
            item = Config('notification', var_name, old_val)
            self.store_new.add(item)

        # Migrate private fields
        self.store_new.add(Config('private', 'receipt_salt', old_node.receipt_salt))
        self.store_new.add(Config('private', 'smtp_password', old_notif.password))

        # Set old verions that will be then handled by the version update
        self.store_new.add(Config('private', 'version', 'X.Y.Z'))
        self.store_new.add(Config('private', 'version_db', 0))
Example #5
0
def init_db(store):
    appdata = load_appdata()

    db_create_tables(store)

    db_update_defaults(store)

    log.debug("Performing database initialization...")

    models.config.system_cfg_init(store)

    models.l10n.EnabledLanguage.add_all_supported_langs(store, appdata)

    file_descs = [(u'logo', 'data/logo.png'), (u'favicon', 'data/favicon.ico')]

    for file_desc in file_descs:
        with open(os.path.join(Settings.client_path, file_desc[1]), 'r') as f:
            files.db_add_file(store, f.read(), file_desc[0])
Example #6
0
def init_db(store, use_single_lang=False):
    db_create_tables(store)
    appdata_dict = db_update_appdata(store)

    log.debug("Performing database initialization...")

    config.system_cfg_init(store)

    if not use_single_lang:
        EnabledLanguage.add_all_supported_langs(store, appdata_dict)
    else:
        EnabledLanguage.add_new_lang(store, u'en', appdata_dict)

    with open(os.path.join(GLSettings.client_path, 'data/logo.png'),
              'r') as logo_file:
        data = logo_file.read()
        files.db_add_file(store, data, u'logo')

    with open(os.path.join(GLSettings.client_path, 'data/favicon.ico'),
              'r') as favicon_file:
        data = favicon_file.read()
        files.db_add_file(store, data, u'favicon')