Changeset 7069 for lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/snapManager.py
- Timestamp:
- Mar 16, 2018, 1:21:09 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/snapManager.py
r6693 r7069 15 15 16 16 def __init__(self): 17 self.dbg= False17 self.dbg=True 18 18 self.progress=0 19 19 self.partial_progress=0 20 20 self.plugin_actions={'install':'snap','remove':'snap','pkginfo':'snap','load':'snap'} 21 self.cache_dir= "/var/lib/lliurexstore/bundles/cache"21 self.cache_dir=os.getenv("HOME")+"/.cache/lliurex-store" 22 22 self.icons_folder=self.cache_dir+"/icons" 23 self.images_folder=self.cache_dir+"/images" 23 24 self.result={} 24 25 self.result['data']={} … … 114 115 bundle=appstream.Bundle() 115 116 app=appstream.App() 117 icon=appstream.Icon() 118 screenshot=appstream.Screenshot() 116 119 #F*****g appstream have kinds undefined but kind_from_string works... wtf? 117 120 # bundle.set_kind(appstream.BundleKind.SNAP) … … 136 139 137 140 if pkg.get_icon(): 138 app.set_icon_path(pkg.get_icon()) 141 if self.icon_cache_enabled: 142 icon.set_kind(appstream.IconKind.LOCAL) 143 icon.set_name(self._download_file(pkg.get_icon(),pkg.get_name())) 144 else: 145 icon.set_kind(appstream.IconKind.REMOTE) 146 icon.set_name(pkg.get_icon()) 147 app.add_icon(icon) 148 149 if pkg.get_license(): 150 app.set_project_license(pkg.get_license()) 151 152 # if pkg.get_screenshots(): 153 # img=appstream.Image() 154 # screenshot_list=[] 155 # for screen in pkg.get_screenshots(): 156 # screenshot_list.append(screen.get_url()) 157 158 # app_info["screenshots"]=screenshot_list 139 159 return(app) 140 160 … … 167 187 self._debug("Searching %s"%tokens) 168 188 pkg=None 189 pkgs=None 169 190 try: 170 191 pkgs=self.snap_client.find_sync(Snapd.FindFlags.MATCH_NAME,tokens,None,None) … … 176 197 if pkg.get_channel()=='stable': 177 198 stable_pkgs.append(pkg) 199 else: 200 self._debug(pkg.get_channel()) 178 201 self._debug("Done") 179 202 return(stable_pkgs) … … 206 229 #switch to launch async method when running under a gui 207 230 #For an unknown reason request will block when sync mode under a gui and async blocks when on cli (really funny) 208 if self.cli_mode: 209 pkgs=self._search_snap(app_info['name']) 210 else: 211 pkgs=self._search_snap_async(app_info['name']) 231 self._debug("Getting info for %s"%app_info) 232 pkg=None 233 try: 234 pkg=self.snap_client.list_one_sync(app_info['name']) 235 app_info['state']='installed' 236 pkgs=[pkg] 237 except: 238 app_info['state']='available' 239 if self.cli_mode: 240 pkgs=self._search_snap(app_info['name']) 241 else: 242 pkgs=self._search_snap_async(app_info['name']) 243 self._debug("Getting extended info for %s %s"%(app_info['name'],pkgs)) 212 244 if type(pkgs)==type([]): 213 245 for pkg in pkgs: 246 self._debug("Getting extended info for %s"%app_info['name']) 214 247 if pkg.get_download_size(): 215 248 app_info['size']=str(pkg.get_download_size()) 216 249 else: 217 250 app_info['size']=str(pkg.get_installed_size()) 218 if pkg.get_icon():219 if self.icon_cache_enabled:220 app_info['icon']=self._download_file(pkg.get_icon(),app_info['name'])221 else:222 app_info['icon']=pkg.get_icon()223 if pkg.get_status():224 #Not working on xenial225 # if pkg.get_status()==Snapd.SnapStatus.INSTALLED or pkg.get_status()==3:226 # app_info['state']='installed'227 try:228 self.snap_client.list_one_sync(pkg.get_name())229 app_info['state']='installed'230 except:231 app_info['state']='available'232 if pkg.get_screenshots():233 screenshot_list=[]234 for screen in pkg.get_screenshots():235 screenshot_list.append(screen.get_url())236 app_info["screenshots"]=screenshot_list237 #Method not working in xenial, license default type assigned in infoManager238 # if pkg.get_license():239 # app_info["license"]=pkg.get_license()240 251 break 241 252 else:
Note: See TracChangeset
for help on using the changeset viewer.