1

I am working on sikulixide-2.0.5 on windows. Now I would like to utilize user properties write/read functions to implement persistence of application parameters, So that I am learning as the part of reference shown : https://sikulix-2014.readthedocs.io/en/latest/globals.html#saveOpts

The question is , whatever I call any persistence-related API with fix term of Opt , for example makeOpts() , the engine would keep answer me following error, How do I get it works?

[error] AttributeError ( 'org.sikuli.script.support.RunTime' object has no attribute 'makeOpts' )

reference code here , pretty simple :

from sikuli import *

def trialOpts():
    obj = makeOpts()
    return

trialOpts()

As contrast , other kind API like click(), find() are working fine without AttributeError message , which means the main engine of Sikuli is exactly running.

Since these are native API of Sikuli , as my understanding , it should not have to import any modules? To make sure of that , I studied bit source codes of Sikuli on Github , the APIs with term Opt were exactly defined there in Sikuli.py :

enter image description here

By far I am running out clues. Please can you help.

Ju-Hsien Lai
  • 643
  • 7
  • 14

2 Answers2

1

I took another look into the most recent release code and there are alternative preferences handling methods available (see: org.sikuli.basics.PreferencesUser)

from sikuli import *
from org.sikuli.basics import PreferencesUser

def trialOpts():
    obj = PreferencesUser.get()
    obj.put("foo","bar")
    print obj.get("foo","bart")
    return

trialOpts()
Curtis
  • 548
  • 3
  • 13
0

Those "*Opts" convenience methods seem to not exist in the 2.0.5 release. It looks like they were refactored out of existence.

To see what those methods do (and potentially recreate them in jython), see:

https://www.javatips.net/api/SikuliX-2014-master/API/src/main/java/org/sikuli/script/RunTime.java

Additionally, it looks like the github project has the code if you pull a pre-2.0.0 tag:

https://github.com/RaiMan/SikuliX1

Curtis
  • 548
  • 3
  • 13
  • Just checkout repository, I saw options handling functions still there on 2.0.5. – Ju-Hsien Lai Mar 16 '21 at 01:53
  • 1
    I only found those methods in Sikuli.py for 2.0.5. They are not reflected in the RunTime class however. You may take the previous definitions of those method (pre-2.0.0) and implement them yourself. For example, "makeOpts()" is basically "return new Properties();" – Curtis Mar 16 '21 at 14:48
  • You are probably right, by response of the issue I raised on Github, the author said this feature were lost in 2.0.5. Apologized I was having no idea to Java runtime. – Ju-Hsien Lai Mar 17 '21 at 01:50