← Back to team overview

sikuli-driver team mailing list archive

[Question #206597]: Problem with importing "external" modules

 

New question #206597 on Sikuli:
https://answers.launchpad.net/sikuli/+question/206597

I have got (again *g*) a problem (funny thing is, that this once worked but won't work now anymore...):

I have a "main" sikuli.file (Runme.sikuli) which loads other "external" sikuli-files on demand and runs a pre-defined
routine "runModule()" inside of the loaded "external" modules. These are then doing their tests and the main sikuli
file loads the next module and so on...

All these files are opened via \\FILESERVER\Directory\Directory\Directory\Runme.sikuli (for the runme.sikuli) and
\\FILESERVER\Directory\Directory\Directory\Runme.sikuli\Tests\Test1.sikuli (for the first module).

The external modules "InitSystem" and "GlobalSettings" are opened and found correctly, they are saved here:
\\FILESERVER\Directory\Directory\Directory\Runme.sikuli\InitSystem.sikuli
\\FILESERVER\Directory\Directory\Directory\Runme.sikuli\GlobalSettings.sikuli

So the other external modules are one level more down (in the "Tests"-directory) than "InitSystem" and "GlobalSettings".

Here is the code (I have cut out all the other code which is not important here) of Runme.sikuli:
---
import InitSystem
import GlobalSettings

import os
dir = os.path.dirname(getBundlePath())
tests = os.path.join(dir, "Tests")

modulesToRun = ("Test1", "Test2", "Test_OCR")

print("Testing started: " + InitSystem.getCurrentTime())
popup("Abort test with ALT+SHIFT+C")

if (InitSystem.startUp(GlobalSettings.screenT, GlobalSettings.screenQ, GlobalSettings.screenP)==0): # Init the tests
    popup("ERROR during startup, cancelling all tests...")
    exit
else:    # Startup was OK
    # Iterating through all Test-Modules
    popup("OK starting Tests in Modules")
    for currentModule in modulesToRun:
        popup("Working with module " + currentModule + " in directory " + tests)
    
        currDir = os.path.join(tests, currentModule+".sikuli")
        if not currDir in sys.path:
            sys.path.append(currDir)

        popup("Opening " + currentModule)
        # Position XXXX1
        exec("import " + currentModule)
        exec(currentModule + ".runModule()")
    
InitSystem.shutDown() # Shut down the test
print("Testing ended: " + getCurrentTime())
---

The contents of the variables are at Position XXXX1:
currentModule: Test1
currDir: \\FILESERVER\Directory\Directory\Runme.sikuli\Tests\Test1.sikuli

The Error I get is:
---
[error] Error message: Traceback (most recent call last):
 File "c:\temp\windows\sikuli-tmp2898954620263380028.py", line 27, in 
 exec("import " + currentModule)
 File "", line 1, in 
ImportError: No module named Test1
---

Can please anybody help me? :)

I hope that I could describe the setup here :-)

Thanks a lot and best regards,

Chris

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