def get_styles(self, theme_name=None): # For DockbarX preference. This function makes a dict of the names and # file names of the styles for all styles that can be opened correctly. styles = {} style_folder = os.path.join(get_app_homedir(), "themes", "popup_styles") dirs = ["/usr/share/dockbarx/themes/popup_styles", style_folder] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): if f[-7:] == ".tar.gz": name, oft = self.check(dir+"/"+f) if oft: # The style is meant only for themes # mentioned in oft. if theme_name is None: continue oft = [t.strip().lstrip().lower() \ for t in oft.split(",")] if not theme_name.lower() in oft: continue if name: styles[name] = f # The default style (if the theme doesn't set another one) is DBX, # wheter or not the file actually exists. if not "DBX" in styles: styles["DBX"] = "dbx.tar.gz" return styles
def log_to_file(): log_dir = os.path.join(common.get_app_homedir(), "log") if not os.path.exists(log_dir): os.makedirs(log_dir) log_file = os.path.join(log_dir, "dockbarx.log") file_handler = logging.handlers.RotatingFileHandler(log_file, "a", 0, 5) file_handler.setLevel(logging.DEBUG) formatter = logging.Formatter("%(levelname)s\t| " + \ "%(asctime)s\t| %(message)s") file_handler.setFormatter(formatter) logger.addHandler(file_handler) file_handler.doRollover()
def find_themes(self): # Reads the themes from /usr/share/dockbarx/themes/dock_themes and # ${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx/themes/dock_themes # and returns a dict of the theme file names and paths so that a # theme can be loaded themes = {} theme_paths = [] theme_folder = os.path.join(get_app_homedir(), "themes", "dock") dirs = ["/usr/share/dockbarx/themes/dock", theme_folder] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): if f[-7:] == ".tar.gz": themes[f] = dir+"/"+f return themes
def get_themes(self): # For DockbarX preference. This function makes a dict of the names and # file names of the themes for all themes that can be opened correctly. themes = {} theme_folder = os.path.join(get_app_homedir(), "themes", "dock") dirs = ["/usr/share/dockbarx/themes/dock", theme_folder] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): if f[-7:] == ".tar.gz": name = self.check(dir+"/"+f) if name: themes[name] = f # The default theme (if the theme doesn't set another one) is DBX, # wheter or not the file actually exists. if not "DBX" in themes: themes["DBX"] = "dbx.tar.gz" return themes
def find_themes(self): # Reads the themes from /usr/share/dockbarx/themes and # ${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx/themes # and returns a dict of the theme names and paths so # that a theme can be loaded. themes = {} theme_paths = [] theme_folder = os.path.join(get_app_homedir(), "themes") dirs = ["/usr/share/dockbarx/themes", theme_folder] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): if f[-7:] == ".tar.gz": theme_paths.append(dir+"/"+f) for theme_path in theme_paths: try: name = self.check(theme_path) except Exception, detail: logger.exception("Error loading theme from %s"%theme_path) name = None if name is not None: name = str(name) themes[name] = theme_path