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 2Intended 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
All Methods Static Methods Instance Methods Concrete Methods 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 stringstatic 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 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()static booleanisAllowMultiple()static booleanisIDE()StringisJarOnClasspath(String artefact)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 contextbooleanisTesting()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()booleanshouldExport()static booleanshouldRunPythonServer()static booleanshouldRunServer()voidshow()print out some basic information about the current runtime environmentvoidshowIDE()static voidstart(RunTime.Type type, String[] args)static voidstartAPI()static voidstartAPI(String appPath)static voidstartLog(int level, String msg, Object... args)static voidterminate()static voidterminate(int retval, String message, Object... args)booleantestSwitch()
-
-
-
Field Detail
-
runningAs
public RunTime.RunType runningAs
-
appDataMsg
public static String appDataMsg
-
testing
public static boolean testing
-
testingWinApp
public static boolean testingWinApp
-
runType
public RunTime.Type runType
-
jreVersion
public String jreVersion
-
fTempPath
public static File fTempPath
-
fBaseTempPath
public File fBaseTempPath
-
fpBaseTempPath
public String fpBaseTempPath
-
fLibsFolder
public File fLibsFolder
-
fpJarLibs
public String fpJarLibs
-
fpSysLibs
public String fpSysLibs
-
fAppPath
public File fAppPath
-
fSikulixAppPath
public File fSikulixAppPath
-
fSikulixExtensions
public File fSikulixExtensions
-
standardExtensions
public String[] standardExtensions
-
fSikulixLib
public File fSikulixLib
-
fSikulixStore
public File fSikulixStore
-
fSikulixDownloadsGeneric
public File fSikulixDownloadsGeneric
-
fSikulixDownloadsBuild
public File fSikulixDownloadsBuild
-
fSikulixSetup
public File fSikulixSetup
-
fSxBase
public File fSxBase
-
fSxBaseJar
public File fSxBaseJar
-
fSxProject
public File fSxProject
-
fSxProjectTestScriptsJS
public File fSxProjectTestScriptsJS
-
fSxProjectTestScripts
public File fSxProjectTestScripts
-
fpContent
public String fpContent
-
runningJar
public boolean runningJar
-
runningInProject
public boolean runningInProject
-
runningWindows
public boolean runningWindows
-
runningMac
public boolean runningMac
-
runningLinux
public boolean runningLinux
-
javaShow
public String javaShow
-
javaArch
public int javaArch
-
osArch
public String osArch
-
javaVersion
public int javaVersion
-
javahome
public File javahome
-
osName
public String osName
-
sysName
public String sysName
-
osVersion
public String osVersion
-
linuxDistro
public String linuxDistro
-
SXVersion
public String SXVersion
-
SXVersionLong
public String SXVersionLong
-
SXVersionShort
public String SXVersionShort
-
SXSystemVersion
public String SXSystemVersion
-
SXJavaVersion
public String SXJavaVersion
-
ServerList
public String[] ServerList
-
libOpenCV
public static final String libOpenCV
-
runCmdError
public static final String runCmdError
- See Also:
- Constant Field Values
-
NL
public static String NL
-
fLibsProvided
public File fLibsProvided
-
fLibsLocal
public File fLibsLocal
-
useLibsProvided
public boolean useLibsProvided
-
isJythonReady
public boolean isJythonReady
-
isRunningIDE
public static boolean isRunningIDE
-
-
Method Detail
-
isIDE
public static boolean isIDE()
-
shouldRunServer
public static boolean shouldRunServer()
-
getServerOptions
public static String[] getServerOptions()
-
getServerGroups
public static String getServerGroups()
-
getServerExtra
public static String getServerExtra()
-
startAPI
public static void startAPI(String appPath)
-
shouldRunPythonServer
public static boolean shouldRunPythonServer()
-
startAPI
public static void startAPI()
-
start
public static void start(RunTime.Type type, String[] args)
-
afterStart
public static void afterStart(RunTime.Type type, String[] args)
-
evalArgs
public static void evalArgs(String[] args)
-
setAllowMultiple
public static void setAllowMultiple()
-
isAllowMultiple
public static boolean isAllowMultiple()
-
resolveRelativeFile
public static String resolveRelativeFile(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.- Parameters:
scriptName-- Returns:
- absolute file or null if not found
-
getSXArgs
public static String[] getSXArgs()
-
setUserArgs
public static void setUserArgs(String[] args)
-
getUserArgs
public static String[] getUserArgs()
-
printArgs
public static void printArgs()
-
getElapsedStart
public static long getElapsedStart()
-
getLogFile
public static String getLogFile()
-
getUserLogFile
public static String getUserLogFile()
-
getLoadScripts
public static String[] getLoadScripts()
-
getRunScripts
public static String[] getRunScripts()
-
runningScripts
public static boolean runningScripts()
-
isVerbose
public static boolean isVerbose()
-
setVerbose
public static void setVerbose()
-
isQuiet
public static boolean isQuiet()
-
setQuiet
public static void setQuiet()
-
runningIDE
public boolean runningIDE()
-
getLastScriptRunReturnCode
public int getLastScriptRunReturnCode()
-
setLastScriptRunReturnCode
public void setLastScriptRunReturnCode(int lastScriptRunReturnCode)
-
get
public static RunTime get()
-
isTesting
public boolean isTesting()
-
get
public static RunTime get(RunTime.Type typ)
-
getMonitor
public Rectangle getMonitor(int n)
-
terminate
public static void terminate()
-
cleanUp
public static void cleanUp()
-
options
public Options options()
-
shouldExport
public boolean shouldExport()
-
loadLibrary
public static boolean loadLibrary(String libname)
INTERNAL USE: load a native library from the libs folder- Parameters:
libname- name of library without prefix/suffix/ending
-
loadLibrary
public static boolean loadLibrary(String libname, boolean useLibsProvided)
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
public boolean isJava9(String... args)
-
needsRobotFake
public boolean needsRobotFake()
-
show
public void show()
print out some basic information about the current runtime environment
-
testSwitch
public boolean testSwitch()
-
getVersionShort
public String getVersionShort()
-
getSystemInfo
public String getSystemInfo()
-
isVersionRelease
public boolean isVersionRelease()
-
getVersion
public String getVersion()
-
getStatus
public void getStatus()
-
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
public List<String> doExtractToFolderWithList(String fpRessources, File fFolder, List<String> content)
-
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
public boolean extractResourceToFile(String inPrefix, String inFile, File outDir)
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
public boolean extractResourceToFile(String inPrefix, String inFile, File outDir, String outFile)
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
public String extractResourceToString(String inPrefix, String inFile, String encoding)
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
-
resourceListAsFile
public 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 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
public String resourceListAsString(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 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
public String resourceListAsString(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 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
public List<String> doResourceListWithList(String folder, List<String> files, FilenameFilter filter)
-
copy
public static void copy(InputStream in, OutputStream out) throws IOException
- Throws:
IOException
-
dumpClassPath
public void dumpClassPath()
print the current classpath entries to sysout
-
dumpClassPath
public void dumpClassPath(String filter)
print the current classpath entries to sysout whose path name contain the given string- Parameters:
filter- the fileter string
-
isOnClasspath
public boolean isOnClasspath(URL path)
check wether a the given URL is on classpath- Parameters:
path- URL to look for- Returns:
- true if found else otherwise
-
addToClasspath
public boolean addToClasspath(String jarOrFolder)
-
runcmd
public String runcmd(String cmd)
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
public String runcmd(String[] args)
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
public String getLastCommandResult()
-
-