documents:120206pyip_cooking:python_imagej_cookbook
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
documents:120206pyip_cooking:python_imagej_cookbook [2021/11/08 07:15] – added background subtraciton kota | documents:120206pyip_cooking:python_imagej_cookbook [2021/11/17 07:34] – [Shell Command] kota | ||
---|---|---|---|
Line 2357: | Line 2357: | ||
See explanation in [[http:// | See explanation in [[http:// | ||
+ | |||
+ | ==== Shell Command ==== | ||
+ | |||
+ | To run Shell command in OSX, here is an example. | ||
+ | |||
+ | <code python> | ||
+ | from java.lang import Runtime | ||
+ | from java.util import Scanner | ||
+ | |||
+ | def runShellCommand( cmd ): | ||
+ | proc = Runtime.getRuntime().exec(cmd) | ||
+ | istream = proc.getInputStream() | ||
+ | scan = Scanner(istream).useDelimiter(" | ||
+ | for ss in scan: | ||
+ | print ss | ||
+ | |||
+ | |||
+ | runShellCommand( " | ||
+ | runShellCommand( "ls -la" ) | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Is dockr daemon running? ==== | ||
+ | |||
+ | Check if the docker daemon is running (): | ||
+ | |||
+ | <code python> | ||
+ | from java.lang import Runtime | ||
+ | from java.util import Scanner | ||
+ | |||
+ | |||
+ | def checkDockerRunning( cmd ): | ||
+ | proc = Runtime.getRuntime().exec(cmd) | ||
+ | inputst = proc.getInputStream() | ||
+ | s = Scanner(inputst).useDelimiter(" | ||
+ | if not s.hasNext(): | ||
+ | print " | ||
+ | return False | ||
+ | for ss in s: | ||
+ | print ss | ||
+ | if ss.startswith(" | ||
+ | return True | ||
+ | else: | ||
+ | print " | ||
+ | return False | ||
+ | |||
+ | # below is for OSX. WIth win, just " | ||
+ | cmd = "/ | ||
+ | if checkDockerRunning( cmd ): | ||
+ | print " | ||
+ | else: | ||
+ | print " | ||
+ | </ | ||
===== JAVADOCS ===== | ===== JAVADOCS ===== |
documents/120206pyip_cooking/python_imagej_cookbook.txt · Last modified: 2022/10/16 07:12 by kota