Changeset 8182
- Timestamp:
- Oct 23, 2018, 2:24:29 PM (2 years ago)
- Location:
- lliurex-store/trunk/fuentes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/lliurex-store-cli/usr/share/lliurex-store/lliurex-store-cli.py
r7471 r8182 1 1 #!/usr/bin/python3 2 import sys 2 import sys,os,signal 3 3 import argparse 4 4 #sys.path.append('/usr/share/lliurex-store') … … 8 8 import html2text 9 9 import gettext 10 import threading 10 11 gettext.textdomain('python3-lliurex-store') 11 12 _=gettext.gettext … … 23 24 END = '\033[0m' 24 25 26 def signal_handler(*args): 27 if args[0]==17: 28 return 29 os.system('setterm -cursor on') 30 sys.exit(0) 31 32 25 33 def main(): 26 34 def print_results(action=None): … … 28 36 results=store.get_result(action) 29 37 status=store.get_status(action) 30 print("ST: %s"%status)31 38 if not 'status' in status.keys(): 32 39 status['status']=1 … … 72 79 elif action=='search': 73 80 #Only print name and summary 81 data_id='' 74 82 printcolor=color.DARKCYAN 75 data_id='' 76 if data['bundle']!='': 83 if data['bundle']: 77 84 printcolor=color.PURPLE 78 85 elif (data['package'] not in data['id'] or data['package'] in processed): … … 98 105 pass 99 106 elif action=='install': 100 print( data['package']+" "+ _(u"installed")+" "+color.BOLD+ _(u"succesfully")+color.END)107 print(color.DARKCYAN+data['package']+color.END+" "+ _(u"installed")+" "+color.BOLD+ _(u"succesfully")+color.END) 101 108 elif action=='remove': 102 print( data['package']+" "+ _(u"removed")+" "+color.BOLD+ _(u"succesfully")+color.END)109 print(color.DARKCYAN+data['package']+color.END+" "+ _(u"removed")+" "+color.BOLD+ _(u"succesfully")+color.END) 103 110 else: 104 111 print("RESULT:\n%s"%data) … … 145 152 # actions.append('random') 146 153 # parms['random']=args.random 147 #if args.list:148 #actions.append('list')149 #parms['list']=args.list154 if args.list: 155 actions.append('list') 156 parms['list']=args.list 150 157 151 158 actionList={'search':False,'info':False,'pkgInfo':False,'install':False,'remove':False,'list':False,'list-sections':False,'random':False} … … 153 160 store=storeManager.StoreManager(appimage=appimage,snap=snap,dbg=dbg,cli=True) 154 161 for action in actions: 155 store.execute_action(action,parms[action]) 162 th=threading.Thread(target=store.execute_action, args = (action,parms[action])) 163 th.start() 156 164 actionList[action]=False 157 165 166 inc=0 167 banner=' '.join(actions) 168 banner='LliureX Store' 169 numchar=len(banner) 170 os.system('setterm -cursor off') 158 171 while store.is_action_running(): 159 progressDic=store.get_progress() 160 progressArray=[] 161 for progress in progressDic: 162 if progress!='load': 163 progressArray.append(_(progress)+': '+str(int(progressDic[progress]))+'%') 164 print(','.join(progressArray),end="\r") 165 time.sleep(0.1) 166 for key in actionList: 167 progressDic=store.get_progress(key) 168 if key in progressDic: 172 ini=banner[0:numchar] 173 end=banner[numchar:inc] 174 text=ini+' '+end 175 print(text+' ',end='\r') 176 numchar-=1 177 inc+=1 178 time.sleep(0.2) 179 if numchar<0: 180 numchar=len(banner) 181 inc=0 182 print("") 183 print (CURSOR_UP + ERASE_LINE) 184 for key in actionList: 185 progressDic=store.get_progress(key) 186 if key in progressDic: 169 187 if progressDic[key]==100 and not actionList[key]: 170 progressDic=store.get_progress(key)171 progressArray=[]172 for progress in progressDic:173 if progress!='load':174 progressArray.append(_(progress)+': '+str(progressDic[progress])+'%')175 print(','.join(progressArray))176 print (CURSOR_UP + ERASE_LINE)177 188 actionList[key]=print_results(key) 178 # print_results('random') 189 print_results() 190 os.system('setterm -cursor on') 179 191 180 192 def process_Args(args): … … 188 200 parser.add_argument('--appimage',action='store_true',help=(_(u"Load appimage catalog"))) 189 201 parser.add_argument('--snap',action='store_true',help=(_(u"Load snap catalog"))) 190 #parser.add_argument('--list',metavar='list',nargs='?',help=(_(u"List category")))202 parser.add_argument('--list',metavar='list',nargs='?',help=(_(u"List category"))) 191 203 192 204 args=parser.parse_args() 193 205 return args 194 206 207 #Cause the cli hides the cursor we must assure that the cursor is showing when the program ends 208 sigs=set(signal.Signals) - {signal.SIGKILL, signal.SIGSTOP} 209 for sig in sigs: 210 signal.signal(sig,signal_handler) 195 211 main() -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/searchManager.py
r8139 r8182 130 130 categories_set=set(tokens) 131 131 apps_in_store=self.store.get_apps() 132 if max_results:133 apps_in_store=apps_in_store[0:max_results]134 132 count_apps=len(apps_in_store) 135 133 self.progress=0 … … 146 144 self._debug("Found "+app.get_id()) 147 145 applist.append(app) 146 if max_results and len(applist)==max_results: 147 break 148 148 else: 149 149 self._debug("Loading all apps in store") … … 165 165 # for app in applist: 166 166 # self._debug("Added "+app.get_id()) 167 #if max_results:168 #applist=applist[0:max_results]167 if max_results: 168 applist=applist[0:max_results] 169 169 #List only valid categories 170 170 -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/storeManager.py
r8084 r8182 227 227 exe_function=eval(self.plugins_registered[action][package_type]+"("+','.join(args)+")") 228 228 if self._propagate_dbg: 229 exe_function.set_debug( )229 exe_function.set_debug(self.dbg) 230 230 if self.plugins_registered[action][package_type] in self.cli_mode: 231 231 exe_function.cli_mode=True
Note: See TracChangeset
for help on using the changeset viewer.