<commit_before>module Main where

import System.IO
import System.Process
import System.Exit

-- copy all *.mpl files to the server
-- upload files to server, build there, move archive?


-- the "-b -" option tells sftp to read commands from stdin
sftp, ssh, user, serv :: String
sftp = "sftp"
ssh  = "ssh"
user = "ppaml"
serv = "quarry.uits.indiana.edu"


sftpCommands :: [String]
sftpCommands = [
  "pwd",
  "mkdir maple",
  "cd maple",
  "put ../mochastic/Language/Hakaru/*.mpl .",
  "put update-archive.mpl ."
  ]

sshCommands :: [String]
sshCommands = [
  "cd maple",
  "maple update-archive.mpl",
  "rm *.mpl",
  "pwd",
  "ls"
  ]


run :: String -> [String] -> IO String
run prog commands = do
  let p = proc prog [user ++ "@" ++ serv]
  (Just inH, Just outH, Nothing, p') <- createProcess p { std_in = CreatePipe, std_out = CreatePipe, close_fds = True }
  mapM (hPutStrLn inH) commands
  hClose inH
  c <- hGetContents outH
  length c `seq` hClose outH
  exit <- waitForProcess p'
  case exit of
    ExitSuccess -> return $ c
    _ -> error (prog ++ ":" ++ show exit)


main :: IO ()
main = do
  result <- run sftp sftpCommands
  putStrLn result
  result <- run ssh sshCommands
  putStrLn result
<commit_msg>update maple using git pull instead of sftp<commit_after>module Main where

import System.IO
import System.Process
import System.Exit

-- copy all *.mpl files to the server
-- upload files to server, build there, move archive?


-- the "-b -" option tells sftp to read commands from stdin
ssh, user, serv :: String
ssh  = "ssh"
user = "ppaml"
serv = "quarry.uits.indiana.edu"


sshCommands :: [String]
sshCommands = [
  "cd ppaml",
  "pwd",
  "git pull",
  "cd mochastic/maple",
  "pwd",
  "maple update-archive.mpl",
  "ls -l ppaml.mla"
  ]


run :: String -> [String] -> IO String
run prog commands = do
  let p = proc prog [user ++ "@" ++ serv]
  (Just inH, Just outH, Nothing, p') <- createProcess p { std_in = CreatePipe, std_out = CreatePipe, close_fds = True }
  mapM (hPutStrLn inH) commands
  hClose inH
  c <- hGetContents outH
  length c `seq` hClose outH
  exit <- waitForProcess p'
  case exit of
    ExitSuccess -> return $ c
    _ -> error (prog ++ ":" ++ show exit)


main :: IO ()
main = do
  result <- run ssh sshCommands
  putStrLn result

{'fraction_non_alphanumeric': 0.1310466138962181, 'fraction_numerical': 0.0, 'mean_word_length': 3.128856624319419, 'pattern_counts': {'":': 2, '<': 12, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5483426', 'n_tokens_mistral': 859, 'n_tokens_neox': 802, 'n_words': 275}