`
MyEyeOfJava
  • 浏览: 1124874 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
7af2d6ca-4fe1-3e9a-be85-3f65f7120bd0
测试开发
浏览量:70171
533896eb-dd7b-3cde-b4d3-cc1ce02c1c14
晨记
浏览量:0
社区版块
存档分类
最新评论

[sikuli]-导入代码库和Jar

 
阅读更多

 

# an example - choose your own naming
# on Windows
myScriptPath = "c:\\someDirectory\\myLibrary"
# on Mac/Linux
myScriptPath = "/someDirectory/myLibrary"

# all systems
if not myScriptPath in sys.path: sys.path.append(myScriptPath)

# supposing there is a myLib.sikuli
import myLib

# supposing myLib.sikuli contains a function "def myFunction():"
myLib.myFunction() # makes the call

# instead of: import module

如果你的代码里没有定义def方法,那么该模块只加载一次,第二次将不在加载。如果你想重新加载,请使用Jython的reload方法。

import module
reload(module)

# instead of: from module import *
import module
reload(module)
from module import *
把你的代码库自动加到项目环境内:
# works on all platforms
import os
# get the directory containing your running .sikuli
myPath = os.path.dirname(getBundlePath())
if not myPath in sys.path: sys.path.append(myPath)

# now you can import every .sikuli in the same directory
import myLib

New in version X1.0-rc3.

Since scripts in same directory are found automatically:

# nothing else needed
# now you can import every .sikuli in the same directory
import myLib

在你的python项目内加载Jar文件

Loading a jar-file containing Java/Python modules

New in version X1.0-rc2.

load(jar-file)

Loads a jar-file and puts the absolute path to it into sys.path, so the Java or Python code in that jar-file can be imported afterwards.

Parameters: Returns:
  • jar-file – either a filename.jar without any path or the absolute path to filename.jar

True if the file was found, otherwise False

Note: if no path is specified, Sikuli first looks into the bundle (the Sikuli folder of the running script) and then into the extensions folder. (more information: Sikuli Extensions)

 

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics