Check-in [0ef1977fd2]
Overview
Comment: | os.access(gtk_dir, os.W_OK) in installhandler() not working on Windows (10). Incorrectly returns true for ProgramFiles paths, thus dll copying failed. Finally more cleanup code to remove the zip file, as well as dll - after successful extraction. → clear_theme() and clear_dll() are the new corresponding functions. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0ef1977fd28b40c258dad95176ad6ecf |
User & Date: | Oliver on 2016-12-18 20:32:22 |
Other Links: | manifest | tags |
Context
2016-12-18
| ||
20:34 | Minor fixes to Win installer/uninstall, regarding background color, and streamripper detection. check-in: fb1512484e user: Oliver tags: trunk | |
20:32 | os.access(gtk_dir, os.W_OK) in installhandler() not working on Windows (10). Incorrectly returns true for ProgramFiles paths, thus dll copying failed. Finally more cleanup code to remove the zip file, as well as dll - after successful extraction. → clear_theme() and clear_dll() are the new corresponding functions. check-in: 0ef1977fd2 user: Oliver tags: trunk | |
14:04 | Add more .progress() indication check-in: 0c7040e314 user: mario tags: trunk | |
Changes
Modified contrib/theme_installer.py from [d8378ec0f4] to [c01fa877e8].
︙ | ︙ | |||
56 57 58 59 60 61 62 | class theme_installer(object): # plugin info module = "theme_installer" meta = plugin_meta() category = "themes" theme_dir = conf.dir + "/themes/" | | > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | class theme_installer(object): # plugin info module = "theme_installer" meta = plugin_meta() category = "themes" theme_dir = conf.dir + "/themes/" # themes_url = "http://milki.include-once.org/streamtuner2/themes/" themes_url = "http://oha59.bplaced.net/streamtuner2/themes/" themes_csv = "themes.json" mime = "zip/gtk-theme" parent = None bm = None # register def __init__(self, parent): |
︙ | ︙ | |||
89 90 91 92 93 94 95 | def apply_theme(self, now=True): if conf.theme == "default": return # look if theme exists fn = "%s%s/%s" % (self.theme_dir, conf.theme, "gtk-2.0/gtkrc") if not os.path.exists(fn): return | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | def apply_theme(self, now=True): if conf.theme == "default": return # look if theme exists fn = "%s%s/%s" % (self.theme_dir, conf.theme, "gtk-2.0/gtkrc") if not os.path.exists(fn): return log.GTK_THEME_FILE("XYZ " + fn) # .GTKRC/Gtk2 uikit.gtk.rc_parse_string("module_path \"%s:%s\"\n" % (uikit.gtk.rc_get_module_dir(), self.theme_dir)) uikit.gtk.rc_parse(fn) uikit.gtk.rc_reset_styles(uikit.gtk.settings_get_for_screen(uikit.gtk.gdk.screen_get_default())) # download list of themes def update_streams(self, cat): |
︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | for d in r: d["favicon"] = fi.row_to_fn(d) if not os.path.exists(d["favicon"]): fi.banner_localcopy(d["img"], d["favicon"], 64) log.COPY( d["img"], d["favicon"] ) return r # invoked by action. module when encounterin a zip/gtk-theme links def install_handler(self, row, audioformat, source, assoc): if not "url" in row: return # download log.THEME_INSTALL(row["url"]) zip = self.theme_dir + os.path.basename(row["url"]) #if not os.path.exists(zip): with open(zip, "wb") as f: f.write(ahttp.get(row["url"], binary=True)) # extract z = zipfile.ZipFile(zip) z.extractall(self.theme_dir) ls = z.namelist() dll = [fn for fn in ls if re.search("\w+\.(dll|so)$", fn)] base = [m.group(1) for fn in ls for m in [re.match("^([\w\s\-\.]+)/gtk-2.0/.+", fn)] if m] # move *.dll / *.so for gtk_dir in uikit.gtk.rc_get_module_dir().split(";" if conf.windows else ":"): if os.path.exists(gtk_dir) and os.access(gtk_dir, os.W_OK): for fn in dll: if fn.find("/") > 0: # create lib/engines/.../ if given try: os.makedirs(self.theme_dir + os.path.basename(fn)) except: pass # copy file | > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | for d in r: d["favicon"] = fi.row_to_fn(d) if not os.path.exists(d["favicon"]): fi.banner_localcopy(d["img"], d["favicon"], 64) log.COPY( d["img"], d["favicon"] ) return r # invoked by action. module when encounterin a zip/gtk-theme links def install_handler(self, row, audioformat, source, assoc): if not "url" in row: return # download log.THEME_INSTALL(row["url"]) zip = self.theme_dir + os.path.basename(row["url"]) #if not os.path.exists(zip): with open(zip, "wb") as f: f.write(ahttp.get(row["url"], binary=True)) # extract z = zipfile.ZipFile(zip) z.extractall(self.theme_dir) z.close() os.remove(zip) ls = z.namelist() dll = [fn for fn in ls if re.search("\w+\.(dll|so)$", fn)] base = [m.group(1) for fn in ls for m in [re.match("^([\w\s\-\.]+)/gtk-2.0/.+", fn)] if m] # move *.dll / *.so for gtk_dir in uikit.gtk.rc_get_module_dir().split(";" if conf.windows else ":"): if os.path.exists(gtk_dir) and os.access(gtk_dir, os.W_OK): for fn in dll: if fn.find("/") > 0: # create lib/engines/.../ if given try: os.makedirs(self.theme_dir + os.path.basename(fn)) except: pass # copy file try: if shutil.copy(self.theme_dir + fn, gtk_dir): break except Exception as e: log.THEME_INSTALL("Copy Gtk theme engine error ", e) self.parent.status('<span background="orange">â›” Set theme unsuccessful. - Check access rights!</span>', timeout=22, markup=1) self.clear_theme(ls, dll) return else: self.clear_theme(ls) return # enable if dll: self.clear_dll(dll) conf.theme = base[0] self.apply_theme(True) conf.save() # delete theme files if application failed def clear_theme(self, ls, dll): for fn in ls: try: shutil.rmtree(self.theme_dir + fn) except: pass # probably not found if dll: self.clear_dll(dll) # delete theme engine dll def clear_dll(self, dll): for fn in dll: os.remove(self.theme_dir + fn) |