User Tools

Site Tools


documents:120206pyip_cooking:python_imagej_cookbook

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
documents:120206pyip_cooking:python_imagej_cookbook [2021/11/17 07:14] – [Shell Command] new addition kotadocuments:120206pyip_cooking:python_imagej_cookbook [2021/11/17 07:34] – [Shell Command] kota
Line 2376: Line 2376:
 runShellCommand( "pwd" ) runShellCommand( "pwd" )
 runShellCommand( "ls -la" ) runShellCommand( "ls -la" )
 +</code>
 +
 +
 +==== 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("\\n")
 + if not s.hasNext():
 + print "Please start docker desktop!"
 + return False
 + for ss in s:
 + print ss
 + if ss.startswith("CONTAINER ID"):
 + return True
 + else:
 + print "Please start docker desktop!"
 + return False
 +
 +# below is for OSX. WIth win, just "docker ps"
 +cmd = "/usr/local/bin/docker ps" 
 +if checkDockerRunning( cmd ):
 + print "Docker running"
 +else:
 + print "Docker not running"
 </code> </code>
  
documents/120206pyip_cooking/python_imagej_cookbook.txt · Last modified: 2022/10/16 07:12 by kota

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki