×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    2

    Program can't access included files

    My first post here – total newbie

    So I create a sis package in ensymble with the UID=0xa0006219

    in there is a couple of folders with graphics and sounds. In my script I access the file paths like this:

    graphics.Image.open('!:\\private\\A0006219\\instruments
    \\pocket_toshi_chimes_2.jpg')

    The program won't run. There is no problem, if I put the same files on a specific folder on the memory card, and change the paths to it like:

    '!:\\python\\instruments\\pocket_toshi_chimes_2.jpg'

    Any ideas? How do those paths work?

    Also, is it true there's no chance to use relative paths?

  2. #2
    Registered User
    Join Date
    Feb 2007
    Location
    Kyiv (Ukraine)
    Posts
    83

    Re: Program can't access included files

    Try
    Code:
    graphics.Image.open('C:\\private\\A0006219\\instruments
    \\pocket_toshi_chimes_2.jpg')
    or
    Code:
    graphics.Image.open('E:\\private\\A0006219\\instruments
    \\pocket_toshi_chimes_2.jpg')

  3. #3
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Helsinki
    Posts
    376

    Re: Program can't access included files

    Any ideas? How do those paths work?

    Also, is it true there's no chance to use relative paths?
    You can use os.path.abspath to get absolute path from a relative. However, you might never know which is the current path of the file.

    For imported Python modules (IMPORTED! Not main module. Python 2.2 feature!) you can use this:
    Code:
    import os, sys
    mod = sys.modules[__name__]
    module_path = os.path.abspath(os.path.dirname(mod.__file__))
    
    path2 = os.path.join(module_path, "..", "foobar")
    Then you can guess the installation path of your .py file:

    Code:
    if os.path.exists(os.path.join("c:", "python", "movz")):
        movz_path=os.path.join("c:", "python")
    else:
        movz_path=os.path.join("e:", "python")
    Mikko Ohtamaa

    http://mfabrik.com
    http://blog.mfabrik.com

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    2

    Re: Program can't access included files

    Thanks for the replies, changing the path to "E:\\" instead of "!:\\", did the trick. And it's enough for this small app. I'll just force it to install on the memory card.

    Interesting tip for the absolute path too.. I will have to play with that also

Similar Threads

  1. Problem with CW 3.1: Wrong files being included
    By svdwal in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2006-07-19, 09:30
  2. *** how to access files on MMC of Nokia3300 ?***
    By haila in forum Mobile Java General
    Replies: 0
    Last Post: 2004-11-04, 23:07
  3. how to Select Access Point by program?
    By haha@java in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2004-04-01, 10:57
  4. how to access directories and files from J2ME app
    By johnmobile in forum Mobile Java General
    Replies: 6
    Last Post: 2004-01-23, 21:25
  5. Replies: 1
    Last Post: 2003-02-17, 13:17

Posting Permissions

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