Ejemplo n.º 1
0
 def fill_items(self):
     if self.cur_dir == u"":
         self.items = [ unicode(d + "\\") for d in e32.drive_list() ]
         self.images = [None for d in self.items]
     else:
         entries = [ e.decode('utf-8')
                     for e in os.listdir( self.cur_dir.encode('utf-8') ) ]
         entries.sort()
         d = self.cur_dir
         dirs = []
         files = []
         dimages = []
         fimages = []
         for e in entries:
             f = os.path.join(d,e)
             if os.path.isdir(f.encode('utf-8')):
                 dirs.append(e.upper())
                 dimages.append(None)
             elif os.path.isfile(f.encode('utf-8')):
                 desc = e.lower() + "\n"
                 desc += "%d bytes" % os.path.getsize(f)
                 files.append(desc)
                 if f.endswith(".jpg") or f.endswith(".png") or f.endswith(".gif"):
                     fimages.append(f)
                 else:
                     fimages.append(None)
         dirs.insert(0, u".." )
         dimages.insert(0,None)
         self.items = dirs + files
         self.images = dimages + fimages       
Ejemplo n.º 2
0
def python_drive():
    if e32.s60_version_info >= (3, 0):
        return "C:"
    for drive in [str(x) for x in e32.drive_list()]:
        if os.path.isfile(os.path.join(drive, PYTHON_PATH, 'python.app')):
            return drive
    raise AssertionError, "Python not found"
Ejemplo n.º 3
0
    def show(self, filters=None):
        filelist = e32.drive_list()
        while (1):
            ll = []
            for file in filelist:
                if (filters != None):
                    if isfile(self.current_path + "\\" + file):
                        matched = 0
                        filext = splitext(file)[1]
                        for filter in filters:
                            if (filext == filter):
                                matched = 1
                                break
                        if (matched == 0): continue
                ll.append(unicode(file))

            ind = selection_list(ll)

            if ind is not None:
                if (self.current_path == "<root>"):
                    self.current_path = ll[ind]
                    filelist = os.listdir(self.current_path)
                    continue
                if not isfile(self.current_path + "\\" + ll[ind]):
                    self.current_path = self.current_path + "\\" + ll[ind]
                    filelist = os.listdir(self.current_path)
                    continue
                return self.current_path + "\\" + ll[ind]
            else:
                self.current_path = "<root>"
                return None
Ejemplo n.º 4
0
 def show(self, filters=None):
     filelist = e32.drive_list()
     while (1):
        ll = []
        for file in filelist:
           if (filters != None):
              if isfile(self.current_path + "\\" + file):
                 matched = 0; filext = splitext(file)[1]
                 for filter in filters:
                     if (filext == filter):
                        matched = 1; break
                 if (matched == 0): continue
           ll.append(unicode(file))
             
        ind = selection_list(ll)
         
        if ind is not None:
          if (self.current_path == "<root>"):
              self.current_path = ll[ind]
              filelist = os.listdir(self.current_path)
              continue
          if not isfile(self.current_path + "\\" + ll[ind]):
              self.current_path = self.current_path + "\\" + ll[ind]
              filelist = os.listdir(self.current_path)
              continue
          return self.current_path + "\\" + ll[ind]
        else:
          self.current_path = "<root>"
          return None
Ejemplo n.º 5
0
def get_path(app_name):
	drives_list = e32.drive_list()

	#Gives preference to load from drive 'E:'
	drives_list.reverse()
	for drive in [str(x) for x in drives_list]:
        	if os.path.isdir(os.path.join(drive, app_name)):
	        	return os.path.join(drive, app_name)
 def listdir(self, dirpath):
     if dirpath == "<root>":
         return e32.drive_list()
     else:
         dir = os.listdir(dirpath)
         dir = self.sortdir(dir, dirpath)
         if dir == []:
             dir = [u"<empty>"]
         return dir
Ejemplo n.º 7
0
 def update(self, syncHistory = True):
   p = os.path.abspath(".")
   if not p in e32.drive_list():
     p = os.path.basename(p)
   txt = "[%s %s]$ " % ("user@pys60", p)
   self.toEnd()
   self.add(txt)
   
   self.setPosToEnd(syncHistory)    
Ejemplo n.º 8
0
def select(type="file",initdir="\\",drive="",**options):
  def opt(k):
   if k in options:return options[k]
  initdir=drive+initdir
  path= os.path.normpath(initdir)
  drive,path=os.path.splitdrive(path)
  if not drive or initdir==drive+"\\..\\" and not opt("limitdrive"):
   drvs=e32.drive_list()
   ind=appuifw.popup_menu(drvs,u"Select Drive")
   if not ind==None:drive=drvs[ind]
   else:return None
  if not path[0:1]=="\\":path="\\"+path
  initdir=drive+path
  dirs=[]
  files=[]
  if not initdir[-1:]=="\\":initdir+="\\"
  dirsonly=type=="dir"
  for f in os.listdir(initdir):
   f=f.decode('utf8')
   statistics=os.stat(unicode(initdir+f).encode('utf8'))
   if S_ISDIR(statistics[0]):
    dirs.append([f.lower(),f])
   else:
    files.append([f.lower(),f])
  dirs.sort()
  files.sort()
  realdirs=[]
  if dirsonly:realdirs.append(u"[This Directory]")
  realdirs.append(u"[d] ..")
  for dir in dirs:realdirs.append(unicode("[d] "+dir[1]))
  if not dirsonly:
   realfiles=[]
   for file in files:
    allowed=True
    if opt("extblacklist"):
     for black in opt("extblacklist"):
      if os.path.splitext(file[1])[1][1:]==black:allowed=False
    if opt("extwhitelist"):
     allowed=False
     for white in opt("extwhitelist"):
      if os.path.splitext(file[1])[1][1:]==white:allowed=True
    if allowed:realfiles.append(unicode("[f] "+file[1]))
   realdirs.extend(realfiles)
  if dirsonly:title="Folder"
  else:title="File"
  ind=appuifw.popup_menu(realdirs,u'Select '+title)
  if not ind and ind is not 0:return None
  selected=realdirs[ind]
  if selected[:3]=="[d]":
   if dirsonly and selected[4:]=="[This Directory]":
    return initdir+selected[4:]
   else:
    return select(type,initdir+selected[4:]+"\\",'',**options)
  elif selected==u"[This Directory]":
   return  initdir
  else:
   return initdir+selected[4:]
Ejemplo n.º 9
0
    def generateDriveList(self):

        self.available_drives = []

        for drive in e32.drive_list():
            try:
                os.listdir(drive + "\\")
                self.available_drives.append(u"%s\\" % drive)
            except:
                pass
Ejemplo n.º 10
0
 def generateDriveList(self):
   
   self.available_drives = []
   
   for drive in e32.drive_list():
     try:
       os.listdir(drive + "\\")
       self.available_drives.append(u"%s\\" % drive)
     except:
       pass
Ejemplo n.º 11
0
def root():
    ui.app.title=u'File Manager'
    try:
        drivelist=e32.drive_list()
        #drivelist=[u'C:', u'D:', u'E:', u'Z:']
        index=ui.selection_list(drivelist)
        opn(drivelist[index])
    except:
        a=ui.query(u'sure to quit?', 'query')
        if not a:
            root()
Ejemplo n.º 12
0
 def _drive_list(self):
     itpares = [[x, self._in] for x in drive_list()]
     drlist = Ttextlist((1, self.list_y), self.buff, itpares, self.font_bold, self.multi)
     drlist.key['select2'] = None
     drlist.size((display_pixels()[0], 100))
     drlist.clrs = self.itemcolors
     drlist.cycled = self.cycled
     drlist.sp_bl = self.btwlinespace
     drlist._updateheight(True)
     if drlist.scroll is not None : 
         drlist.scroll.clr = self.scrollbarcolors
     return drlist
Ejemplo n.º 13
0
 def handle(self):
  c=app.body.current()
  if c==0:self.conscr()
  elif c==1:
   self.exit(self.mainscr)
   self.interface=[]
   sys_drives=['C:','D:','Z:']
   for d in e32.drive_list():
    if d in sys_drives:icon=ui.Icon(u(self.db.get('icons')), 397, 398)
    else:icon=ui.Icon(u(self.db.get('icons')), 395, 396)
    self.interface.append((u(d),icon))
   app.body=self.disp(self.file)
  elif c==2:self.settings()
  elif c==3:self.setup()
  else:pass
Ejemplo n.º 14
0
def scan(path):
  if path=='':
    return e32.drive_list()
  if os.path.isdir(path)==0 and os.path.isfile(path)==0:
    return [u'<<<']
  _files=[]
  files=[u"<<<"]
  for _file in os.listdir(path):
    if os.path.isfile(path+_file)==0:
      _file+="\\"
      files.append(ru(_file))
    else:
      _files.append(ru(_file))
  files.extend(_files)
  return files
Ejemplo n.º 15
0
 def fill_items(self):
     if self.cur_dir == u"":
         self.items = [ unicode(d + "\\") for d in e32.drive_list() ]
     else:
         entries = [ e.decode('utf-8')
                     for e in os.listdir( self.cur_dir.encode('utf-8') ) ]
         d = self.cur_dir
         dirs  = [ e.upper() for e in entries
                   if os.path.isdir(os.path.join(d,e).encode('utf-8'))  ]
         
         files = [ e.lower() for e in entries
                   if os.path.isfile(os.path.join(d,e).encode('utf-8')) ]
         
         files = [ f for f in files
                   if re.match(self.mask,f) ]
         dirs.sort()
         files.sort()
         dirs.insert( 0, u".." )
         self.items = dirs + files
 def refresh(self):
     """
     Returns True if the list changed as a result of the refresh,
     and False otherwise.
     """
     dirty = False
     for drive in e32.drive_list():
         if not self.drivelist.has_key(drive):
             self.drivelist[drive] = DriveInfo(drive, self.mk_pic)
             dirty = True
     for di in self.drivelist.itervalues():
         if di.dirty:
             di.refresh()
             dirty = True
     if dirty:
         self.filelist = []
         for di in self.drivelist.itervalues():
             self.filelist.extend(di.filelist)
     return dirty
Ejemplo n.º 17
0
 def handle(self):
     c = app.body.current()
     if c == 0: self.conscr()
     elif c == 1:
         self.exit(self.mainscr)
         self.interface = []
         sys_drives = ['C:', 'D:', 'Z:']
         for d in e32.drive_list():
             if d in sys_drives:
                 icon = ui.Icon(u(self.db.get('icons')), 397, 398)
             else:
                 icon = ui.Icon(u(self.db.get('icons')), 395, 396)
             self.interface.append((u(d), icon))
         app.body = self.disp(self.file)
     elif c == 2:
         self.settings()
     elif c == 3:
         self.setup()
     else:
         pass
 def run(self):
     self.oldscreen = appuifw.app.screen
     appuifw.app.screen = self.screen
     if self.dirpath == "<root>":
         entries = e32.drive_list()
     else:
         entries = self.listdir(self.dirpath)
     if not self.dirpath == "<root>":
         entries.insert(0, u"..")
     self.entries = entries
     self.lb = appuifw.Listbox(entries, self.observe)
     self.lb.bind(EKeyLeftArrow, lambda: self.observe(-1))
     self.lb.bind(EKeyRightArrow, self.observe)
     self.lb.bind(EKeyYes, self.go)
     self.lb.bind(EKeyUpArrow, self.cycle)
     old_title = appuifw.app.title
     self.refresh()
     self.script_lock.wait()
     appuifw.app.title = old_title
     appuifw.app.body = None
     appuifw.app.screen = self.oldscreen
     self.lb = None
Ejemplo n.º 19
0
    def fill_items(self):
        if self.cur_dir == u"":
            self.items = [unicode(d + "\\") for d in e32.drive_list()]
        else:
            entries = [
                e.decode('utf-8')
                for e in os.listdir(self.cur_dir.encode('utf-8'))
            ]
            d = self.cur_dir
            dirs = [
                e.upper() for e in entries
                if os.path.isdir(os.path.join(d, e).encode('utf-8'))
            ]

            files = [
                e.lower() for e in entries
                if os.path.isfile(os.path.join(d, e).encode('utf-8'))
            ]

            files = [f for f in files if re.match(self.mask, f)]
            dirs.sort()
            files.sort()
            dirs.insert(0, u"..")
            self.items = dirs + files
Ejemplo n.º 20
0
 def __init__(self):
     self.script_lock = e32.Ao_lock()
     self.dir_stack = []
     self.current_dir = dir_iter.Directory_iter(e32.drive_list())
Ejemplo n.º 21
0
 def __init__(self):
     self.script_lock = e32.Ao_lock()
     self.dir_stack = []
     self.current_dir = dir_iter.Directory_iter(e32.drive_list())
     self.left_arrow_clicked = False
     self.selected = None
Ejemplo n.º 22
0
 def __init__(self):
     self.script_lock = e32.Ao_lock()
     self.dir_stack = []
     self.current_dir = dir_iter.Directory_iter(e32.drive_list())
Ejemplo n.º 23
0
 def python_drive(self):
     for drive in [str(x) for x in e32.drive_list()]:
         if os.path.isfile(os.path.join(drive, self.PYTHON_PATH, 'python.app')):
             return drive
     raise AssertionError, "Python not found"
Ejemplo n.º 24
0
 def update_entries(self):
     if self.path:
         self.entries = os.listdir(os.path.join(*self.path))
         self.entries.insert(0, u'..')
     else:
         self.entries = e32.drive_list()
Ejemplo n.º 25
0
 def _run(self, path=None, path_item=None):
     ui.app.focus = self.refresh
     self.CH = 0
     if path != None:
         path = unicode(os.path.normpath(path))
         if os.path.exists(path) or os.path.basename(path) == "(empty)":
             path = path
         else:
             ui.note(u"path does not exist", "error")
             return self._run()
     e32.ao_yield()
     self.all = []
     self.allist = []
     if path == None:
         running = 1
         while running:
             self.lb.set_list([(u"please wait...", self.wait_icon)])
             e32.ao_yield()
             self.allist += [(i, self.drive_icon) for i in e32.drive_list()]
             e32.ao_yield()
             self.all = self.allist
             if path_item != None:
                 try:
                     select = e32.drive_list().index(path_item)
                 except:
                     select = 0
             else:
                 select = 0
             running = 0
         return self.__execute(self.allist, select)
     elif os.path.isdir(path):
         running = 1
         while running:
             self.lb.set_list([(u"please wait...", self.wait_icon)])
             e32.ao_yield()
             a = os.listdir(path)
             b = []
             c = []
             for i in a:
                 d = path + os.sep + i
                 if os.path.isdir(d):
                     b.append((d, self.folder_icon))
                     e32.ao_yield()
                 else:
                     ext = os.path.splitext(d)[1][1:].lower()
                     if not self.exts or ext in self.exts:
                         c.append((d, self.file_icon))
                         e32.ao_yield()
             if self.type == "folder":
                 self.all = b
             else:
                 self.all = b + c
             if len(self.all) == 0:
                 self.all.append((path + "\\(empty)", self.empty_icon))
             self.allist = [(os.path.basename(k), v) for k, v in self.all]
             e32.ao_yield()
             al = [k for k, v in self.allist]
             if path_item != None:
                 try:
                     select = al.index(path_item)
                 except:
                     select = 0
             else:
                 select = 0
             running = 0
         return self.__execute(self.allist, select)
     elif os.path.isfile(path):
         self.CH = 1
         self.cur = path
         self.lock.signal()
         return
     else:
         if not os.path.exists(path):
             dir = os.path.dirname(path)
             if dir.endswith("\\"):
                 dir = dir[:-1]
             return self._run(dir, path_item)
Ejemplo n.º 26
0
sys.path.append("E:\\System\\Apps\\Python\\my\\")
sys.path.append("C:\\Python")
sys.path.append("E:\\Python")

sys.path.append("C:\\System\\Apps\\Python\\my\\")
from logger import Logger

# Series 60 specific imports
try:
    # On phone?
    import e32
    import e32db

    # @SEMI-HACK@
    # At the moment, set global variable that determines where our data is going to live
    availableDrives = e32.drive_list()
    # if 'E:' in availableDrives:
    #    dataPath = u'E:\\System\\Data\\FluidNexusData'
    # else:
    #    dataPath = u'C:\\System\\Data\\FluidNexusData'

    try:
        os.listdir("E:")
        dataPath = u"E:\\System\\Data\\FluidNexusData"
    except OSError:
        # there is no memory card
        dataPath = u"C:\\System\\Data\\FluidNexusData"

    # Setup our data path
    if not os.path.isdir(dataPath):
        os.makedirs(dataPath)
Ejemplo n.º 27
0
 def __init__(self, drive_list=None):
     self.drives=lambda: [((i, u"Drive")) for i in e32.drive_list()]
     self.at_root = 1
     self.len = len(self.drives())
     self.path = '\\'
Ejemplo n.º 28
0
def pseudo_osSystemCommand(cmd, args):
  global wantExit
  if pythonScripts:
    checkForExit()
  if cmd == "exit":
    if not pythonScripts:
      print "Bye!"
      exit(True)
  elif cmd == "help":
    styles = ((0x000000, 0xFFFFFF, True), (0xFFFFFF, 0x000000, True), (0xAA0000, 0xFFFFFF, True), (0x4444FF, 0xFFFFFF, True))
    terminalTools.print_special((("Welcome to the ", 0), ("Terminal", 1), (". [to view this text, use '", 0), ("help", 2), ("']", 0)), styles = styles)
    terminalTools.print_special("________________________", bold = True)
    terminalTools.print_special("This tend's to simulate an extremely basic Unix terminal and it is based on Python.", bold = True)
    terminalTools.print_special("Use UP/DOWN to look in history and use RIGHT on the end of the line for auto-complete.")
    terminalTools.print_special(getExecHelp(), styles = styles)
    terminalTools.print_special("Available drives on device: ", bold = True)
    for txt in e32.drive_list():
      terminalTools.print_special(((txt, 3),), styles = styles)
    print "\n"
  elif cmd == "testInput":
    print "You typed %s." % terminalTools.raw_input_special("lalaaalaa: ", color=0xFFFFFF, highlight_color=0x000000)
  elif cmd == "testKeys":
    terminalTools.keyGrabber.start()
    l = []
    while not "DOWN" in l:
      l = terminalTools.keyGrabber.get()
      for i in l:
        print i
    terminalTools.keyGrabber.stop()
  elif cmd == "clear":
    text.clear()
  elif cmd == "sleep":
    try:
      t = float(args[0][0])
    except ValueError:
      t = 1
    sleep(t)
  elif cmd == "echo":
    print " ".join(extractArgInfo(args))
  elif cmd == "cat":
    if os.path.exists(args[0][0]) and os.path.isfile(args[0][0]):
      if os.path.getsize(args[0][0]) < MAX_FILELENGTH:
        try:
          print open(args[0][0], 'rb').read()
        except IOError:
          print "File cannot be read."
      else:
        print "File is too big to show here."
        return 2
    else:
      print "%s: no such file." % args[0][0]
      return -1
  elif cmd == "cp":
    if not args[1][0]:
      print "No destination file specified, aborting."
      return -1
    destination = args[1][0]
    if os.path.isfile(args[0][0]) and os.path.isdir(destination):
      destination = os.path.join(destination, os.path.basename(os.path.abspath(args[0][0])))
    if copyFile(args[0][0], destination) == -1:
      print "Copy operation failed."
      return -1
  elif cmd == "mv":
    if not args[1][0]:
      print "No destination file specified, aborting."
      return -1
    destination = args[1][0]
    try:
      if os.path.isfile(args[0][0]) and os.path.isdir(destination):
        destination = os.path.join(destination, os.path.basename(os.path.abspath(args[0][0])))
      os.rename(args[0][0], destination)
    except:
      print "Move operation failed."
      return -1
  elif cmd == "rm":
    toReturn = 0
    for arg in extractArgInfo(args):
      if os.path.exists(arg) and os.path.isfile(arg):
        try:
          os.remove(arg)
        except:
          print "Permission denied."
      else:
        print "%s: no such file." % arg
        toReturn = -1
    return toReturn
  elif cmd == "rmdir":
    toReturn = 0
    for arg in extractArgInfo(args):
      if os.path.exists(arg) and os.path.isdir(arg):
        try:
          os.rmdir(arg)
        except:
          print "Permission denied."
      else:
        print "%s: no such directory." % arg
        toReturn = -1
    return toReturn
  elif cmd == "mkdir":
    toReturn = 0
    for arg in extractArgInfo(args):
      p = os.path.abspath(arg)
      if os.path.exists(os.path.dirname(p)):
        try:
          os.mkdir(p)
        except:
          print "Permission denied."
      else:
        print "%s: no such parent directory." % os.path.dirname(p)
        toReturn = -1
    return toReturn
  elif cmd == "cd":
    try:
        if args[0][0]:
            os.chdir(args[0][0])
        else:
            os.chdir(startPath)
    except:
        print "%s: no such directory." % args[0][0]
        return -1
  elif cmd == "ls":
    listAll = hasOption(args, "-a")
    if args[0][0]:
      if os.path.exists(args[0][0]):
        p = args[0][0]
      else:
        p = ""
    else:
      p = "."
    if p:
      if os.path.isfile(p):
        print "%s    %s bytes" % (os.path.basename(os.path.abspath(p)), os.path.getsize(p))
      else:
        l = sorted(map(str, os.listdir(p)), key = str.lower)
        if len(l) > MAX_FILELISTINGLENGTH and not listAll:
          print "Too much files to display, use option '-a'."
          return -1
        k = 0
        for ii in range(len(l)):
          if os.path.isdir(os.path.join(p, l[ii])):
            l.insert(k, l[ii])
            del l[ii+1]
            k += 1
        for j in range(len(l)):
          if j < k:
            terminalTools.print_special(l[j], color = 0x0000FF, bold = True)
          elif os.path.islink(os.path.join(p, l[j])):
            terminalTools.print_special(l[j], color = 0xFF00FF)
          else:
            print l[j]
    else:
      print "%s: no such file or directory." % args[0][0]
      return -1
  elif cmd == "pwd":
    print os.path.abspath('.')
  elif cmd == "python":
    if args[0][0]:
      if not os.path.exists(args[0][0]):
        print "%s: no such file." % args[0][0]
        return -1
      terminalTools.history.active = False
      prompt.history = terminalTools.history
      addNewPythonScript()
      toReturn = 0
      sys.path[0] = os.path.abspath('.')
      sys.argv = map(str, extractArgInfo(args))
      namespace = genNamespace()
      try:
        execfile(args[0][0], namespace)
      except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        if exc_type != SystemExit:
          import traceback
          print "Exception in script '%s' code:" % args[0][0]
          print '-'*36
          traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout)
          print '-'*36
        if exc_type in (KeyboardInterrupt, SystemExit) and wantExit and not exitAllPython:
          wantExit = False
        if exceptionCallback and exc_type != SystemExit:
          exceptionCallback(exc_type, exc_value, traceback.extract_tb(exc_traceback))
        toReturn = -1
      endLastPythonScript()
      return toReturn
    else:
      sys.path[0] = os.path.abspath('.')
      prompt.history = History()
      addNewPythonScript()
      namespace = genNamespace()
      inp = ""
      indent = False
      buffer = ""
      styles = ((0x000000, 0xFFFFFF, True), (0xFFFFFF, 0x000000, True), (0xAA0000, 0xFFFFFF, True))
      terminalTools.print_special((("Welcome to the ", 0), ("Interactive Python Shell", 1), ("!", 0)), styles = styles)
      while True:
        try:
          inp = raw_input((">>> ", "... ")[indent])
        except KeyboardInterrupt:
          print "KeyboardInterrupt"
          endLastPythonScript()
          if wantExit and not exitAllPython:
            wantExit = False
          print "Bye!"
          return -1
        if inp in ("quit()", "exit()"):
          break
        if inp:
          if inp[0] in (" ", "\t"):
            indent = True
          elif inp[-1] == ":":
            indent = True
          elif indent:
            print "Please end with a ENTER after an indentation-block."
            buffer = ""
            indent = False
        else:
          inp = buffer
          buffer = ""
          indent = False
        if indent:
          buffer += inp + "\n"
        elif inp:
          terminalTools.history.active = False
          prompt.history = terminalTools.history
          addNewPythonScript()
          exc_type = exc_value = exc_traceback = None
          extended_inp = "terminalTools.tmpValue = (%s)" % inp
          try:
            exec extended_inp in namespace
            if terminalTools.tmpValue != None:
              namespace['_'] = terminalTools.tmpValue
              print repr(namespace['_'])
          except SyntaxError:
            try:
              exec inp in namespace
            except:
              exc_type, exc_value, exc_traceback = sys.exc_info()
          except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
          if not exc_type == exc_value == exc_traceback == None:
            if exc_type != SystemExit:
              import traceback
              print "Exception in user code:"
              print '-'*36
              traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout)
              print '-'*36
            if exc_type in (KeyboardInterrupt, SystemExit) and wantExit and not exitAllPython:
              wantExit = False
          endLastPythonScript()
      endLastPythonScript()
      print "Bye!"
  elif cmd:
    try:
      toReturn = e32.start_exe(unicode(cmd), " ".join(extractArgInfo(args)), True)
      if toReturn == 2:
        print "Application terminated abnormally."
      return toReturn
    except:
      print "%s: command not found." % cmd
      return -1
    #return os.__system__(cmd)
  
  return 0  
Ejemplo n.º 29
0
 def test_drive_list(self):
     drive_list = e32.drive_list()
     self.failUnless(u'C:' in drive_list)
 def observe(self, ind=None):
     if (ind == -1) and (self.dirpath == "<root>"):
         return
     if not ind == None:
         index = ind
     else:
         index = self.lb.current()
     if self.dirpath != "<root>":
         dalist = self.unic(self.listdir(self.dirpath))
     focused_item = 0
     if self.dirpath == "<root>":
         self.dir_stack.append(index)
         self.dirpath = e32.drive_list()[index]
     elif index == -1:
         if self.dir_stack != []:
             if self.dirpath != "<root>":
                 focused_item = self.dir_stack.pop()
                 self.popdir()
                 self.backuplist = dalist
                 self.lb.set_list(self.backuplist)
     elif os.path.isdir(self.dirpath + "\\" +
                        self.backuplist[index].replace('> ', '')):
         self.dir_stack.append(index)
         self.dirpath += "\\" + self.backuplist[index].replace('> ', '')
     elif os.path.isfile(self.dirpath + "\\" + self.backuplist[index]):
         self.item = os.path.join(self.dirpath, self.backuplist[index])
         path = unicode(
             os.path.splitext(self.item)[0] +
             (os.path.splitext(self.item)[1]))
         if path.find("\\") == -1:
             path = path[:2] + u"\\" + path[2:]
         self.path = path
         self.debind()
         i = appuifw.popup_menu(
             [u"Edit (UTF-8)", u"Delete", u"New", u"Exit"])
         self.rebind()
         if i == 0:
             self.text = appuifw.Text()
             self.text.color = self.textcolor
             self.text.font = unicode(self.textfont)
             # appuifw.app.body = self.text
             appuifw.app.body.bind(EKeyYes, self.fonts)
             (encoding, decoding, reader, writer) = codecs.lookup('UTF-8')
             input = reader(open(path, 'rb'))
             self.filename = path.replace("/", "\\")
             try:
                 ex = False
                 s = input.read()
             except UnicodeError:
                 ex = True
                 appuifw.note(u'Failed to decode UTF-8', 'error')
             if not ex:
                 appuifw.app.body = self.text
                 appuifw.app.body.set(s)
                 appuifw.app.body.set_pos(0)
                 appuifw.app.menu = self.mainmenu
                 appuifw.app.exit_key_handler = self.filemenu
         elif i == 1:
             if appuifw.query(u"Really delete entry?", 'query'):
                 os.remove(self.item)
                 focused_item = index
             else:
                 pass
         elif i == 2:
             fn = appuifw.query(u"Filename:", 'text')
             if fn != None:
                 fn = (path[:path.rfind("\\")] + "\\" + fn).replace(
                     '/', '\\')
                 debug(fn)
                 self.text = appuifw.Text()
                 self.text.color = self.textcolor
                 self.text.font = self.textfont
                 appuifw.app.body = self.text
                 appuifw.app.body.color = self.textcolor
                 appuifw.app.body.bind(EKeyYes, self.fonts)
                 self.filename = fn
                 appuifw.app.body.set_pos(0)
                 appuifw.app.menu = self.mainmenu
         else:
             if not self.bound:
                 if appuifw.query(u"Really exit?", 'query'):
                     self.do_exit()
     if self.dirpath == "<root>":
         entries = e32.drive_list()
     else:
         entries = self.listdir(self.dirpath)
     entries = self.unic(entries)
     self.backuplist = entries
     self.lb.set_list(entries, focused_item)
     self.entries, self.cur = entries, self.lb.current() == 0
Ejemplo n.º 31
0
     fp.seek(0)
     resp = fp
 if cmd[:4] == 'RETR':
     try:
         resp = open(cmd[5:], 'r')
     except IOError, e:
         if e.errno == 13:
             raise error_perm, '550 No such file or directory.'
 if cmd[:4] == 'STOR': resp = open(self.wd + '/' + cmd[5:], 'w')
 if cmd[:4] == 'LIST':
     f = StringIO.StringIO()
     if len(cmd) < 6: dir = self.wd
     else: dir = self.drive + cmd[5:] + '\\'
     if dir: files = os.listdir(dir)
     else:
         files = e32.drive_list()
         self.wd = ""
     for file in files:
         st = os.stat(dir + file)
         d = '-'
         time = localtime(st.st_mtime)
         mon = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
                'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
         r = oct(S_IMODE(st[0]))
         if len(r) == 4: r = r[1:]
         if S_ISDIR(st[0]): p = 'd'
         else: p = '-'
         for i in range(len(r)):
             if r[i] == '0': p += '---'
             elif r[i] == '1': p += '--x'
             elif r[i] == '2': p += '-w-'
Ejemplo n.º 32
0
def back(path):
  if len(path)==3:return ''
  path=path.split('\\')[:-2]
  path= string.join(path,'\\')
  return path+'\\'
def exit():
 global run
 run=0
 app_lock.signal()
path=u''
run=1
app_lock = e32.Ao_lock()
lock=0
appuifw.app.exit_key_handler=exit
while run:
 files=scan(ur(path))
 if lock==0:
   appuifw.app.body=appuifw.Listbox(files,fopen)
 app_lock.wait()
 index=info()
 if len(path) == 0 :
    path=e32.drive_list()[index]+'\\'
    lock=0
 elif index==0 :
    path=back(ur(path))
    lock=0
 elif os.path.isfile(ur(path+files[index])):
    lock=1
 else:
    path+=files[index]
    lock=0
Ejemplo n.º 33
0
import os, sys, e32
import appuifw as ui

# from key_codes import *

LIBPATH = "\\system\\libs"
for i in e32.drive_list():
    if os.path.isfile(i + LIBPATH + "\\usefman.py"):
        LIBPATH = i + LIBPATH + "\\"
        break


class useFman:
    def __init__(self):
        self.LIBPATH = LIBPATH
        self.lock = e32.Ao_lock()
        self.drive_icon = ui.Icon(self.LIBPATH + u"myicons.mbm", 0, 1)
        self.folder_icon = ui.Icon(self.LIBPATH + u"myicons.mbm", 2, 3)
        self.wait_icon = ui.Icon(self.LIBPATH + u"myicons.mbm", 6, 7)
        self.empty_icon = ui.Icon(self.LIBPATH + u"myicons.mbm", 8, 9)
        self.file_icon = ui.Icon(self.LIBPATH + u"myicons.mbm", 36, 37)
        e32.ao_yield()
        entry = [(u"C:", self.drive_icon)]
        self.lb = ui.Listbox(entry, self.ret)
        self.old_body = ui.app.body
        self.old_menu = ui.app.menu
        self.old_exit = ui.app.exit_key_handler
        self.old_screen = ui.app.screen
        self.old_title = ui.app.title
        self.CH = -1
Ejemplo n.º 34
0
import e32
import sys
import os

# looking for install dir   
DEFDIR = u""
for d in e32.drive_list():
    appd = d + u"\\data\\python\\smsearch\\"
    if os.path.exists(appd + u"smsearch.py"):
        DEFDIR = appd
        break

if DEFDIR:
    sys.path.append(appd)
    from smsearch import SMSearch
    SMSearch().run()
Ejemplo n.º 35
0
 if cmd[:4]=='NLST':
  fp=StringIO.StringIO();s=''
  for l in os.listdir(cmd[5:]):s+=l+'\n'
  fp.write(s);fp.seek(0)
  resp= fp
 if cmd[:4]=='RETR':
  try:resp=open(cmd[5:], 'r')
  except IOError, e:
   if e.errno==13: raise error_perm, '550 No such file or directory.'
 if cmd[:4]=='STOR':resp=open(self.wd+'/'+cmd[5:], 'w')
 if cmd[:4]=='LIST':
  f=StringIO.StringIO()
  if len(cmd)<6:dir=self.wd
  else:dir=self.drive+cmd[5:]+'\\'
  if dir:files=os.listdir(dir)
  else:files=e32.drive_list();self.wd=""
  for file in files:
   st=os.stat(dir+file);d='-'
   time=localtime(st.st_mtime)
   mon=('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
   r=oct(S_IMODE(st[0]))
   if len(r)==4:r=r[1:]
   if S_ISDIR(st[0]):p='d'
   else:p='-'
   for i in range(len(r)):
    if r[i]=='0':p+='---'
    elif r[i]=='1': p+='--x'
    elif r[i]=='2': p+= '-w-'
    elif r[i]=='3': p+='-wx'
    elif r[i]=='4': p+='r--'
    elif r[i]=='5': p+='r-x'
Ejemplo n.º 36
0
 
sys.stdout.write("OS version:\n")
print(sysinfo.os_version())

sys.stdout.write("Free/total RAM (MB): %.2f / %.2f\n" % (sysinfo.free_ram()/1024/1024,sysinfo.total_ram()/1024/1024))
 
sys.stdout.write("Total ROM (MB): %.2f \n" % (sysinfo.total_rom()/1024/1024))
 
sys.stdout.write("Free disk space C/E (MB): %.2f / %.2f\n" % (sysinfo.free_drivespace()['C:']/1024/1024,sysinfo.free_drivespace()['E:']/1024/1024))

sys.stdout.write("Python version: %s (%s, %s)\n" % (e32.pys60_version,e32.pys60_version_info[0],e32.pys60_version_info[1]))
 
sys.stdout.write("Symbian version: (%s, %s)\n" % (e32.s60_version_info[0],e32.s60_version_info[1]))
 
sys.stdout.write("Available drives: \n")
print(e32.drive_list())
 
sys.stdout.write("Inactivity time: %s\n" % e32.inactivity())
 
sys.stdout.write("Platf. sec. capabilities: \n")
print(e32.get_capabilities())

sys.stdout.write("Check WriteUserData: %s\n" % e32.has_capabilities(['WriteUserData']))
 
sys.stdout.write("Check WriteUserData and ReadUserData: "+str(e32.has_capabilities(['WriteUserData','ReadUserData']))+"\n")
 
sys.stdout.write("Check if UI thread: %s\n" % e32.is_ui_thread())
 
sys.stdout.write("Check if in emulator: %s\n" % e32.in_emulator())

sys.stdout.write("Current time: %s\n" % time.strftime("%a, %d %b %Y, %H:%M:%S", time.localtime()))
Ejemplo n.º 37
0
 def __init__(self):
     self.entries = e32.drive_list()
     self.path = []