Changeset 5188 for lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/appImageManager.py
- Timestamp:
- Jun 16, 2017, 12:22:02 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/appImageManager.py
r5187 r5188 18 18 #action=example 19 19 #package='*' (in this case all packages) 20 self.pluginInfo={'install':'appimage','remove':'appimage','pkginfo':'appimage' ,'loadCatalogue':'appimage'}20 self.pluginInfo={'install':'appimage','remove':'appimage','pkginfo':'appimage'} 21 21 self.result={} 22 22 self.result['data']={} … … 155 155 #def _get_info 156 156 157 def _download_appImg_catalogue(self):158 outfile='appimage.yml'159 outdir="/usr/share/metainfo"160 outdir="/tmp"161 content=''162 applist=[]163 repolist=['https://dl.bintray.com/probono/AppImages']164 self.descDict={}165 for repo in repolist:166 self._debug(("Fetching repo %s")%(repo))167 applist=self._generate_applist(self._fetch_repo(repo))168 self._debug("Processing info...")169 self._th_generate_xml_catalog(applist,outdir)170 self._debug("Fetched repo "+repo)171 self._debug("Setting status to 0")172 self._set_status(0)173 return("Repo fetched")174 175 def _fetch_repo(self,repo):176 with urllib.request.urlopen('https://dl.bintray.com/probono/AppImages') as f:177 content=(f.read().decode('utf-8'))178 return(content)179 180 def _generate_applist(self,content):181 garbageList=[]182 applist=[]183 garbageList=content.split(' ')184 for garbageLine in garbageList:185 if garbageLine.endswith('AppImage"'):186 app=garbageLine.replace('href=":','')187 applist.append(app.replace('"',''))188 return(applist)189 190 def _get_description(self,appName):191 desc=''192 self._debug("Getting description from 'https://bintray.com/probono/AppImages/'"+appName)193 try:194 with urllib.request.urlopen('https://bintray.com/probono/AppImages/'+appName) as f:195 content=(f.read().decode('utf-8'))196 soup=BeautifulSoup(content,"html.parser")197 descDiv=soup.findAll('div', attrs={ "class" : "description-text"})198 if len(descDiv)>0:199 desc=descDiv[0].text200 desc=desc.replace(':','.')201 desc=desc.replace('&','&')202 except:203 pass204 return(desc)205 206 def _th_generate_xml_catalog(self,applist,outdir):207 oldName=''208 oldDesc=''209 maxconnections = 10210 semaphore = threading.BoundedSemaphore(value=maxconnections)211 randomList = list(applist)212 random.shuffle(randomList)213 lenAppList=len(randomList)214 self.progress=25215 for app in randomList:216 th=threading.Thread(target=self._th_write_xml, args = (app,outdir,semaphore))217 th.start()218 self._callback(1,len(randomList))219 while (len(threading.enumerate())>3):220 self._callback()221 time.sleep(0.5)222 223 def _th_write_xml(self,app,outdir,semaphore):224 semaphore.acquire()225 lock=threading.Lock()226 self._debug("Generating "+app+" xml")227 nameSplitted=app.split('-')228 name=nameSplitted[0]229 version=nameSplitted[1]230 arch=nameSplitted[2]231 f=open(outdir+'/'+name+"_"+version+".appdata.xml",'w')232 f.write('<?xml version="1.0" encoding="UTF-8"?>'+"\n")233 f.write("<components version=\"0.10\">\n")234 f.write("<component type=\"desktop-application\">\n")235 f.write(" <id>"+app.lower()+"</id>\n")236 f.write(" <pkgname>"+app+"</pkgname>\n")237 f.write(" <name>"+name+"</name>\n")238 f.write(" <summary>"+name+" AppImage Bundle</summary>\n")239 f.write(" <metadata_license>CC0-1.0</metadata_license>\n")240 f.write(" <provides><binary>"+app+"</binary></provides>\n")241 f.write(" <releases>\n")242 f.write(" <release version=\""+version+"\" timestamp=\"1408573857\"></release>\n")243 f.write(" </releases>\n")244 f.write(" <launchable type=\"desktop-id\">"+name+".desktop</launchable>\n")245 with lock:246 if name in self.descDict.keys():247 description=self.descDict[name]248 else:249 description=self._get_description(name)250 self.descDict.update({name:description})251 f.write(" <description><p>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.</p><p>"+description+"</p></description>\n")252 f.write(" <bundle type=\"appimage\">"+app+"</bundle>\n")253 f.write(" <keywords>\n")254 f.write(" <keyword>"+name+"</keyword>\n")255 f.write(" <keyword>appimage</keyword>\n")256 f.write(" </keywords>\n")257 f.write(" <categories>\n")258 f.write(" <category>AppImage</category>\n")259 f.write(" <category>GTK</category>\n")260 f.write(" </categories>\n")261 f.write("<icon type=\"cached\">"+name+"_"+name+".png</icon>\n")262 f.write("</component>\n")263 f.write("</components>\n")264 f.close()265 semaphore.release()
Note: See TracChangeset
for help on using the changeset viewer.