← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #264180]: how to import a file in other file between middle of the code

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
generally:
imports are static (only down once) and as such should be at the top of the script.
especially in this case, where you force a re-import  (I guess since you are working in the Sikuli IDE on both modules in parallel).

so this is better in any case:

#######Main.sikuli
import csv
import main
reload(main)
from main import *

if ((scnName == "general") & (stpTest == "STP-GPSBL-002")): #checking the condition
    print "Done"
    startMstsc(1)
    try:
        startApp(1)
        onAppear("7Connected.png", handler)
        observe(FOREVER)
        startTest(1)
        stopMstsc(1)

    except FindFailed:
        popup("image not found")
        print "img not found on the screen"

now you are doing an import(main), but I cannot see any main.sikuli.

if I understand your script right then this should be:
import MSTSC_SIM
reload(MSTSC_SIM)
from MSTSC_SIM import *

… or I understand everything completely wrong.

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