Beispiel #1
0
    def test_add_read(self):
        self.assertEqual([], self.luct_glo.listing())

        inst = LucteriosInstance("inst_psql", self.path_dir)
        inst.set_database(
            "postgresql:name=" + self.data['dbname'] + ",user=puser,password=123456,host=localhost")
        inst.add()
        self.assertEqual(["inst_psql"], self.luct_glo.listing())

        inst = LucteriosInstance("inst_psql", self.path_dir)
        inst.read()
        self.assertEqual("postgresql", inst.database[0])
        self.assertEqual("localhost", inst.database[1]['host'])
        self.assertEqual(self._testMethodName, inst.database[1]['name'])
        self.assertEqual("123456", inst.database[1]['password'])
        self.assertEqual("puser", inst.database[1]['user'])
        self.assertEqual("lucterios.standard", inst.appli_name)
        self.assertEqual((), inst.modules)

        table_list = list(self.run_psql_cmd(
            "SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public'"))
        table_list = table_list[2:-2]
        table_list.sort()
        self.assertEqual(self.waiting_table, table_list)

        inst = LucteriosInstance("inst_psql", self.path_dir)
        inst.clear()
        table_list = list(self.run_psql_cmd(
            "SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public'"))
        table_list = table_list[2:-2]
        self.assertEqual([], table_list)

        inst = LucteriosInstance("inst_psql", self.path_dir)
        inst.delete()
        self.assertEqual([], self.luct_glo.listing())
Beispiel #2
0
    def test_add_read(self):
        self.assertEqual([], self.luct_glo.listing())

        inst = LucteriosInstance("inst_a", self.path_dir)
        inst.add()
        self.assertEqual(["inst_a"], self.luct_glo.listing())

        inst = LucteriosInstance("inst_a", self.path_dir)
        inst.read()
        self.assertEqual(("sqlite", {}), inst.database)
        self.assertEqual("lucterios.standard", inst.appli_name)
        self.assertEqual((), inst.modules)

        table_list = list(self.run_sqlite_cmd(
            "inst_a", "SELECT name FROM sqlite_master WHERE type='table';"))
        if "sqlite_sequence" in table_list:
            table_list.remove("sqlite_sequence")
        table_list.sort()
        self.assertEqual(self.waiting_table, table_list)

        inst = LucteriosInstance("inst_a", self.path_dir)
        inst.clear()

        table_list = list(self.run_sqlite_cmd(
            "inst_a", "SELECT name FROM sqlite_master WHERE type='table';"))
        if "sqlite_sequence" in table_list:
            table_list.remove("sqlite_sequence")
        table_list.sort()
        self.assertEqual([], table_list)

        self.assertEqual(["inst_a"], self.luct_glo.listing())
Beispiel #3
0
    def test_add_read(self):
        self.assertEqual([], self.luct_glo.listing())

        inst = LucteriosInstance("inst_mysql", self.path_dir)
        inst.set_database(
            "mysql:name=testv2,user=myuser,password=123456,host=localhost")
        inst.add()
        self.assertEqual(["inst_mysql"], self.luct_glo.listing())

        inst = LucteriosInstance("inst_mysql", self.path_dir)
        inst.read()
        self.assertEqual("mysql", inst.database[0])
        self.assertEqual("localhost", inst.database[1]['host'])
        self.assertEqual("testv2", inst.database[1]['name'])
        self.assertEqual("123456", inst.database[1]['password'])
        self.assertEqual("myuser", inst.database[1]['user'])
        self.assertEqual("lucterios.standard", inst.appli_name)
        self.assertEqual((), inst.modules)

        table_list = list(self.run_mysql_cmd("use testv2;show tables;"))
        if "Tables_in_testv2" in table_list:
            table_list.remove("Tables_in_testv2")
        table_list.sort()
        self.assertEqual(self.waiting_table, table_list)

        inst = LucteriosInstance("inst_mysql", self.path_dir)
        inst.clear()
        table_list = list(self.run_mysql_cmd("use testv2;show tables;"))
        self.assertEqual([], table_list)

        inst = LucteriosInstance("inst_mysql", self.path_dir)
        inst.delete()
        self.assertEqual([], self.luct_glo.listing())
Beispiel #4
0
    def test_extra(self):
        self.assertEqual([], self.luct_glo.listing())

        inst = LucteriosInstance("inst_e", self.path_dir)
        inst.set_extra(
            "DEBUG=True,ALLOWED_HOSTS=[localhost;127.0.0.1],DEFAULT_PAGE=cms/,NBMAX=5,PIVALUE=3.1415"
        )
        inst.add()
        self.assertEqual(["inst_e"], self.luct_glo.listing())

        # print(open(self.path_dir + '/inst_a/settings.py', 'r').readlines())

        inst = LucteriosInstance("inst_e", self.path_dir)
        inst.read()
        self.assertEqual(
            {
                'DEBUG': True,
                '': {
                    'mode': (0, 'Connexion toujours nécessaire')
                },
                'ALLOWED_HOSTS': ['localhost', '127.0.0.1'],
                'DEFAULT_PAGE': 'cms/',
                "NBMAX": 5,
                'PIVALUE': 3.1415
            }, inst.extra)
        inst.modif()

        inst = LucteriosInstance("inst_e", self.path_dir)
        inst.read()
Beispiel #5
0
    def select_instance(self, evt):

        if self.instance_list['state'] == NORMAL:
            self.instance_list.config(state=DISABLED)
            try:
                instance_name = self.get_selected_instance_name()
                self.instance_txt.configure(state=NORMAL)
                self.instance_txt.delete("1.0", END)
                if instance_name != '':
                    if instance_name not in self.running_instance.keys():
                        self.running_instance[instance_name] = None
                    inst = LucteriosInstance(instance_name)
                    inst.read()
                    self.instance_txt.insert(END, "\t\t\t%s\n\n" % inst.name)
                    self.instance_txt.insert(
                        END, ugettext("Database\t\t%s\n") % inst.get_database_txt())
                    self.instance_txt.insert(
                        END, ugettext("Appli\t\t%s\n") % inst.get_appli_txt())
                    self.instance_txt.insert(
                        END, ugettext("Modules\t\t%s\n") % inst.get_module_txt())
                    self.instance_txt.insert(
                        END, ugettext("Extra\t\t%s\n") % inst.get_extra_txt())
                    self.instance_txt.insert(END, '\n')
                    if self.running_instance[instance_name] is not None and self.running_instance[instance_name].is_running():
                        self.instance_txt.insert(END, ugettext(
                            "=> Running in http://%(ip)s:%(port)d\n") % {'ip': self.running_instance[instance_name].lan_ip, 'port': self.running_instance[instance_name].port})
                        self.btninstframe.winfo_children()[0]["text"] = ugettext(
                            "Stop")
                    else:
                        self.running_instance[instance_name] = None
                        self.instance_txt.insert(END, ugettext("=> Stopped\n"))
                        self.btninstframe.winfo_children()[0]["text"] = ugettext(
                            "Launch")
                else:
                    self.btninstframe.winfo_children()[0]["text"] = ugettext(
                        "Launch")
                self.btninstframe.winfo_children()[0].disabled = (
                    instance_name == '')
                self.btninstframe.winfo_children()[1].disabled = (
                    instance_name == '')
                self.btninstframe.winfo_children()[2].disabled = (
                    instance_name == '')
                self.btninstframe.winfo_children()[3].disabled = (
                    instance_name == '')
                self.btninstframe.winfo_children()[4].disabled = (
                    instance_name == '')
                self.instance_txt.configure(state=DISABLED)
            finally:
                setup_from_none()
                self.instance_list.config(state=NORMAL)
Beispiel #6
0
    def test_extra(self):
        self.assertEqual([], self.luct_glo.listing())

        inst = LucteriosInstance("inst_e", self.path_dir)
        inst.set_extra("DEBUG=True,ALLOWED_HOSTS=[localhost]")
        inst.add()
        self.assertEqual(["inst_e"], self.luct_glo.listing())

        # print(open(self.path_dir + '/inst_a/settings.py', 'r').readlines())

        inst = LucteriosInstance("inst_e", self.path_dir)
        inst.read()
        self.assertEqual({'DEBUG': True, '': {'mode': (
            0, 'Connexion toujours nécessaire')}, 'ALLOWED_HOSTS': ['localhost']}, inst.extra)
Beispiel #7
0
 def _load_current_data(self, instance_name):
     from lucterios.framework.settings import DEFAULT_LANGUAGES, get_locale_lang
     self.is_new_instance = False
     lct_inst = LucteriosInstance(instance_name)
     lct_inst.read()
     self.name.delete(0, END)
     self.name.insert(0, lct_inst.name)
     self.name.config(state=DISABLED)
     applis_id = 0
     for appli_iter in range(len(self.mod_applis)):
         if self.mod_applis[appli_iter][0] == lct_inst.appli_name:
             applis_id = appli_iter
             break
     self.applis.current(applis_id)
     if lct_inst.extra['']['mode'] is not None:
         self.mode.current(lct_inst.extra['']['mode'][0])
     else:
         self.mode.current(2)
     self.mode_selection(None)
     typedb_index = 0
     for typedb_idx in range(len(self.typedb[VALUES])):
         if self.typedb[VALUES][typedb_idx].lower(
         ) == lct_inst.database[0].lower():
             typedb_index = typedb_idx
             break
     self.typedb.current(typedb_index)
     self.typedb.config(state=DISABLED)
     self.typedb_selection(None)
     self.namedb.delete(0, END)
     if 'name' in lct_inst.database[1].keys():
         self.namedb.insert(0, lct_inst.database[1]['name'])
     self.userdb.delete(0, END)
     if 'user' in lct_inst.database[1].keys():
         self.userdb.insert(0, lct_inst.database[1]['user'])
     self.pwddb.delete(0, END)
     if 'password' in lct_inst.database[1].keys():
         self.pwddb.insert(0, lct_inst.database[1]['password'])
     self.modules.select_clear(0, self.modules.size())
     for mod_idx in range(len(self.module_data)):
         current_mod = self.module_data[mod_idx]
         if current_mod in lct_inst.modules:
             self.modules.select_set(mod_idx)
     current_lang = get_locale_lang()
     if 'LANGUAGE_CODE' in lct_inst.extra.keys():
         current_lang = lct_inst.extra['LANGUAGE_CODE']
     for lang in DEFAULT_LANGUAGES:
         if lang[0] == current_lang:
             self.language.current(self.language[VALUES].index(lang[1]))
Beispiel #8
0
 def _load_current_data(self, instance_name):
     from lucterios.framework.settings import DEFAULT_LANGUAGES, get_locale_lang
     self.is_new_instance = False
     lct_inst = LucteriosInstance(instance_name)
     lct_inst.read()
     self.name.delete(0, END)
     self.name.insert(0, lct_inst.name)
     self.name.config(state=DISABLED)
     applis_id = 0
     for appli_iter in range(len(self.mod_applis)):
         if self.mod_applis[appli_iter][0] == lct_inst.appli_name:
             applis_id = appli_iter
             break
     self.applis.current(applis_id)
     if lct_inst.extra['']['mode'] is not None:
         self.mode.current(lct_inst.extra['']['mode'][0])
     else:
         self.mode.current(2)
     self.mode_selection(None)
     typedb_index = 0
     for typedb_idx in range(len(self.typedb[VALUES])):
         if self.typedb[VALUES][typedb_idx].lower() == lct_inst.database[0].lower():
             typedb_index = typedb_idx
             break
     self.typedb.current(typedb_index)
     self.typedb.config(state=DISABLED)
     self.typedb_selection(None)
     self.namedb.delete(0, END)
     if 'name' in lct_inst.database[1].keys():
         self.namedb.insert(0, lct_inst.database[1]['name'])
     self.userdb.delete(0, END)
     if 'user' in lct_inst.database[1].keys():
         self.userdb.insert(0, lct_inst.database[1]['user'])
     self.pwddb.delete(0, END)
     if 'password' in lct_inst.database[1].keys():
         self.pwddb.insert(0, lct_inst.database[1]['password'])
     self.modules.select_clear(0, self.modules.size())
     for mod_idx in range(len(self.module_data)):
         current_mod = self.module_data[mod_idx]
         if current_mod in lct_inst.modules:
             self.modules.select_set(mod_idx)
     current_lang = get_locale_lang()
     if 'LANGUAGE_CODE' in lct_inst.extra.keys():
         current_lang = lct_inst.extra['LANGUAGE_CODE']
     for lang in DEFAULT_LANGUAGES:
         if lang[0] == current_lang:
             self.language.current(self.language[VALUES].index(lang[1]))
Beispiel #9
0
    def test_extra(self):
        self.assertEqual([], self.luct_glo.listing())

        inst = LucteriosInstance("inst_e", self.path_dir)
        inst.set_extra("DEBUG=True,ALLOWED_HOSTS=[localhost;127.0.0.1],DEFAULT_PAGE=cms/,NBMAX=5,PIVALUE=3.1415")
        inst.add()
        self.assertEqual(["inst_e"], self.luct_glo.listing())

        # print(open(self.path_dir + '/inst_a/settings.py', 'r').readlines())

        inst = LucteriosInstance("inst_e", self.path_dir)
        inst.read()
        self.assertEqual({'DEBUG': True, '': {'mode': (0, 'Connexion toujours nécessaire')},
                          'ALLOWED_HOSTS': ['localhost', '127.0.0.1'], 'DEFAULT_PAGE': 'cms/',
                          "NBMAX": 5, 'PIVALUE': 3.1415}, inst.extra)
        inst.modif()

        inst = LucteriosInstance("inst_e", self.path_dir)
        inst.read()
Beispiel #10
0
    def test_add_modif(self):
        self.assertEqual([], self.luct_glo.listing())

        inst = LucteriosInstance("inst_b", self.path_dir)
        inst.add()
        self.assertEqual(["inst_b"], self.luct_glo.listing())

        inst = LucteriosInstance("inst_b", self.path_dir)
        inst.set_database("sqlite")
        inst.appli_name = "lucterios.standard"
        inst.modules = ('lucterios.dummy',)
        inst.modif()

        inst = LucteriosInstance("inst_b", self.path_dir)
        inst.read()
        self.assertEqual(("sqlite", {}), inst.database)
        self.assertEqual("lucterios.standard", inst.appli_name)
        self.assertEqual(('lucterios.dummy',), inst.modules)

        inst = LucteriosInstance("inst_b", self.path_dir)
        inst.refresh()
Beispiel #11
0
 def select_instance(self, evt):
     if self.instance_list['state'] == NORMAL:
         self.instance_list.config(state=DISABLED)
         try:
             instance_name = self.get_selected_instance_name()
             self.instance_txt.configure(state=NORMAL)
             self.instance_txt.delete("1.0", END)
             if instance_name != '':
                 if instance_name not in self.running_instance.keys():
                     self.running_instance[instance_name] = None
                 inst = LucteriosInstance(instance_name)
                 inst.read()
                 self.instance_txt.insert(END, "\t\t\t%s\n\n" % inst.name)
                 self.instance_txt.insert(
                     END, ugettext("Database\t\t%s\n") % inst.get_database_txt())
                 self.instance_txt.insert(
                     END, ugettext("Appli\t\t%s\n") % inst.get_appli_txt())
                 self.instance_txt.insert(
                     END, ugettext("Modules\t\t%s\n") % inst.get_module_txt())
                 self.instance_txt.insert(
                     END, ugettext("Extra\t\t%s\n") % inst.get_extra_txt())
                 self.instance_txt.insert(END, '\n')
                 if self.running_instance[instance_name] is not None and self.running_instance[instance_name].is_running():
                     self.instance_txt.insert(END, ugettext("=> Running in http://%(ip)s:%(port)d\n") % {'ip': self.running_instance[instance_name].lan_ip, 'port': self.running_instance[instance_name].port})
                     self.btninstframe.winfo_children()[0]["text"] = ugettext("Stop")
                 else:
                     self.running_instance[instance_name] = None
                     self.instance_txt.insert(END, ugettext("=> Stopped\n"))
                     self.btninstframe.winfo_children()[0]["text"] = ugettext("Launch")
             else:
                 self.btninstframe.winfo_children()[0]["text"] = ugettext("Launch")
             self.btninstframe.winfo_children()[0].disabled = (instance_name == '')
             self.btninstframe.winfo_children()[1].disabled = (instance_name == '')
             self.btninstframe.winfo_children()[2].disabled = (instance_name == '')
             self.btninstframe.winfo_children()[3].disabled = (instance_name == '')
             self.btninstframe.winfo_children()[4].disabled = (instance_name == '')
             self.instance_txt.configure(state=DISABLED)
         finally:
             setup_from_none()
             self.instance_list.config(state=NORMAL)
Beispiel #12
0
 def _get_instance_elements(self, instance_name):
     from lucterios.framework.settings import get_locale_lang
     lct_inst = LucteriosInstance(instance_name)
     lct_inst.read()
     applis_id = 0
     for appli_iter in range(len(self.mod_applis)):
         if self.mod_applis[appli_iter][0] == lct_inst.appli_name:
             applis_id = appli_iter
             break
     if lct_inst.extra['']['mode'] is not None:
         mode_id = lct_inst.extra['']['mode'][0]
     else:
         mode_id = 2
     typedb_index = 0
     for typedb_idx in range(len(self.dbtype_values)):
         if self.dbtype_values[typedb_idx].lower(
         ) == lct_inst.database[0].lower():
             typedb_index = typedb_idx
             break
     current_lang = get_locale_lang()
     if 'LANGUAGE_CODE' in lct_inst.extra.keys():
         current_lang = lct_inst.extra['LANGUAGE_CODE']
     return lct_inst, applis_id, mode_id, typedb_index, current_lang