- Timestamp:
- Mar 21, 2018, 6:13:59 PM (3 years ago)
- Location:
- lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/appImageManager.py
r7080 r7092 27 27 self.result['status']={} 28 28 self.conf_dir=os.getenv("HOME")+"/.cache/lliurex-store" 29 self.icons_dir=self.conf_dir+"/icons" 29 30 self.bundles_dir=self.conf_dir+"/bundles" 30 31 self.bundle_types=['appimg'] 31 self.appimage_dir= self.conf_dir+"/appimg"32 self.appimage_dir=os.getenv("HOME")+"/.lliurex-store/appimg" 32 33 #To get the description of an app we must go to a specific url defined in url_info. 33 34 #$(appname) we'll be replaced with the appname so the url matches the right one. 34 35 #If other site has other url naming convention it'll be mandatory to define it with the appropiate replacements 35 36 self.repos={'probono':{'url':'https://dl.bintray.com/probono/AppImages', 'url_info':'https://bintray.com/probono/AppImages/$(appname)'}} 36 #Appimges not stored in a repo must be listed here, providing the download url and the info url (if there's any)37 #Appimges not stored in a repo must be listed in this file, providing the download url and the info url (if there's any) 37 38 self.external_appimages="/usr/share/lliurex-store/files/external_appimages.json" 38 39 self.disabled=False … … 361 362 try: 362 363 if name in self.descriptions_dict.keys(): 363 description=self.descriptions_dict[name]364 (description,icon)=self.descriptions_dict[name] 364 365 else: 365 description=self._get_description(name,info_url,repo_name)366 self.descriptions_dict.update({name: description})366 (description,icon)=self._get_description_icon(name,info_url,repo_name) 367 self.descriptions_dict.update({name:[description,icon]}) 367 368 except: 368 369 description='' 370 icon='' 369 371 summary=' '.join(list(description.split(' ')[:8])) 370 372 description="This is an AppImage bundle of app "+name+". It hasn't been tested by our developers and comes from a 3rd party dev team. Please use it carefully.\n"+description … … 383 385 # f.write(" <category>GTK</category>\n") 384 386 f.write(" </categories>\n") 385 f.write("<icon type=\"cached\">"+name+"_"+name+".png</icon>\n") 387 # f.write("<icon type=\"cached\">"+name+"_"+name+".png</icon>\n") 388 f.write("<icon type=\"local\">"+icon+"</icon>\n") 386 389 f.write("</component>\n") 387 390 f.write("</components>\n") … … 389 392 #def _write_xml_file 390 393 391 def _get_description (self,app_name,info_url,repo_name):394 def _get_description_icon(self,app_name,info_url,repo_name): 392 395 desc='' 393 if '$(appname)' in info_url: 394 info_url=info_url.replace('$(appname)',app_name) 396 icon='' 395 397 if info_url: 398 if '$(appname)' in info_url: 399 info_url=info_url.replace('$(appname)',app_name) 396 400 self._debug("Getting description from repo/app %s - %s "%(repo_name,info_url)) 397 401 try: … … 401 405 soup=BeautifulSoup(content,"html.parser") 402 406 description_div=soup.findAll('div', attrs={ "class" : "description-text"}) 407 icon_div=soup.findAll('div', attrs={ "class" : "avatar-icon avatar-large description-icon "}) 403 408 if len(description_div)>0: 404 409 desc=description_div[0].text 405 410 desc=desc.replace(':','.') 406 411 desc=desc.replace('&','&') 412 if len(icon_div)>0: 413 icon_str=str(icon_div[0]) 414 icon=icon_str.split(' ')[9] 415 icon=icon.lstrip('url(') 416 if icon.startswith('http'): 417 icon=icon.rstrip(');"></div>') 418 icon=self._download_file(icon,app_name) 419 print("Icon: %s"%icon) 407 420 except Exception as e: 408 421 print("Can't get description from "+info_url) 409 422 print(str(e)) 410 423 pass 411 return( desc)424 return([desc,icon]) 412 425 #def _get_description 413 426 … … 425 438 #def _clean_bunlde_catalogue 426 439 440 def _download_file(self,url,app_name): 441 # target_file=self.icons_folder+'/'+app_name+".png" 442 target_file=self.icons_dir+'/'+app_name+".png" 443 if not os.path.isfile(target_file): 444 # shutil.copy("/usr/share/icons/hicolor/128x128/apps/lliurex-store.png",target_file) 445 # if not os.fork(): 446 if not os.path.isfile(target_file): 447 self._debug("Downloading %s to %s"%(url,target_file)) 448 try: 449 with urllib.request.urlopen(url) as response, open(target_file, 'wb') as out_file: 450 bf=16*1024 451 acumbf=0 452 file_size=int(response.info()['Content-Length']) 453 while True: 454 if acumbf>=file_size: 455 break 456 shutil.copyfileobj(response, out_file,bf) 457 acumbf=acumbf+bf 458 st = os.stat(target_file) 459 except Exception as e: 460 self._debug("Unable to download %s"%url) 461 self._debug("Reason: %s"%e) 462 target_file=url 463 # os._exit(0) 464 return(target_file) 465 #def _download_file -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/infoManager.py
r7080 r7092 94 94 appInfo['categories']=app.get_categories() 95 95 if app.get_icon_default(): 96 appInfo['icon']=app.get_icon_default().get_name() 96 if app.get_icon_default().get_filename(): 97 appInfo['icon']=app.get_icon_default().get_filename() 98 else: 99 appInfo['icon']=app.get_icon_default().get_name() 97 100 if appInfo['icon']==None: 98 101 icons=app.get_icons() -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/snapManager.py
r7080 r7092 234 234 self._debug("Unable to download %s"%url) 235 235 self._debug("Reason: %s"%e) 236 target_file='' 236 237 # os._exit(0) 237 238 return(target_file)
Note: See TracChangeset
for help on using the changeset viewer.