Package org.sikuli.script.support
Class RunTime
java.lang.Object
org.sikuli.script.support.RunTime
public class RunTime extends Object
INTERNAL USE --- NOT official API
not as is in version 2
not as is in version 2
Intended to concentrate all, that is needed at startup of sikulix or sikulixapi and may be at runtime by SikuliX or any caller
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classRunTime.oneFileFilterstatic classRunTime.RunTypestatic classRunTime.Type -
Field Summary
-
Method Summary
Modifier and Type Method Description booleanaddToClasspath(String jarOrFolder)booleanaddToClasspath(String jarOrFolder, String caller)static voidafterStart(RunTime.Type type, String[] args)static StringarrayToQuotedString(String[] args)FileasExtension(String fpJar)static FileasFile(String option)static FileasFolder(String option)static voidcleanUp()static voidcopy(InputStream in, OutputStream out)voidcrash()List<String>doExtractToFolderWithList(String fpRessources, File fFolder, List<String> content)List<String>doResourceListWithList(String folder, List<String> files, FilenameFilter filter)voiddumpClassPath()print the current classpath entries to sysoutvoiddumpClassPath(String filter)print the current classpath entries to sysout whose path name contain the given stringvoiddumpSysProps()print the current java system properties key-value pairs sorted by keyvoiddumpSysProps(String filter)print the current java system properties key-value pairs sorted by key but only keys containing filterstatic voidevalArgs(String[] args)voidexportLib()List<String>extractResourcesToFolder(String fpRessources, File fFolder, FilenameFilter filter)export all resource files from the given subtree on classpath to the given folder retaining the subtree
to export a specific file from classpath use extractResourceToFile or extractResourceToStringList<String>extractResourcesToFolderFromJar(String aJar, String fpRessources, File fFolder, FilenameFilter filter)export all resource files from the given subtree in given jar to the given folder retaining the subtreebooleanextractResourceToFile(String inPrefix, String inFile, File outDir)store a resource found on classpath to a file in the given folder with same filenamebooleanextractResourceToFile(String inPrefix, String inFile, File outDir, String outFile)store a resource found on classpath to a file in the given folderStringextractResourceToString(String inPrefix, String inFile, String encoding)store the content of a resource found on classpath in the returned stringURLfromClasspath(String artefact)static RunTimeget()static RunTimeget(RunTime.Type typ)static FilegetAppPath()static longgetElapsedStart()StringgetLastCommandResult()intgetLastScriptRunReturnCode()static String[]getLoadScripts()static StringgetLogFile()RectanglegetMonitor(int n)StringgetOption(String oName)List<String>getResourceList(String res)List<String>getResourceList(String res, Class classReference)static String[]getRunScripts()static StringgetServerExtra()static StringgetServerGroups()static String[]getServerOptions()voidgetStatus()static String[]getSXArgs()StringgetSystemInfo()static String[]getUserArgs()static StringgetUserLogFile()StringgetVersion()StringgetVersionShort()RectanglehasPoint(Point aPoint)voidhideIDE()voidinstallStopHotkeyPythonServer()static booleanisAllowMultiple()static booleanisIDE()StringisJarOnClasspath(String artefact)booleanisJava8()booleanisJava9(String... args)StringisOnClasspath(String artefact)booleanisOnClasspath(URL path)check wether a the given URL is on classpathstatic booleanisQuiet()booleanisRunningFromJar()INTERNAL USE: to check whether we are running in compiled classes contextstatic booleanisRunningPyServer()booleanisTesting()static booleanisVerbose()booleanisVersionRelease()List<String>listFilesInJar(URL uJar)static booleanloadLibrary(String libname)INTERNAL USE: load a native library from the libs folderstatic booleanloadLibrary(String libname, boolean useLibsProvided)INTERNAL USE: load a native library from the libs folderbooleanneedsRobotFake()Optionsoptions()static voidpause(float time)static voidpause(int time)static voidprintArgs()static StringresolveRelativeFile(String scriptName, String baseDir)a relative path is checked for existence in the current base folder, working folder and user home folder in this sequence.static String[]resolveRelativeFiles(String[] givenScripts)String[]resourceListAsFile(String folder, File target, FilenameFilter filter)write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
non-compact format: every file with full pathString[]resourceListAsSikulixContent(String folder, File targetFolder, FilenameFilter filter)write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
compact sikulixcontent formatString[]resourceListAsSikulixContentFromJar(String aJar, String folder, File targetFolder, FilenameFilter filter)write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
compact sikulixcontent formatStringresourceListAsString(String folder, FilenameFilter filter)write the list produced by calling extractResourcesToFolder to the returned string with system line separator
non-compact format: every file with full pathStringresourceListAsString(String folder, FilenameFilter filter, String separator)write the list produced by calling extractResourcesToFolder to the returned string with given separator
non-compact format: every file with full pathURLresourceLocation(String folderOrFile)Stringruncmd(String cmd)run a system command finally using Java::Runtime.getRuntime().exec(args) and waiting for completionStringruncmd(String[] args)run a system command finally using Java::Runtime.getRuntime().exec(args) and waiting for completionbooleanrunningIDE()static booleanrunningScripts()static voidsetAllowMultiple()voidsetLastScriptRunReturnCode(int lastScriptRunReturnCode)static voidsetQuiet()static voidsetUserArgs(String[] args)static voidsetVerbose()static booleanshouldDetach()booleanshouldExport()static booleanshouldRunPythonServer()static booleanshouldRunServer()voidshow()print out some basic information about the current runtime environmentvoidshowIDE()static voidstart(RunTime.Type type, String[] args)static voidstartLog(int level, String msg, Object... args)static voidstartPythonServer()static voidstopPythonServer()static voidterminate()static voidterminate(int retval, String message, Object... args)booleantestSwitch()
-
Field Details
-
runningAs
-
appDataMsg
-
testing
public static boolean testing -
testingWinApp
public static boolean testingWinApp -
runType
-
sxBuild
-
sxBuildStamp
-
jreVersion
-
optionsIDE
-
classLoader
-
userName
-
fTempPath
-
fBaseTempPath
-
fpBaseTempPath
-
fLibsFolder
-
fpJarLibs
-
fpSysLibs
-
fUserDir
-
fWorkDir
-
fAppPath
-
fSikulixAppPath
-
fSikulixExtensions
-
standardExtensions
-
fSikulixLib
-
fSikulixStore
-
fSikulixDownloadsGeneric
-
fSikulixDownloadsBuild
-
fSikulixSetup
-
fSxBase
-
fSxBaseJar
-
fSxProject
-
fSxProjectTestScriptsJS
-
fSxProjectTestScripts
-
fpContent
-
runningJar
public boolean runningJar -
runningInProject
public boolean runningInProject -
runningWindows
public boolean runningWindows -
runningMac
public boolean runningMac -
runningLinux
public boolean runningLinux -
javaShow
-
javaArch
public int javaArch -
osArch
-
javaVersion
public int javaVersion -
javahome
-
osName
-
sysName
-
osVersion
-
linuxDistro
-
SikuliVersionMajor
public int SikuliVersionMajor -
SikuliVersionMinor
public int SikuliVersionMinor -
SikuliVersionSub
public int SikuliVersionSub -
SXVersion
-
SXVersionLong
-
SXVersionShort
-
SXBuild
-
SXBuildNumber
-
SXVersionIDE
-
SXVersionAPI
-
SXSystemVersion
-
SXJavaVersion
-
ServerList
-
libOpenCV
-
runCmdError
- See Also:
- Constant Field Values
-
NL
-
fLibsProvided
-
fLibsLocal
-
useLibsProvided
public boolean useLibsProvided -
isJythonReady
public boolean isJythonReady -
isRunningIDE
public static boolean isRunningIDE
-
-
Method Details
-
isIDE
public static boolean isIDE() -
start
-
afterStart
-
installStopHotkeyPythonServer
public void installStopHotkeyPythonServer() -
startPythonServer
public static void startPythonServer() -
stopPythonServer
public static void stopPythonServer() -
isRunningPyServer
public static boolean isRunningPyServer() -
asFolder
-
asFile
-
evalArgs
-
resolveRelativeFiles
-
resolveRelativeFile
a relative path is checked for existence in the current base folder, working folder and user home folder in this sequence.- Parameters:
scriptName-- Returns:
- absolute file or null if not found
-
getSXArgs
-
setUserArgs
-
getUserArgs
-
printArgs
public static void printArgs() -
getElapsedStart
public static long getElapsedStart() -
getLogFile
-
getUserLogFile
-
getLoadScripts
-
getRunScripts
-
runningScripts
public static boolean runningScripts() -
shouldRunServer
public static boolean shouldRunServer() -
getServerOptions
-
getServerGroups
-
getServerExtra
-
shouldRunPythonServer
public static boolean shouldRunPythonServer() -
setAllowMultiple
public static void setAllowMultiple() -
isAllowMultiple
public static boolean isAllowMultiple() -
shouldDetach
public static boolean shouldDetach() -
getAppPath
-
isVerbose
public static boolean isVerbose() -
setVerbose
public static void setVerbose() -
isQuiet
public static boolean isQuiet() -
setQuiet
public static void setQuiet() -
startLog
-
arrayToQuotedString
-
runningIDE
public boolean runningIDE() -
getLastScriptRunReturnCode
public int getLastScriptRunReturnCode() -
setLastScriptRunReturnCode
public void setLastScriptRunReturnCode(int lastScriptRunReturnCode) -
get
-
isTesting
public boolean isTesting() -
get
-
getMonitor
-
hasPoint
-
terminate
public static void terminate() -
terminate
-
cleanUp
public static void cleanUp() -
getOption
-
options
-
shouldExport
public boolean shouldExport() -
loadLibrary
INTERNAL USE: load a native library from the libs folder- Parameters:
libname- name of library without prefix/suffix/ending
-
loadLibrary
INTERNAL USE: load a native library from the libs folder- Parameters:
libname- name of library without prefix/suffix/ending
-
hideIDE
public void hideIDE() -
showIDE
public void showIDE() -
exportLib
public void exportLib() -
crash
public void crash() -
pause
public static void pause(int time) -
pause
public static void pause(float time) -
isRunningFromJar
public boolean isRunningFromJar()INTERNAL USE: to check whether we are running in compiled classes context- Returns:
- true if the code source location is a folder ending with classes (Maven convention)
-
isJava9
-
isJava8
public boolean isJava8() -
needsRobotFake
public boolean needsRobotFake() -
show
public void show()print out some basic information about the current runtime environment -
testSwitch
public boolean testSwitch() -
getVersionShort
-
getSystemInfo
-
isVersionRelease
public boolean isVersionRelease() -
getVersion
-
getStatus
public void getStatus() -
getResourceList
-
getResourceList
-
extractResourcesToFolder
public List<String> extractResourcesToFolder(String fpRessources, File fFolder, FilenameFilter filter)export all resource files from the given subtree on classpath to the given folder retaining the subtree
to export a specific file from classpath use extractResourceToFile or extractResourceToString- Parameters:
fpRessources- path of the subtree relative to rootfFolder- folder where to export (if null, only list - no export)filter- implementation of interface FilenameFilter or null for no filtering- Returns:
- the filtered list of files (compact sikulixcontent format)
-
doExtractToFolderWithList
-
extractResourcesToFolderFromJar
public List<String> extractResourcesToFolderFromJar(String aJar, String fpRessources, File fFolder, FilenameFilter filter)export all resource files from the given subtree in given jar to the given folder retaining the subtree- Parameters:
aJar- absolute path to an existing jar or a string identifying the jar on classpath (no leading /)fpRessources- path of the subtree or file relative to rootfFolder- folder where to export (if null, only list - no export)filter- implementation of interface FilenameFilter or null for no filtering- Returns:
- the filtered list of files (compact sikulixcontent format)
-
extractResourceToFile
store a resource found on classpath to a file in the given folder with same filename- Parameters:
inPrefix- a subtree found in classpathinFile- the filename combined with the prefix on classpathoutDir- a folder where to export- Returns:
- success
-
extractResourceToFile
store a resource found on classpath to a file in the given folder- Parameters:
inPrefix- a subtree found in classpathinFile- the filename combined with the prefix on classpathoutDir- a folder where to exportoutFile- the filename for export- Returns:
- success
-
extractResourceToString
store the content of a resource found on classpath in the returned string- Parameters:
inPrefix- a subtree from root found in classpath (leading /)inFile- the filename combined with the prefix on classpathencoding-- Returns:
- file content
-
resourceLocation
-
resourceListAsFile
write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
non-compact format: every file with full path- Parameters:
folder- path of the subtree relative to root with leading /target- the file to write the list (if null, only list - no file)filter- implementation of interface FilenameFilter or null for no filtering- Returns:
- success
-
resourceListAsSikulixContent
public String[] resourceListAsSikulixContent(String folder, File targetFolder, FilenameFilter filter)write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
compact sikulixcontent format- Parameters:
folder- path of the subtree relative to root with leading /targetFolder- the folder where to store the file sikulixcontent (if null, only list - no export)filter- implementation of interface FilenameFilter or null for no filtering- Returns:
- success
-
resourceListAsSikulixContentFromJar
public String[] resourceListAsSikulixContentFromJar(String aJar, String folder, File targetFolder, FilenameFilter filter)write the list as it is produced by calling extractResourcesToFolder to the given file with system line separator
compact sikulixcontent format- Parameters:
aJar- absolute path to an existing jar or a string identifying the jar on classpath (no leading /)folder- path of the subtree relative to root with leading /targetFolder- the folder where to store the file sikulixcontent (if null, only list - no export)filter- implementation of interface FilenameFilter or null for no filtering- Returns:
- success
-
resourceListAsString
write the list produced by calling extractResourcesToFolder to the returned string with system line separator
non-compact format: every file with full path- Parameters:
folder- path of the subtree relative to root with leading /filter- implementation of interface FilenameFilter or null for no filtering- Returns:
- the resulting string
-
resourceListAsString
write the list produced by calling extractResourcesToFolder to the returned string with given separator
non-compact format: every file with full path- Parameters:
folder- path of the subtree relative to root with leading /filter- implementation of interface FilenameFilter or null for no filteringseparator- to be used to separate the entries- Returns:
- the resulting string
-
doResourceListWithList
-
listFilesInJar
-
copy
- Throws:
IOException
-
dumpClassPath
public void dumpClassPath()print the current classpath entries to sysout -
dumpClassPath
print the current classpath entries to sysout whose path name contain the given string- Parameters:
filter- the fileter string
-
isJarOnClasspath
-
isOnClasspath
-
fromClasspath
-
isOnClasspath
check wether a the given URL is on classpath- Parameters:
path- URL to look for- Returns:
- true if found else otherwise
-
addToClasspath
-
addToClasspath
-
asExtension
-
dumpSysProps
public void dumpSysProps()print the current java system properties key-value pairs sorted by key -
dumpSysProps
print the current java system properties key-value pairs sorted by key but only keys containing filter- Parameters:
filter- the filter string
-
runcmd
run a system command finally using Java::Runtime.getRuntime().exec(args) and waiting for completion- Parameters:
cmd- the command as it would be given on command line, quoting is preserved- Returns:
- the output produced by the command (sysout [+ "*** error ***" + syserr] if the syserr part is present, the command might have failed
-
runcmd
run a system command finally using Java::Runtime.getRuntime().exec(args) and waiting for completion- Parameters:
args- the command as it would be given on command line splitted into the space devided parts, first part is the command, the rest are parameters and their values- Returns:
- the output produced by the command (sysout [+ "*** error ***" + syserr] if the syserr part is present, the command might have failed
-
getLastCommandResult
-