Commit 84da8362 authored by Mart Lubbers's avatar Mart Lubbers

Adapt to clean-platform pty update

parent 66710316
......@@ -714,7 +714,7 @@ externalProcessExample =
enterInformation "Enter the path to the external process. To for instance open a shell run '/bin/bash' or 'c:\\Windows\\System32\\cmd.exe'." [] >>= \path ->
withShared
Nothing
( \sds -> ( externalProcess path [] Nothing sds True handlers <<@ ApplyLayout (removeSubUIs (SelectByPath [])) >&>
( \sds -> ( externalProcess path [] Nothing sds handlers Nothing <<@ ApplyLayout (removeSubUIs (SelectByPath [])) >&>
viewSharedInformation "Process output" []
) -&&-
forever (enterInformation "Enter data to send to StdIn" [] >>= \data -> set (Just (data +++ "\n")) sds)
......
......@@ -6,7 +6,8 @@ from TCPIP import class ChannelEnv, :: IPAddress, :: Timeout
from Internet.HTTP import :: HTTPRequest, :: HTTPResponse
from System.FilePath import :: FilePath
from System.Time import :: Timestamp
from System.Time import :: Timestamp
from System.Process import :: ProcessPtyOptions
from Data.Error import :: MaybeError
from iTasks.WF.Definition import :: TaskId
from iTasks.Internal.IWorld import :: IWorld, :: BackgroundTaskId
......@@ -23,7 +24,7 @@ addListener :: !TaskId !Int !Bool !ConnectionTask !*IWorld -> (!MaybeError TaskE
addConnection :: !TaskId !String !Int !ConnectionTask !*IWorld -> (!MaybeError TaskException (),!*IWorld)
//Dynamically add an external process
addExternalProc :: !TaskId !FilePath ![String] !(Maybe FilePath) !Bool !ExternalProcessTask !IWorld -> (!MaybeError TaskException (), !*IWorld)
addExternalProc :: !TaskId !FilePath ![String] !(Maybe FilePath) !ExternalProcessTask (!Maybe ProcessPtyOptions) !IWorld -> (!MaybeError TaskException (), !*IWorld)
//Dynamically add a background task
addBackgroundTask :: !BackgroundTask !*IWorld -> (!MaybeError TaskException BackgroundTaskId,!*IWorld)
......
......@@ -538,7 +538,7 @@ where
= case mbConn of
Nothing = (Error ("Failed to connect to host " +++ host), {iworld & world = world})
Just channel = (Ok (ip, channel), {iworld & world = world})
onInitHandler :: !IPAddress !Dynamic !*IWorld -> (!MaybeErrorString Dynamic, !Maybe Dynamic, ![String], !Bool, !*IWorld)
onInitHandler ip r iworld = handlers.ConnectionHandlersIWorld.onConnect (toString ip) r iworld
......@@ -547,17 +547,19 @@ where
# opts = {ConnectionInstanceOpts|taskId = taskId, connectionId = 0, remoteHost = ip, connectionTask = connectionTask, removeOnClose = False}
= ConnectionInstance opts channel
addExternalProc :: !TaskId !FilePath ![String] !(Maybe FilePath) !Bool !ExternalProcessTask !IWorld -> (!MaybeError TaskException (), !*IWorld)
addExternalProc taskId cmd args dir pty extProcTask=:(ExternalProcessTask handlers sds) iworld
addExternalProc :: !TaskId !FilePath ![String] !(Maybe FilePath) !ExternalProcessTask (!Maybe 'Process'.ProcessPtyOptions) !IWorld -> (!MaybeError TaskException (), !*IWorld)
addExternalProc taskId cmd args dir extProcTask=:(ExternalProcessTask handlers sds) mopts iworld
= addIOTask taskId sds init externalProcessIOOps onInitHandler mkIOTaskInstance iworld
where
init :: !*IWorld -> (!MaybeErrorString (!(), (!ProcessHandle, !ProcessIO)), !*IWorld)
init iworld
# (mbRes, world) = (if pty 'Process'.runProcessPty 'Process'.runProcessIO) cmd args dir iworld.world
# (mbRes, world) = case mopts of
Nothing = 'Process'.runProcessIO cmd args dir iworld.world
Just opts = 'Process'.runProcessPty cmd args dir opts iworld.world
= case mbRes of
Error (_, e) = (Error e, {iworld & world = world})
Ok proc = (Ok ((), proc), {iworld & world = world})
onInitHandler :: !() !Dynamic !*IWorld -> (!MaybeErrorString Dynamic, !Maybe Dynamic, ![String], !Bool, !*IWorld)
onInitHandler _ r iworld
# (mbl, mbw, out, close) = handlers.ExternalProcessHandlers.onStartup r
......
......@@ -6,6 +6,7 @@ definition module iTasks.WF.Tasks.IO
import iTasks.WF.Definition
from iTasks.SDS.Definition import :: RWShared, :: SDS
from System.FilePath import :: FilePath
from System.Process import :: ProcessPtyOptions
from Data.Error import :: MaybeError, :: MaybeErrorString
:: ConnectionHandlers l r w =
......@@ -30,10 +31,10 @@ from Data.Error import :: MaybeError, :: MaybeErrorString
* @param a list of command-line arguments
* @param (optional) startup directory
* @param A reference to shared data the task has access to
* @param A flag whether to open a pseudotty
* @param The event handler functions
* @param Optionally the pseudotty settings
*/
externalProcess :: !FilePath ![String] !(Maybe FilePath) !(RWShared () r w) !Bool !(ExternalProcessHandlers l r w) -> Task l | iTask l & TC r & TC w
externalProcess :: !FilePath ![String] !(Maybe FilePath) !(RWShared () r w) !(ExternalProcessHandlers l r w) !(Maybe ProcessPtyOptions) -> Task l | iTask l & TC r & TC w
/**
* Connect to an external system using TCP. This task's value becomes stable when the connection is closed
* @param Hostname
......
......@@ -10,6 +10,7 @@ import iTasks.Internal.TaskEval
import iTasks.Internal.TaskServer
import iTasks.Internal.Generic.Visualization
import System.Process
import Text, Text.JSON, StdString, StdInt
import qualified Data.Map as DM
......@@ -29,11 +30,11 @@ import qualified Data.Map as DM
, onExit :: !(ExitCode l r -> (!MaybeErrorString l, !Maybe w ))
}
externalProcess :: !FilePath ![String] !(Maybe FilePath) !(RWShared () r w) !Bool !(ExternalProcessHandlers l r w) -> Task l | iTask l & TC r & TC w
externalProcess cmd args dir sds pty handlers = Task eval
externalProcess :: !FilePath ![String] !(Maybe FilePath) !(RWShared () r w) !(ExternalProcessHandlers l r w) !(Maybe ProcessPtyOptions) -> Task l | iTask l & TC r & TC w
externalProcess cmd args dir sds handlers mopts = Task eval
where
eval event evalOpts tree=:(TCInit taskId ts) iworld
= case addExternalProc taskId cmd args dir pty (wrapExternalProcTask handlers sds) iworld of
= case addExternalProc taskId cmd args dir (wrapExternalProcTask handlers sds) mopts iworld of
(Error e, iworld)
= (ExceptionResult e, iworld)
(Ok _, iworld)
......
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