コード例 #1
0
ファイル: factory.py プロジェクト: sagara-/ibus-table
    def create_engine(self, engine_name):
        # because we need db to be past to Engine
        # the type (engine_name) == dbus.String
        name = engine_name.encode('utf8')
        self.engine_path = engine_base_path % path_patt.sub('_', name)
        try:
            if not self.db:
                # first check self.dbdict
                if not name in self.dbdict:
                    try:
                        db_dir = os.path.join(os.getenv('IBUS_TABLE_LOCATION'),
                                              'tables')
                    except:
                        db_dir = "/usr/share/ibus-table/tables"
                    db = os.path.join(db_dir, name + '.db')
                    udb = name + '-user.db'
                    _sq_db = tabsqlitedb.tabsqlitedb(name=db, user_db=udb)
                    _sq_db.db.commit()
                    self.dbdict[name] = _sq_db
            else:
                name = self.dbusname

            engine = table.tabengine(self.bus, self.engine_path \
                    + str(self.engine_id), self.dbdict[name])
            self.engine_id += 1
            #return engine.get_dbus_object()
            return engine
        except:
            print "fail to create engine %s" % engine_name
            import traceback
            traceback.print_exc()
            raise IBusException("Can not create engine %s" % engine_name)
コード例 #2
0
ファイル: factory.py プロジェクト: phuang/ibus-table
    def create_engine(self, engine_name):
        # because we need db to be past to Engine
        # the type (engine_name) == dbus.String
        name = engine_name.encode("utf8")
        self.engine_path = engine_base_path % path_patt.sub("_", name)
        try:
            if not self.db:
                # first check self.dbdict
                if not name in self.dbdict:
                    try:
                        db_dir = os.path.join(os.getenv("IBUS_TABLE_LOCATION"), "tables")
                    except:
                        db_dir = "/usr/share/ibus-table/tables"
                    db = os.path.join(db_dir, name + ".db")
                    udb = name + "-user.db"
                    _sq_db = tabsqlitedb.tabsqlitedb(name=db, user_db=udb)
                    _sq_db.db.commit()
                    self.dbdict[name] = _sq_db
            else:
                name = self.dbusname

            engine = table.tabengine(self.bus, self.engine_path + str(self.engine_id), self.dbdict[name])
            self.engine_id += 1
            # return engine.get_dbus_object()
            return engine
        except:
            print "fail to create engine %s" % engine_name
            import traceback

            traceback.print_exc()
            raise IBusException("Can not create engine %s" % engine_name)
コード例 #3
0
ファイル: factory.py プロジェクト: bernardn/ibus-table
    def do_create_engine(self, engine_name):
        # because we need db to be past to Engine
        # the type (engine_name) == dbus.String
        name = engine_name.encode ('utf8')
        self.engine_path = engine_base_path % path_patt.sub ('_', name)
        try:
            if not self.db:
                # first check self.dbdict
                if not name in self.dbdict:
                    try:
                        db_dir = os.path.join (os.getenv('IBUS_TABLE_LOCATION'),'tables')
                    except:
                        db_dir = "/usr/share/ibus-table/tables"
                    db = os.path.join (db_dir,name+'.db')
                    udb = name+'-user.db'
                    if not os.path.exists(db):
                        byo_db_dir = os.path.join(os.getenv('HOME'), '.ibus/byo-tables')
                        db = os.path.join(byo_db_dir, name + '.db')                    
                    _sq_db = tabsqlitedb.tabsqlitedb( name = db,user_db = udb )
                    _sq_db.db.commit()
                    self.dbdict[name] = _sq_db
            else:
                name = self.dbusname

            engine = table.tabengine(self.bus, self.engine_path \
                    + str(self.engine_id), self.dbdict[name])
            self.engine_id += 1
            #return engine.get_dbus_object()
            return engine
        except:
            print "fail to create engine %s" % engine_name
            import traceback
            traceback.print_exc ()
            raise Exception("Can not create engine %s" % engine_name)
コード例 #4
0
ファイル: factory.py プロジェクト: 12019/system-config
 def create_engine(self, engine_name):
     # because we need db to be past to Engine
     # the type (engine_name) == dbus.String
     print 'hello world, engine is', engine_name
     name = engine_name.encode ('utf8')
     self.engine_path = engine_base_path % path_patt.sub ('_', name)
     try:
         engine = table.tabengine(self.bus, 
                                  self.engine_path + str(self.engine_id))
         self.engine_id += 1
         #return engine.get_dbus_object()
         return engine
     except:
         print "fail to create engine %s" % engine_name
         import traceback
         traceback.print_exc ()
         raise IBusException("Can not create engine %s" % engine_name)
コード例 #5
0
 def create_engine(self, engine_name):
     # because we need db to be past to Engine
     # the type (engine_name) == dbus.String
     print 'hello world, engine is', engine_name
     name = engine_name.encode('utf8')
     self.engine_path = engine_base_path % path_patt.sub('_', name)
     try:
         engine = table.tabengine(self.bus,
                                  self.engine_path + str(self.engine_id))
         self.engine_id += 1
         #return engine.get_dbus_object()
         return engine
     except:
         print "fail to create engine %s" % engine_name
         import traceback
         traceback.print_exc()
         raise IBusException("Can not create engine %s" % engine_name)
コード例 #6
0
ファイル: factory.py プロジェクト: JamesLinus/ibus-table
    def do_create_engine(self, engine_name):
        engine_name = re.sub(r'^table:', '', engine_name)
        engine_base_path = "/com/redhat/IBus/engines/table/%s/engine/"
        path_patt = re.compile(r'[^a-zA-Z0-9_/]')
        self.engine_path = engine_base_path % path_patt.sub ('_', engine_name)
        try:
            if not self.db:
                # first check self.dbdict
                if not engine_name in self.dbdict:
                    try:
                        db_dir = os.path.join(
                            os.getenv('IBUS_TABLE_LOCATION'),'tables')
                    except:
                        db_dir = "/usr/share/ibus-table/tables"
                    db = os.path.join (db_dir, engine_name+'.db')
                    udb = engine_name+'-user.db'
                    if not os.path.exists(db):
                        byo_db_dir = os.path.join(
                            os.getenv('HOME'), '.ibus/byo-tables')
                        db = os.path.join(byo_db_dir, engine_name + '.db')
                    _sq_db = tabsqlitedb.tabsqlitedb(
                        filename = db, user_db = udb)
                    _sq_db.db.commit()
                    self.dbdict[engine_name] = _sq_db
            else:
                name = self.dbusname

            engine = table.tabengine(self.bus,
                                     self.engine_path + str(self.engine_id),
                                     self.dbdict[engine_name])
            self.engine_id += 1
            #return engine.get_dbus_object()
            return engine
        except:
            print("failed to create engine %s" %engine_name)
            import traceback
            traceback.print_exc ()
            raise Exception("Cannot create engine %s" %engine_name)
コード例 #7
0
ファイル: factory.py プロジェクト: JamesLinus/ibus-table
    def do_create_engine(self, engine_name):
        engine_name = re.sub(r'^table:', '', engine_name)
        engine_base_path = "/com/redhat/IBus/engines/table/%s/engine/"
        path_patt = re.compile(r'[^a-zA-Z0-9_/]')
        self.engine_path = engine_base_path % path_patt.sub('_', engine_name)
        try:
            if not self.db:
                # first check self.dbdict
                if not engine_name in self.dbdict:
                    try:
                        db_dir = os.path.join(os.getenv('IBUS_TABLE_LOCATION'),
                                              'tables')
                    except:
                        db_dir = "/usr/share/ibus-table/tables"
                    db = os.path.join(db_dir, engine_name + '.db')
                    udb = engine_name + '-user.db'
                    if not os.path.exists(db):
                        byo_db_dir = os.path.join(os.getenv('HOME'),
                                                  '.ibus/byo-tables')
                        db = os.path.join(byo_db_dir, engine_name + '.db')
                    _sq_db = tabsqlitedb.tabsqlitedb(filename=db, user_db=udb)
                    _sq_db.db.commit()
                    self.dbdict[engine_name] = _sq_db
            else:
                name = self.dbusname

            engine = table.tabengine(self.bus,
                                     self.engine_path + str(self.engine_id),
                                     self.dbdict[engine_name])
            self.engine_id += 1
            #return engine.get_dbus_object()
            return engine
        except:
            print("failed to create engine %s" % engine_name)
            import traceback
            traceback.print_exc()
            raise Exception("Cannot create engine %s" % engine_name)