Home Help Center

Python including slices

toaditoadi Member
Hello,

I'm new to ice and python so probably I'm just overlooking something trivial.

But I include our own slice files into my python program:

Ice.loadSlice('Session.ice')
Ice.loadSlice('SecurityItmes.ice')

But one of our own slice files has a include:

#include <Ice/Plugin.ice>

So I added:

Ice.loadSlice('-I c:/Ice-3.0.1/slice/Ice Plugin.ice')

But now following error occurs:

icecpp: can't open `Plugin.ice' for reading
Traceback (most recent call last):
File "Client.py", line 13, in ?
Ice.loadSlice('-I c:/Ice-3.0.1/slice/Ice Plugin.ice')
RuntimeError: Slice preprocessing failed for `-I c:/Ice-3.0.1/slice/Ice Plugin.i
ce'

I also tried with:

Ice.loadSlice('-I c:/Ice-3.0.1/slice Plugin.ice')

Like I told I'm new to ice and new to python so probably I'm missing something trivial...

Comments

  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Hi,

    If one of your slice files includes a slice file from another directory you need to add the include directive when you load your slice file. ie

    Ice.loadSlice('-I c:/Ice-3.0.1/slice SecurityItmes.ice')

    or whichever slice file has the include. What you doing above is trying to load a file named Plugin.ice in your current directory, which does not exist.

    Regards,
    Dwayne
  • toaditoadi Member
    Hello,

    So I have:

    in my local slice dir:

    someslice1.ice
    someslice2.ice
    someslice3.ice


    someslice1.ice has as includes:

    #include <someslice2.ice>
    #include <someslice3.ice>

    someslice2.ice has as includes:

    #include <Ice/Plugin.ice>
    #include <someslice3.ice>

    My python script contains:

    Ice.loadSlice('-I c:/Ice-3.0.1/slice -I C:/localslicepath someslice1.ice')
    Ice.loadSlice('-I c:/Ice-3.0.1/slice -I C:/localslicepath someslice2.ice')
    Ice.loadSlice('-I c:/Ice-3.0.1/slice -I C:/localslicepath someslice3.ice')

    Following error occurs:

    Traceback (most recent call last):
    File "Client.py", line 13, in ?
    Ice.loadSlice('-I c:/Ice-3.0.1/slice -I C:/localslicepath someslice1.ice')
    File "someslice1.ice'", line 3, in ?

    ImportError: No module named someslice2_ice

    Why is there a importerror?
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Add -I., so that the current directory is searched.

    You can also simply add --all, so that all dependencies are included. Then you only need one line:

    Ice.loadSlice('--all -I. -Ic:/Ice-3.0.1/slice -IC:/localslicepath someslice1.ice')
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    marc wrote:
    Add -I., so that the current directory is searched.

    You can also simply add --all, so that all dependencies are included. Then you only need one line:

    Ice.loadSlice('--all -I. -Ic:/Ice-3.0.1/slice -IC:/localslicepath someslice1.ice')

    Sorry, what I wrote is not correct, you don't need "-I.". You get the error because at the time you try to load someslice1.ice, someslice2.ice has not yet been loaded. So you must either reverse your load order, or instead load someslice1.ice including all it's dependencies with the --all option (which is simpler IMO).
  • toaditoadi Member
    This seems to work. Thanks for the quick response.
Sign In or Register to comment.