当前位置: 首页>>代码示例>>Python>>正文


Python Config.get方法代码示例

本文整理汇总了Python中deepin_utils.config.Config.get方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get方法的具体用法?Python Config.get怎么用?Python Config.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在deepin_utils.config.Config的用法示例。


在下文中一共展示了Config.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
def run():
    if not os.path.exists(data_newest_id_path):
        newest_data_id_config = Config(data_newest_id_path)
        newest_data_id_config.load()
        newest_data_id_config.set("newest", "data_id", "")
        newest_data_id_config.set("newest", "update_date", "")
        newest_data_id_config.write()
    else:
        newest_data_id_config = Config(data_newest_id_path)
        newest_data_id_config.load()

    try:
        update_date = newest_data_id_config.get("newest", "update_date")
    except Exception:
        update_date = ""

    if newest_data_id_config.get("newest", "data_id") == "" or update_date != UPDATE_DATE:
        clean()
        newest_data_id = str(uuid.uuid4())
        newest_data_dir = os.path.join(DATA_DIR, "update", newest_data_id)
        
        print "进行第一次数据解压..."
        for data_file in os.listdir(data_origin_dir):
            with tarfile.open(os.path.join(data_origin_dir, data_file), "r:gz") as tar_file:
                tar_file.extractall(newest_data_dir)
        print "进行第一次数据解压完成"
        
        newest_data_id_config.set("newest", "data_id", newest_data_id)
        newest_data_id_config.set("newest", "update_date", UPDATE_DATE)
        newest_data_id_config.write()
开发者ID:martyr-deepin,项目名称:deepin-software-center-data,代码行数:32,代码来源:unpack-data.py

示例2: Mirror

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
class Mirror(object):
    def __init__(self, ini_file):
        self.config = Config(ini_file)
        self.config.load()
        deepin_url = self.get_repo_urls()[1]
        _url_parse = urlparse(deepin_url)
        self._hostname = _url_parse.scheme + "://" + _url_parse.netloc
        self._priority = int(self.config.get("mirror", "priority")) if self.config.has_option("mirror", "priority") else 100
    
    @property
    def hostname(self):
        return self._hostname

    @property
    def name(self):
        if self.config.has_option('mirror', 'name[%s]' % LANGUAGE):
            return self.config.get('mirror', 'name[%s]' % LANGUAGE)
        else:
            return self.config.get('mirror', 'name[%s]' % 'en_US')

    @property
    def priority(self):
        return self._priority

    def get_repo_urls(self):
        return (self.config.get('mirror', 'ubuntu_url'), self.config.get('mirror', 'deepin_url'))
开发者ID:PeterDaveHello,项目名称:deepin-software-center,代码行数:28,代码来源:mirror_test.py

示例3: scan_plugin_info

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
 def scan_plugin_info(self):
     self.engine_list = []
     self.engine_dict = {}
     
     for plugin_name in os.listdir(self.plugin_dir):
         plugin_config_file = os.path.join(self.plugin_dir, plugin_name, self.plugin_config_name)
         plugin_config = Config(plugin_config_file)
         plugin_config.load()
         
         language = get_language()
         plugin_display_name = plugin_config.get("Plugin Info", "name[%s]" % language) or plugin_config.get("Plugin Info", "name[en]")
         
         need_network = is_true(plugin_config.get("Voice Info", "need_network"))
         support_all_language = is_true(plugin_config.get("Voice Info", "support_all_language"))
         support_languages_info = plugin_config.get("Voice Info", "support_languages")
         priority = plugin_config.get("Voice Info", "priority")
         if support_languages_info == None:
             support_languages = []
         else:
             support_languages = support_languages_info.split(",")
             
         if support_all_language:
             self.engine_list.append((plugin_name, plugin_display_name, priority, need_network))
         else:
             self.update_dict(self.engine_dict, support_languages, plugin_name, plugin_display_name, priority, need_network)
开发者ID:PeterDaveHello,项目名称:deepin-translator,代码行数:27,代码来源:tts_plugin.py

示例4: load_skin_from_package

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
    def load_skin_from_package(self, filepath):
        '''
        Load theme from given package.

        @param filepath: The file path of package.
        '''
        # Init.
        skin_dir = os.path.join(self.user_skin_dir, str(uuid.uuid4()))

        # Create skin directory.
        create_directory(skin_dir, True)

        # Extract skin package.
        tar = tarfile.open(filepath, "r:gz")
        tar.extractall(skin_dir)

        # Get skin image file.
        config = Config(os.path.join(skin_dir, "config.ini"))
        config.load()

        # Move theme files to given directory if theme is not in default theme list.
        skin_theme_name = config.get("theme", "theme_name")
        if not skin_theme_name in COLOR_SEQUENCE:
            # Check version when package have special theme that not include in standard themes.
            app_id = config.get("application", "app_id")
            app_version = config.get("application", "app_version")
            if app_id == self.app_given_id and app_version == self.app_given_version:
                # Remove same theme from given directories.
                remove_directory(os.path.join(self.ui_theme_dir, skin_theme_name))
                if self.app_theme_dir != None:
                    remove_directory(os.path.join(self.app_theme_dir, skin_theme_name))

                # Move new theme files to given directories.
                shutil.move(os.path.join(skin_dir, "ui_theme", skin_theme_name), self.ui_theme_dir)
                if self.app_theme_dir != None:
                    shutil.move(os.path.join(skin_dir, "app_theme", skin_theme_name), self.app_theme_dir)

                # Remove temp theme directories under skin directory.
                remove_directory(os.path.join(skin_dir, "ui_theme"))
                remove_directory(os.path.join(skin_dir, "app_theme"))
            else:
                # Remove skin directory if version mismatch.
                remove_directory(skin_dir)

                return False

        # Apply new skin.
        skin_image_file = config.get("background", "image")
        if self.reload_skin(os.path.basename(skin_dir)):
            self.apply_skin()

            return (True, skin_dir, skin_image_file)
        else:
            return (False, skin_dir, skin_image_file)
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:56,代码来源:skin_config.py

示例5: is_mirror_disabled

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
def is_mirror_disabled():
    if os.path.exists(deepin_version_path):
        config = Config(deepin_version_path)
        config.load()
        return config.has_option("Custom", "Mirror") and config.get("Custom", "Mirror") == "False"
    else:
        return True # not deepin os, disable mirror change
开发者ID:martyr-deepin,项目名称:deepin-store,代码行数:9,代码来源:mirror_test.py

示例6: ModuleInfo

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
class ModuleInfo(object):
    '''
    class docs
    '''
	
    def __init__(self, module_path):
        '''
        init docs
        '''
        self.path = module_path
        self.config = Config(os.path.join(self.path, "config.ini"))
        self.config.load()
        self.id = self.config.get("main", "id")
        # TODO: lihongwu req to support i18n
        self.name = MODULES_NAME_FOR_L18N.get(self.id, "")
        self.default_name = self.config.get("name", "default")

        """
        self.name = self.default_name
        if MAIN_LANG != "en_US":
            self.name = self.config.get("name", MAIN_LANG)
        """

        icon_infos = [self.get_system_icon_info(self.id, 48), 
                      self.get_system_icon_info(self.id, 16),
                     ]
        
        self.icon_pixbuf = None
        self.menu_icon_pixbuf = None
        try:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_infos[0])
            self.menu_icon_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_infos[1])
        except:
            self.icon_pixbuf = app_theme.get_pixbuf("navigate/none-big.png").get_pixbuf()
            self.menu_icon_pixbuf = app_theme.get_pixbuf("navigate/none-small.png").get_pixbuf()
            
        self.search_keyword = self.config.get("main", "search_keyword")
        
    def get_system_icon_info(self, icon_id, icon_size):
        '''
        NOTE: Because dtk.ui.utils.get_system_icon_info need take 20ms every call,
        it will slow down start speed of deepin system settings.
        
        So i return path directly to solve start speed problem.
        '''
        return "/usr/share/icons/Deepin/apps/%s/preferences-%s.png" % (icon_size, icon_id)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:48,代码来源:module_info.py

示例7: save_skin_name

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
 def save_skin_name(self):
     '''
     Internal function to save skin name.
     '''
     skin_config = Config(self.skin_config_file)
     skin_config.load()
     if skin_config.get("skin", "skin_name") != self.skin_name:
         skin_config.set("skin", "skin_name", self.skin_name)
         skin_config.write(self.skin_config_file)
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:11,代码来源:skin_config.py

示例8: is_fontend_running

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
 def is_fontend_running(self):
     if os.path.exists(DATA_CURRENT_ID_CONFIG_PATH):
         config = Config(DATA_CURRENT_ID_CONFIG_PATH)
         config.load()
         data_id = config.get('current', 'data_id')
         if data_id:
             return True
         else:
             return False
     else:
         False
开发者ID:iceleaf916,项目名称:software-update-manager,代码行数:13,代码来源:dsc-daemon.py

示例9: get_last_update_time

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
def get_last_update_time():
    config = Config(SYS_CONFIG_INFO_PATH)

    if os.path.exists(SYS_CONFIG_INFO_PATH):
        config.load()
        if config.has_option("update", "last_update_time"):
            return config.get("update", "last_update_time")
        else:
            return ""
    else:
        return ""
开发者ID:martyr-deepin,项目名称:deepin-store,代码行数:13,代码来源:utils.py

示例10: data_init

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
def data_init():
    global data_init_flag
    global DATA_ID
    
    if not data_init_flag:
        data_init_flag = True
        
        data_newest_id_config = Config(DATA_NEWEST_ID_CONFIG_FILE)
        data_newest_id_config.load()
        DATA_ID = data_newest_id_config.get("newest", "data_id")
        
        if not os.path.exists(DATA_CURRENT_ID_CONFIG_FILE):
            touch_file(DATA_CURRENT_ID_CONFIG_FILE)
            os.chmod(DATA_CURRENT_ID_CONFIG_FILE, 0777)
            
        data_current_id_config = Config(DATA_CURRENT_ID_CONFIG_FILE)
        data_current_id_config.load()
        data_current_id_config.set("current", "data_id", DATA_ID)
        data_current_id_config.write()
开发者ID:PeterDaveHello,项目名称:deepin-software-center,代码行数:21,代码来源:data.py

示例11: init_config

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
    def init_config(self):
        if os.path.exists(CONFIG_INFO_PATH):
            config = Config(CONFIG_INFO_PATH)
            config.load()
            uid = config.get("statistics", 'uid')
            if not uid:
                uid = uuid.uuid4().hex
                config.set("statistics", 'uid', uid)
                config.set("statistics", 'last_date', '')
                config.write()
        else:
            touch_file(CONFIG_INFO_PATH)
            uid = uuid.uuid4().hex
            config = Config(CONFIG_INFO_PATH)
            config.load()
            config.set("statistics", 'uid', uid)
            config.set("statistics", 'last_date', '')
            config.write()

        return config
开发者ID:menghun3,项目名称:deepin-software-center-1,代码行数:22,代码来源:dsc-daemon.py

示例12: init_skin

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
    def init_skin(self,
                  skin_name,
                  system_skin_dir,
                  user_skin_dir,
                  skin_config_file,
                  app_given_id,
                  app_given_version):
        '''
        Init skin.

        @param skin_name: Skin name.
        @param system_skin_dir: Default skin directory.
        @param user_skin_dir: User's skin directory, generic use ~/.config/project-name/skin
        @param skin_config_file: Skin's config filepath, generic use ~/.config/project-name/skin_config.ini
        @param app_given_id: Project name.
        @param app_given_version: Project version.
        '''
        self.skin_config_file = skin_config_file
        if os.path.exists(skin_config_file):
            # Read skin name from config file.
            skin_config = Config(skin_config_file)
            skin_config.load()

            # Load skin.
            init_skin_name = skin_config.get("skin", "skin_name")
        else:
            # Create skin config if it not exists.
            touch_file(self.skin_config_file)

            init_skin_name = skin_name

        if self.is_skin_exist(init_skin_name, system_skin_dir, user_skin_dir):
            self.load_skin(init_skin_name, system_skin_dir, user_skin_dir)
        else:
            # Try load default skin if user's select skin not exists.
            default_skin_name = self.get_default_skin(system_skin_dir, user_skin_dir)
            assert(default_skin_name != None)
            self.load_skin(default_skin_name, system_skin_dir, user_skin_dir)

        self.app_given_id = app_given_id
        self.app_given_version = app_given_version
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:43,代码来源:skin_config.py

示例13: scan_plugin_info

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
 def scan_plugin_info(self):
     self.word_all_list = []
     self.words_all_list = []
     self.word_dict = {}
     self.words_dict = {}
     
     for plugin_name in os.listdir(self.plugin_dir):
         plugin_config_file = os.path.join(self.plugin_dir, plugin_name, self.plugin_config_name)
         plugin_config = Config(plugin_config_file)
         plugin_config.load()
         
         language = LANGUAGE.replace("_", "-")
         plugin_display_name = plugin_config.get("Plugin Info", "name[%s]" % language) or plugin_config.get("Plugin Info", "name[en]")
         is_support_word = is_true(plugin_config.get("Language Info", "word_translate"))
         is_support_words = is_true(plugin_config.get("Language Info", "words_translate"))
         support_all_language = is_true(plugin_config.get("Language Info", "support_all_language"))
         two_way_translate = is_true(plugin_config.get("Language Info", "two_way_translate"))
         src_language = plugin_config.get("Language Info", "src_language")
         dst_language = plugin_config.get("Language Info", "dst_language")
         need_network = is_true(plugin_config.get("Language Info", "need_network"))
         
         if is_support_word:
             if support_all_language:
                 self.word_all_list.append((plugin_name, plugin_display_name, need_network))
             else:
                 self.update_dict(self.word_dict, src_language, dst_language, plugin_name, plugin_display_name, need_network)
                 
                 if two_way_translate:
                     self.update_dict(self.word_dict, dst_language, src_language, plugin_name, plugin_display_name, need_network)    
                     
         if is_support_words:
             if support_all_language:
                 self.words_all_list.append((plugin_name, plugin_display_name, need_network))
             else:
                 self.update_dict(self.words_dict, src_language, dst_language, plugin_name, plugin_display_name, need_network)
                 
                 if two_way_translate:
                     self.update_dict(self.words_dict, dst_language, src_language, plugin_name, plugin_display_name, need_network)    
开发者ID:lihongwu,项目名称:deepin-translator,代码行数:40,代码来源:dict_plugin.py

示例14: SkinConfig

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
class SkinConfig(gobject.GObject):
    '''
    SkinConfig class.

    @undocumented: update_image_size
    @undocumented: get_skin_file_path
    @undocumented: is_skin_exist
    @undocumented: get_default_skin
    @undocumented: get_skin_dir
    @undocumented: save_skin_name
    @undocumented: reload_skin
    @undocumented: load_skin
    @undocumented: save_skin
    @undocumented: change_theme
    @undocumented: apply_skin
    @undocumented: add_theme
    @undocumented: remove_theme
    @undocumented: wrap_skin_window
    @undocumented: add_skin_window
    @undocumented: remove_skin_window
    @undocumented: reset
    @undocumented: auto_resize
    @undocumented: vertical_mirror_background
    @undocumented: horizontal_mirror_background
    @undocumented: render_background
    @undocumented: export_skin
    @undocumented: load_skin_from_image
    @undocumented: load_skin_from_package
    '''

    __gsignals__ = {
        "theme-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
    }

    def __init__(self):
        '''
        Initialize SkinConfig class.
        '''
        # Init.
        gobject.GObject.__init__(self)
        self.cache_pixbuf = CachePixbuf()

        self.theme_list = []
        self.window_list = []

    def set_application_window_size(self, app_window_width, app_window_height):
        '''
        Set application window with given size.

        @param app_window_width: Application window width.
        @param app_window_height: Application window height.
        '''
        self.app_window_width = app_window_width
        self.app_window_height = app_window_height

    def update_image_size(self, x, y, scale_x, scale_y):
        '''
        Internal function to update image size.
        '''
        self.x = x
        self.y = y
        self.scale_x = scale_x
        self.scale_y = scale_y

    def get_skin_file_path(self, filename):
        '''
        Internal function to get skin file path.
        '''
        skin_file_dir = None
        for skin_dir in [self.system_skin_dir, self.user_skin_dir]:
            if os.path.exists(skin_dir):
                if self.skin_name in os.listdir(os.path.expanduser(skin_dir)):
                    skin_file_dir = skin_dir
                    break

        if skin_file_dir:
            return os.path.join(skin_file_dir, self.skin_name, filename)
        else:
            return None

    def is_skin_exist(self, skin_name, system_skin_dir, user_skin_dir):
        '''
        Internal function to is skin exist in skin directories.
        '''
        for skin_dir in [system_skin_dir, user_skin_dir]:
            if os.path.exists(skin_dir):
                if skin_name in os.listdir(os.path.expanduser(skin_dir)):
                    return True

        return False

    def get_default_skin(self, system_skin_dir, user_skin_dir):
        '''
        Internal function to get default skin.
        '''
        for skin_dir in [system_skin_dir, user_skin_dir]:
            if os.path.exists(skin_dir):
                skin_list = os.listdir(os.path.expanduser(skin_dir))
                if len(skin_list) > 0:
                    return skin_list[0]
#.........这里部分代码省略.........
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:103,代码来源:skin_config.py

示例15: ModuleFrame

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import get [as 别名]
class ModuleFrame(gtk.Plug):
    '''
    class docs
    '''
	
    def __init__(self, module_config_path, argv=""):
        '''
        init docs
        '''
        # Init.
        gtk.Plug.__init__(self, 0)
        self.module_config_path = module_config_path
        self.module_config = Config(self.module_config_path)
        self.module_config.load()
        self.module_id = self.module_config.get("main", "id")
        self.argv = argv
        
        # WARING: only use once in one process
        DBusGMainLoop(set_as_default=True) 
        
        # Init threads.
        if self.module_id != "bluetooth": # Added by hualet, wonder why? go ask him :)
            gtk.gdk.threads_init()

        # Init dbus.
        self.bus = dbus.SessionBus()
        self.module_dbus_name = "com.deepin.%s_settings" % (self.module_id)
        self.module_object_name = "/com/deepin/%s_settings" % (self.module_id)
        self.module_bus_name = dbus.service.BusName(self.module_dbus_name, bus=self.bus)
        
        # Handle signals.
        self.connect("realize", self.module_frame_realize)
        self.connect("destroy", self.module_frame_exit)

        glib.timeout_add(1000, self.is_exist)

    def is_exist(self):
        if dbus.SessionBus().name_has_owner("com.deepin.system_settings"):
            return True
        else:
            glib.timeout_add(0, gtk.main_quit)
            return False

    def run(self):    
        if not hasattr(self, "module_message_handler"):
            raise Exception, "Please customize your own module_message_handler for module_frame"
        
        # Start dbus service.
        ModuleService(self.module_bus_name, 
                      self.module_dbus_name, 
                      self.module_object_name,
                      self.module_message_handler)
        
        # Show.
        self.show_all()
        
        gtk.main()
        
    def do_delete_event(self, w):
        #a trick to prevent plug destroyed!.  the  better way is recreate an GtkPlug when need reuse it's content
        return True

    def module_frame_realize(self, widget):
        # Send module information.
        self.send_module_info()

    def exit(self):
        gtk.main_quit()

    def module_frame_exit(self, widget):
        print "%s module exit" % (self.module_id)
        
        gtk.main_quit()
        
    def send_message(self, message_type, message_content):    
        if is_dbus_name_exists(APP_DBUS_NAME):
            bus_object = self.bus.get_object(APP_DBUS_NAME, APP_OBJECT_NAME)
            method = bus_object.get_dbus_method("message_receiver")
            method(message_type, 
                   message_content,
                   reply_handler=self.handle_dbus_reply, # add reply handler
                   error_handler=self.handle_dbus_error  # add error handler
                   )
            
    def handle_dbus_reply(self, *reply):
        # print "%s (reply): %s" % (self.module_dbus_name, str(reply))
        pass
        
    def handle_dbus_error(self, *error):
        #print "%s (error): %s" % (self.module_dbus_name, str(error))
        pass
        
    def send_module_info(self):
        module_id = self.module_config.get("main", "id")
        name = MODULES_NAME_FOR_L18N.get(module_id, "")
        self.send_message("send_module_info", 
                          (1, 
                           (module_id,
                            name), 
                           self.argv))
#.........这里部分代码省略.........
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:103,代码来源:module_frame.py


注:本文中的deepin_utils.config.Config.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。