[2.0.5] IDE: import sub as su and from sub import * need IDE restart on changes in sub --- workaround

Asked by Filipe Barbosa

------------------- workaround
only use
import sub

-------------------------------------

I use IDE version 2.0.5, and I'm working with two files:

-index.sikuli
-utils.sikuli

Imagining that I make a change in the utils.sikuli file, for example in a print("123") to print("234"), and after saving the file, when I run it, it continues to print "123". I need to restart the IDE for it to get it to print the "234".

I've been investigating and I'm not even able to find a solution, from for example setting sikuli.properties to not keeping the cache, or using the reload method.

Sorry if this is a dumb question, and my poor English

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Not a dumb question, but too little information about how you use the utils.sikuli.

Since the IDE behaviour when running a script is to always use the latest saved version (even, when autosave is activated), I guess, that you are importing the utils script from the index script.

something like this:

# main.sikuli
import sub
print "in main"
sub.run()

# sub.sikuli
from sikuli import *
def run():
    print "in sub"

I just tested on Windows in IDE 2.0.5 having both scripts open in their tabs.

When doing a change in sub and then run main (even without having saved sub - done automatically), the change is reflected:

# first run of main
in main
in sub

# change the print in sub

# second run of main
in main
in subx

and vice versa. So it simply works.

In the same IDE session imported scripts are remembered and reloaded, when changed.
The only related option is the autosave on run in the IDE settings

So please check your setup and put sample code here.

My test IDE 2.0.5 has a build stamp 21-03-03

Revision history for this message
Filipe Barbosa (fbarbosa3) said :
#2

This is my example code:

______________________________________________

#main.sikuli
import staticUtils as su

print("in main")
su.test1()

_________________________________________________

# sub.sikuli
from sikuli import *

def test1():
    print("in subx")

_________________________________________

after change the print "in sub" to "in subx" i receive:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'staticUtils' is not defined
[error] IDE: Run Script: internal error:

Revision history for this message
RaiMan (raimund-hocke) said :
#3

Ok, thanks for coming back.

I have to confirm, that only
import sub
works.

import sub as su
and
from sub import *

both produce the error.

I will check the behavior in 2.0.6 and in case try to fix.

With 2.0.5 you can currently only use
import sub
if you do not want to restart the IDE after changes in sub.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

Ok, thanks for coming back.

I have to confirm, that only
import sub
works.

import sub as su
and
from sub import *

both produce the error.

I will check the behavior in 2.0.6 and in case try to fix.

With 2.0.5 you can currently only use
import sub
if you do not want to restart the IDE after changes in sub.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

is a bug