Exemple #1
0
 def run(self):
  dirs_scanned=0; files_scanned=0; total_dirs=1
  appuifw.app.body=self.canvas
  appuifw.app.exit_key_handler=self.exit

  while len(self.dir_list):
   folder_files_scanned=0
   dir_index=0; cur_dir=self.dir_list[0]
   dir_contents=map(lambda x: self.dir_list[0]+'\\'+x, os.listdir(cur_dir))
   for i in range(len(dir_contents)):
    cur_path=dir_contents[i]
    self.img.clear()
    self.img.text((5,15),u'Dirs: %d / %d'%(dirs_scanned, total_dirs))
    self.img.text((5,28),u'Files in dir: %d / %d'%(folder_files_scanned, len(dir_contents)))
    self.img.text((5,75),u'Text: %d'%len(self.lists.txt))
    self.img.text((5,88),u'Software: %d'%len(self.lists.software))
    try:
     self.img.text((5,45),unicode(self.dir_list[0]), 0, u'LatinPlain12')
     self.img.text((5,58),unicode(cur_path[cur_path.rfind('\\')+1:]), 0, u'LatinPlain12')
    except UnicodeError:
     self.img.text((5,45),appstdio.nice_unicode(self.dir_list[0]), 0, u'LatinPlain12')
     self.img.text((5,58),appstdio.nice_unicode(cur_path[cur_path.rfind('\\')+1:]), 0, u'LatinPlain12')
    self.canvas.blit(self.img)

    if os.path.isdir(cur_path):
     if dir_index==-1: self.dir_list=[cur_path]+self.dir_list
     else: self.dir_list+=[cur_path]
     total_dirs+=1

    if self.filters.text(cur_path):
     self.lists.txt+=[1]#[cur_path]
     self.img.text((90,75),u'Detected')
    if self.filters.software(cur_path)==2:
     self.img.text((90,88),u'MemoryError',0xf00000)
    elif self.filters.software(cur_path):
     self.lists.software+=[0]#[cur_path]
     #try: os.rename(cur_path, r'E:\Restore\Unknown' + cur_path[cur_path.rfind('\\'):])
     try: appuifw.Content_handler().open_standalone(cur_path); appuifw.selection_list([])
     except OSError:
      if not appuifw.query(u'OSError','query'): self.exit()
     self.img.text((90,88),u'Detected')

    self.canvas.blit(self.img)
    self.files_log.write(cur_path+'\n')
    files_scanned+=1
    folder_files_scanned+=1
    e32.ao_sleep(0)
    if not self.running: break
   dirs_scanned+=1
   self.dirs_log.write(self.dir_list[0]+'\n')
   del self.dir_list[self.dir_list.index(cur_dir)]
   if not self.running: break
  while self.running:
   self.img.text((90,135),u'Done',0x008000, u'Alb17')
   self.canvas.blit(self.img)
   e32.ao_sleep(0)
Exemple #2
0
    def refresh(self, refresh_files=1, refresh_ui=1, dir_changed=1, set_list=1):
        global focused_item
        if not dir_changed: focused_item=self.lb.current()
        try: focused_item
        except NameError: focused_item=0
        if not refresh_files:
          try: self.last_dir
          except AttributeError: refresh_files=2
        if refresh_files: self.loading(); self.entries = self.last_dir = self.current_dir.list_repr()
        if refresh_ui:
          appuifw.app.body=self.lb
          if self.screenmode:
           if self.listmode=='compact': appuifw.app.screen='full'
           if self.listmode=='full': appuifw.app.screen='large'
          else: appuifw.app.screen='normal'
          menu=[[unicode(x), []] for x in ('File', 'Go', 'Edit', 'View', 'Settings')]
          if self.current_dir.len: menu[1][1]+=[(u'Go to item...',self.surface_find)]
          menu[1][1]+=[(u'Refresh',lambda: self.refresh(dir_changed=0))]
          if self.current_dir.len:
           menu[0][1]+=[(u'Open / Select action',self.lbox_observe)]
           if not self.current_dir.at_root: menu[0][1]+=[(u'Delete',self.delete)]
          menu[3][1]+=[
            (u'Screen mode: '+appuifw.app.screen, self.toggle_screenmode),
            (u'List mode: '+self.listmode, self.toggle_listmode)]
          menu+=[
           (u'About', lambda: appuifw.note(u'Python')),
           (u'Exit', appuifw.app.set_exit)]
          for i in range(len(menu)):
           while len(menu)>i:
            if menu[i][1]==[]: del menu[i]
            elif type(menu[i][1])==list:
             menu[i][1]=tuple(menu[i][1]); menu[i]=tuple(menu[i])
             if len(menu[i][1])==1: menu[i]=menu[i][1][0]
             break
            else: break
          appuifw.app.menu=menu
          self.lb.bind(EKeyRightArrow, lambda: self.lbox_observe(pass_files=1)); self.lb.bind(EKeyLeftArrow, lambda: self.lbox_observe(-1))
          self.lb.bind(EKeyBackspace, self.delete)
          self.lb.bind(EKeyUpArrow, lambda: self.chg_pos(wrap='up'))
          self.lb.bind(EKeyDownArrow, lambda: self.chg_pos(wrap='down'))
          self.lb.bind(EKey3, lambda: self.chg_pos(-self.listmode_num)); self.lb.bind(EKey9, lambda: self.chg_pos(self.listmode_num))
          self.lb.bind(EKey5, lambda: self.chg_pos(-1, 1)); self.lb.bind(EKey6, lambda: self.chg_pos(0, len(self.entries)))
        if self.current_dir.len==0:
          if self.listmode=='compact': self.last_dir=[(u"Empty Folder",)]
          elif self.listmode=='full': self.last_dir=[(u"", u"Empty Folder")]

        if self.current_dir.at_root: appuifw.app.title=u'File Browser'
        else:
         current_dir=self.current_dir.name()
         if current_dir[-1]=='\\': current_dir=current_dir[:-1]
         appuifw.app.title=appstdio.nice_unicode(current_dir.split('\\')[-1])
        if self.listmode=='compact': self.entries = map(lambda x: x[0], self.last_dir)
        elif self.listmode=='full': self.entries = self.last_dir
        if set_list: self.lb.set_list(self.entries, focused_item)
Exemple #3
0
 def item_format(i):
     full_name = os.path.join(str(self.name()), i)
     try: time_field = time.strftime("%m/%d/%Y %H:%M",\
                    time.localtime(os.stat(full_name).st_mtime))
     except: time_field = "--/--/---- --:--"
     if os.path.isdir(full_name):
         name_field = i+"\\"
         size, size_unit= 'Folder',''
     else:
       name_field = i
       try: size = os.stat(full_name).st_size; size_unit='b'
       except: size = '?'; size_unit='b'
       else:
         if size>=1200000000: size = round(float(os.stat(full_name).st_size)/1000000000, 1); size_unit='GB'
         elif size>=1200000: size = round(float(os.stat(full_name).st_size)/1000000, 1); size_unit='MB'
         elif size>=1200: size = round(float(os.stat(full_name).st_size)/1000, 1); size_unit='kb'
     info_field = time_field+"   "+str(size)+' '+size_unit
     try: name_field=unicode(name_field)
     except UnicodeError: name_field=appstdio.nice_unicode(name_field)
     except: import traceback; traceback.print_exc()#name_field=u" ??? "
     return name_field, unicode(info_field)