[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)

目录
相关文章
|
5月前
idea新建module路径问题
idea新建module路径问题
|
5月前
|
Java Android开发
Eclipse里面导工程的时候报错faceted project problem
Eclipse里面导工程的时候报错faceted project problem
|
6月前
|
开发者
Angular Schematics 实战 - 项目根目录新建一个文件
Angular Schematics 实战 - 项目根目录新建一个文件
30 0
|
缓存 应用服务中间件
1、IDEA中新建Module出现文件名重复的问题解决
IDEA中新建Module出现文件名重复的问题解决 问题描述:在IDEA中运行Tomcat出现错误,提示Error during artifact deployment时,删除并重建Module及Tomcat Server后,出现文件重复问题,不可再命名为已删除的Module文件名,文件夹中删除文件
|
3月前
|
JavaScript IDE 开发工具
HarmonyOS3项目扩展名ets文件和ts文件有什么区别
HarmonyOS3项目扩展名ets文件和ts文件有什么区别
62 0
|
6月前
|
IDE Java 开发工具
IDE工具之IDEA中Module的创建、删除、导入
IDE工具之IDEA中Module的创建、删除、导入
190 0
|
7月前
|
Java Maven
解决IntelliJ IDEA执行maven打包,执行java -jar命令提示jar中没有主清单属性
执行`java -jar app.jar`命令后,提示jar中没有主清单属性
441 1
|
9月前
|
开发工具 Android开发 git
学习笔记jira项目12-优化为ts文件
学习笔记jira项目12-优化为ts文件
53 0
学习笔记jira项目12-优化为ts文件
|
Java Android开发
Java工具IDEA创建模块(Module)、如何创建 Module:、如何删除模块
Java工具IDEA创建模块(Module)、如何创建 Module:、如何删除模块
Java工具IDEA创建模块(Module)、如何创建 Module:、如何删除模块