Commit ce6129af authored by Mart Lubbers's avatar Mart Lubbers

Adapt codequality monitor and callProcess to new API

parent ea1bdad8
implementation module iTasks.Extensions.Process
import iTasks
import iTasks.WF.Definition
import iTasks.WF.Tasks.Core
import iTasks.WF.Tasks.IO
......@@ -9,6 +10,8 @@ import iTasks.UI.Editor.Modifiers
import StdString, StdList
import Data.Maybe, Data.Error
import System.Time
import Text
import qualified System.Process
derive class iTask ProcessInformation, ProcessStatus, CallException
......@@ -18,21 +21,17 @@ where
toString (CallFailed (_,err)) = "Error calling external process: " +++ err
callProcess :: !d ![ViewOption ProcessInformation] !FilePath ![String] !(Maybe FilePath) (Maybe ProcessPtyOptions) -> Task ProcessInformation | toPrompt d
callProcess prompt [ViewAs tof:_] executable arguments workingDirectory pty
= externalProcess prompt executable arguments workingDirectory unitShare (callProcessHandlers executable arguments) pty (comapEditorValue tof gEditor{|*|})
callProcess prompt [ViewUsing tof editor:_] executable arguments workingDirectory pty
= externalProcess prompt executable arguments workingDirectory unitShare (callProcessHandlers executable arguments) pty (comapEditorValue tof editor)
callProcess prompt [] executable arguments workingDirectory pty
= callProcess prompt [ViewAs vt100render zero] executable arguments workingDirectory pty
callProcessHandlers executable arguments
= {onStartup = onStartup, onOutData = onOutData, onErrData = onErrData, onShareChange = onShareChange, onExit = onExit}
where
onStartup _ = (Ok {ProcessInformation|executable=executable,arguments=arguments,stdout="",stderr="",status=RunningProcess}, Nothing, [], False)
onOutData data info=:{ProcessInformation|stdout} _ = (Ok {ProcessInformation|info & stdout = stdout +++ data}, Nothing, [], False)
onErrData data info=:{ProcessInformation|stderr} _ = (Ok {ProcessInformation|info & stderr = stderr +++ data}, Nothing, [], False)
onShareChange info _ = (Ok info, Nothing, [], False)
onExit (ExitCode exitCode) info _ = (Ok {ProcessInformation|info & status = CompletedProcess exitCode}, Nothing)
callProcess prompt vopts fp args wd pty
= withShared [] \stdin->withShared ([], []) \out->
let s = (mapRead (\(stdout,stderr)->
{ executable=fp
, arguments=args
, stdout=concat stdout
, stderr=concat stderr
, status=RunningProcess}) out) in
externalProcess {tv_sec=0,tv_nsec=100000000} fp args wd pty stdin out
-|| viewSharedInformation prompt vopts s
>>- \c->get s @ \s->{s & status=CompletedProcess c}
callInstantProcess :: !FilePath ![String] !(Maybe FilePath) -> Task Int
callInstantProcess cmd args dir = accWorldError (\world -> 'System.Process'.callProcess cmd args dir world) CallFailed
......@@ -24,8 +24,6 @@ import iTasks.Extensions.Document
import iTasks.Extensions.Process
import iTasks.Extensions.FileCollection
derive class iTask ExitCode
UNIT_TESTS_PATH :== "../Tests/TestPrograms"
INTERACTIVE_TESTS_PATH :== "../Tests/TestPrograms/Interactive"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment