×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    69

    error when browsing files

    Hello,
    I have the following code:
    Code:
    import os
    import appuifw
    import e32
    import dir_iter
    import appuifw
    from audio import*
    import sys
    
    
    def browse():
        appuifw.app.browse_files(__init__)
    	
    def exit():
        exit = appuifw.query(u"You want to exit?", "query")
        if exit:
            sys.exit(0)
        else:
            pass
    		
    		
    global song
    def play():
        global song
        s = appuifw.query(broswe)
        song = Sound.open(s)
        song.play()
    
    def pause():
        global song
        song.stop()
    
    def stop():
        global song
        Sound.close(song)
    
        def __init__(self):
            self.script_lock = e32.Ao_lock()
            self.dir_stack = []
            self.current_dir = dir_iter.Directory_iter(e32.drive_list())
    
        def run(self):
            from key_codes import EKeyLeftArrow
            entries = self.current_dir.list_repr()
            if not self.current_dir.at_root:
                entries.insert(0, (u"..", u""))
            self.lb = appuifw.Listbox(entries, self.lbox_observe)
            self.lb.bind(EKeyLeftArrow, lambda: self.lbox_observe(0))
            old_title = appuifw.app.title
            self.refresh()
            self.script_lock.wait()
            appuifw.app.title = old_title
            appuifw.app.body = None
            self.lb = None
    
        def refresh(self):
            appuifw.app.title = u"File browser"
            appuifw.app.menu = []
            appuifw.app.exit_key_handler = self.exit_key_handler
            appuifw.app.body = self.lb
    
        def do_exit(self):
            self.exit_key_handler()
    
        def exit_key_handler(self):
            appuifw.app.exit_key_handler = None
            self.script_lock.signal()
    
        def lbox_observe(self, ind = None):
            if not ind == None:
                index = ind
            else:
                index = self.lb.current()
            focused_item = 0
    
            if self.current_dir.at_root:
                self.dir_stack.append(index)
                self.current_dir.add(index)
            elif index == 0:                              
                focused_item = self.dir_stack.pop()
                self.current_dir.pop()
            elif os.path.isdir(self.current_dir.entry(index-1)):
                self.dir_stack.append(index)
                self.current_dir.add(index-1)
            else:
                item = self.current_dir.entry(index-1)
                if os.path.splitext(item)[1] == '.mp3':
                    i = appuifw.popup_menu([u"execfile()", u"Delete"])
                else:
                    i = appuifw.popup_menu([u"Open", u"Delete"])
                if i == 0:
                    if os.path.splitext(item)[1].lower() == u'.mp3':
                        execfile(item, globals())
                        self.refresh()
                       
                    else:
                        try:
                            appuifw.Content_handler().open(item)
                        except:
                            import sys
                            type, value = sys.exc_info() [:2]
                            appuifw.note(unicode(str(type)+'\n'+str(value)), "info")
                    return
                elif i == 1:
                    os.remove(item)
                    focused_item = index - 1
    
            entries = self.current_dir.list_repr()
            if not self.current_dir.at_root:
                entries.insert(0, (u"..", u""))
            self.lb.set_list(entries, focused_item)
    
    if __name__ == '__main__':
    
        appuifw.app.menu = [(u"Browse", browse), (u"Play", play), (u"Pause", pause), (u"Stop", stop), (u"Exit", exit)]
        appuifw.app.exit_key_handler = exit
        appuifw.app.title = u"Vnixe Player"
        app_lock = e32.Ao_lock()
        app_lock.wait()
        Filebrowser().run()
    It should serve me to build multimedia app.
    When I try to activate the option to study - I get the following error:
    Python:
    System error(-50)

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: error when browsing files

    And where exactly does it say that appuifw.app has a browse_files method?

  3. #3
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    69

    Re: error when browsing files

    Quote Originally Posted by bogdan.galiceanu View Post
    And where exactly does it say that appuifw.app has a browse_files method?
    My wrong :S
    Any idea what can be put in place?

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: error when browsing files

    Quote Originally Posted by XxXYonIXxX View Post
    Any idea what can be put in place?
    Well, what do you want it to do?
    If you want to search for files, this thread has examples for various kinds of searches. If you want to display files, take out the search part from those examples and leave the part that displays the files.

  5. #5
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    69

    Re: error when browsing files

    Quote Originally Posted by bogdan.galiceanu View Post
    Well, what do you want it to do?
    If you want to search for files, this thread has examples for various kinds of searches. If you want to display files, take out the search part from those examples and leave the part that displays the files.

    I did not mean for search data, but i mean to browse in files.

    What I want to make this media player.
    So who could run the files in the MP3, WMA, etc.
    I want to make the option to browse in files on drives in the device

  6. #6
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: error when browsing files

    Then like I said, try to modify the examples in that thread to display the files in the device's drives. There is a wiki article that gives examples for using basic functions like displaying all the files in a folder and all the files that have a certain extension. Maybe that will help you

  7. #7
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    69

    Re: error when browsing files

    Quote Originally Posted by bogdan.galiceanu View Post
    Then like I said, try to modify the examples in that thread to display the files in the device's drives. There is a wiki article that gives examples for using basic functions like displaying all the files in a folder and all the files that have a certain extension. Maybe that will help you

    Thank you for bringing me information.
    But already created code. I just need to correct the error that appears when you browse in files.
    And he will join with the correct codes of the music player wrote.

  8. #8
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: error when browsing files

    Hi,
    can you please tell us what errors exactly you are getting?
    Jajal Mehul

  9. #9
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    69

    Re: error when browsing files

    Quote Originally Posted by james1980 View Post
    Hi,
    can you please tell us what errors exactly you are getting?
    look on this qoute:

    It should serve me to build multimedia app.
    When I try to activate the option to study - I get the following error:
    Quote:
    Python:
    System error(-50)

  10. #10
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: error when browsing files

    Quote Originally Posted by XxXYonIXxX View Post
    look on this qoute:
    It should serve me to build multimedia app.
    When I try to activate the option to study - I get the following error:
    Quote:
    Python:
    System error(-50)
    You were getting that for reasons explained by Python. Python tells you what kind of error it is and even the line of code that causes it. All you have to do is read the error description carefully and I'm sure you'll be able to solve it.

  11. #11
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    69

    Re: error when browsing files

    Quote Originally Posted by bogdan.galiceanu View Post
    You were getting that for reasons explained by Python. Python tells you what kind of error it is and even the line of code that causes it. All you have to do is read the error description carefully and I'm sure you'll be able to solve it.
    The error is not specified on line (50).
    And I did not know where the registered type of error.

  12. #12
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: error when browsing files

    OK, so the first error is in "Browse", for that appuifw.app.browse_files() thing: AttributeError: browse_files. This means that appuifw.app has no attribute named browse_files.

    Once you replace that with working code or delete it, move on to "Play": NameError: global name 'broswe' is not defined. This means that you haven't declared anything (variable, function, class, whatever) with the name browse.

    So the idea is that in the PyS60 script shell, in that little green text, you get an error report that specifies the file where the error occured, the line, the function, it shows you the line and it gives you an explanation.

    Screenshot:
    http://i231.photobucket.com/albums/e...ror_report.jpg

  13. #13
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    69

    Re: error when browsing files

    Quote Originally Posted by bogdan.galiceanu View Post
    OK, so the first error is in "Browse", for that appuifw.app.browse_files() thing: AttributeError: browse_files. This means that appuifw.app has no attribute named browse_files.

    Once you replace that with working code or delete it, move on to "Play": NameError: global name 'broswe' is not defined. This means that you haven't declared anything (variable, function, class, whatever) with the name browse.

    So the idea is that in the PyS60 script shell, in that little green text, you get an error report that specifies the file where the error occured, the line, the function, it shows you the line and it gives you an explanation.

    Screenshot:
    http://i231.photobucket.com/albums/e...ror_report.jpg
    I know that there are no such attribute.
    But you have no idea what a attributey I can put in place?

  14. #14
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: error when browsing files

    You don't need to put an attribute there. You need to put the code to browse the files.

    So it would be like:
    Code:
    def browse():
        #Code for browsing files goes here

  15. #15
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: error when browsing files

    Quote Originally Posted by XxXYonIXxX View Post
    I know that there are no such attribute.
    But you have no idea what a attributey I can put in place?
    Hi yonatan,

    You can list the files from a directory by using os module:

    Code:
    import os
    
    def list_musics():
        files = []
        PATH = "E:\\Musics\\"  # Your folder with music files
        musics = os.listdir(PATH) # Lists the files in the folder
        
        for f in musics:
            if os.path.splitext(f)[1] == '.mp3':
                files.append(unicode(f))
        return files
    Hope it helps,

    Rafael.

Similar Threads

  1. Problem packaging and deploying files
    By raffaelbechara in forum Symbian
    Replies: 4
    Last Post: 2008-10-24, 14:53
  2. How to enable security to the files on Memory Card
    By manojkumar.m in forum Mobile Java General
    Replies: 1
    Last Post: 2008-10-04, 18:29
  3. missing header files from FP1 SDK & Plug-ins.
    By ruchirvasavada in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2008-09-08, 20:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×