← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #171547]: import controller failing

 

Question #171547 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/171547

    Status: Needs information => Answered

RaiMan proposed the following answer:
I still need to guess:

The directory containing your main Sikuli script bot.sikuli contains the
following Python scripts:

ini.py
model.py
view.py
controller.py

the ini.py is processed inline with exec

then the other modules are imported.

module controller contains a MainController class, which is initiated at
bot_app = controller.MainController()

and then you are calling a MainController method with
bot_app.trade_mode()

up to this point everything should work fine and has nothing to do with
the code you posted in the question above.

--- BTW: if you run this script repeatedly in the IDE, you should use

if not path_to_bot in sys.path: sys.path.append(path_to_bot)

to avoid appending, if it is already there (which is the case with
subsequent runs)

--- One more thing:

In the directory containing your main script put all your modules into a directory (e.g. myModules), which contains an __init__.py, which in turn does all the other needed imports.
Then with rc3, you would need only a
from myModule import *

so your script would read:

from sikuli.Sikuli import *

path_to_bot = getBundlePath().split("bot.sikuli")[0]
execfile(path_to_bot + "ini.py", "rb") # guess is needed for some globals

from myModule import *

bot_app = controller.MainController()
#bot_app.maintenance_mode()
bot_app.trade_mode()

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.