#NEWLINE# def testBackgroundBatchesCanAccessJobDirectory( self ) : #NEWLINE# #INDENT# s = Gaffer . ScriptNode ( ) #NEWLINE# s [ 'w' ] = GafferDispatchTest . TextWriter ( ) #NEWLINE# s [ 'w' ] [ 'fileName' ] . setValue ( '${dispatcher:jobDirectory}/test.####.txt' ) #NEWLINE# s [ 'w' ] [ 'text' ] . setValue ( 'w on ${frame} from ${dispatcher:jobDirectory}' ) #NEWLINE# dispatcher = GafferDispatch . Dispatcher . create ( 'LocalTest' ) #NEWLINE# dispatcher [ 'executeInBackground' ] . setValue ( True ) #NEWLINE# dispatcher [ 'framesMode' ] . setValue ( GafferDispatch . Dispatcher . FramesMode . CustomRange ) #NEWLINE# frameList = IECore . FrameList . parse ( '2-6x2' ) #NEWLINE# dispatcher [ 'frameRange' ] . setValue ( str ( frameList ) ) #NEWLINE# dispatcher . dispatch ( [ s [ 'w' ] ] ) #NEWLINE# dispatcher . jobPool ( ) . waitForAll ( ) #NEWLINE# jobDir = dispatcher . jobDirectory ( ) #NEWLINE# self . assertEqual ( next ( open ( ( '%s/test.0002.txt' % jobDir ) ) ) , ( 'w on 2 from %s' % jobDir ) ) #NEWLINE# self . assertEqual ( next ( open ( ( '%s/test.0004.txt' % jobDir ) ) ) , ( 'w on 4 from %s' % jobDir ) ) #NEWLINE# self . assertEqual ( next ( open ( ( '%s/test.0006.txt' % jobDir ) ) ) , ( 'w on 6 from %s' % jobDir ) )