/
pull.jy
41 lines (26 loc) · 1.09 KB
/
pull.jy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from org.das2.util import LoggerManager
print '****'
print 'This is pull.jy, an editor action.'
setScriptTitle('Git Pull')
setScriptDescription('Run the git pull command. This assumes that the git commands are available at the command line. TODO: make a ro_cache.txt link.')
logger= LoggerManager.getLogger('jython.actions')
script= getApplication().getScriptPanel().getFilename()
from java.io import File
from org.autoplot.datasource import AutoplotSettings
autoplotData= AutoplotSettings.settings().resolveProperty( AutoplotSettings.PROP_AUTOPLOTDATA )
exe= 'git pull'
logger.info("pwd: "+str( File( script ).parentFile ) )
setStatus( "busy: executing pull" )
from java.lang import ProcessBuilder
pb= ProcessBuilder(exe.split(' '))
pb.directory( File( script ).parentFile )
log= File( autoplotData, 'log' )
log= File( log, 'editor.pull.txt' )
pb.redirectErrorStream(True)
pb.redirectOutput( ProcessBuilder.Redirect.to(log) )
p= pb.start()
p.waitFor()
from org.das2.util import FileUtil
msg= FileUtil.readFileToString( log )
showMessageDialog(msg)
setStatus( "Pull complete, see " + str(log) )