Commit 1b627f53 authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[Core] enh: add app execution directory

parent 414b2f9b
Pipeline #413 failed with stage
in 4 minutes and 11 seconds
......@@ -35,7 +35,7 @@ import org.openmole.core.pluginmanager.PluginManager
import org.openmole.core.preference.Preference
import org.openmole.core.replication.ReplicaCatalog
import org.openmole.core.threadprovider.ThreadProvider
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.core.workspace.{ TmpDirectory, Workspace }
import org.openmole.core.services._
import org.openmole.tool.crypto.Cypher
import org.openmole.tool.random.{ RandomProvider, Seeder }
......@@ -99,7 +99,7 @@ class Command(val console: ScalaREPL, val variables: ConsoleVariables) { command
} println(s"${error.level.toString}: ${exceptionToString(error.exception)}")
}
def verify(mole: Mole)(implicit newFile: NewFile, fileService: FileService): Unit = Validation(mole).foreach(println)
def verify(mole: Mole)(implicit newFile: TmpDirectory, fileService: FileService): Unit = Validation(mole).foreach(println)
def encrypted(implicit cypher: Cypher): String = encrypt(Console.askPassword())
......@@ -129,7 +129,7 @@ class Command(val console: ScalaREPL, val variables: ConsoleVariables) { command
case x throw new UserBadDataError("The result is not a puzzle")
}
def modules(urls: OptionalArgument[Seq[String]] = None)(implicit preference: Preference, randomProvider: RandomProvider, newFile: NewFile, fileService: FileService): Unit = {
def modules(urls: OptionalArgument[Seq[String]] = None)(implicit preference: Preference, randomProvider: RandomProvider, newFile: TmpDirectory, fileService: FileService): Unit = {
val installedBundles = PluginManager.bundleHashes.map(_.toString).toSet
def installed(components: Seq[String]) = (components.toSet -- installedBundles).isEmpty
......@@ -143,8 +143,8 @@ class Command(val console: ScalaREPL, val variables: ConsoleVariables) { command
}.sorted.foreach(println)
}
def install(name: String*)(implicit preference: Preference, randomProvider: RandomProvider, newFile: NewFile, workspace: Workspace, fileService: FileService): Unit = install(name)
def install(names: Seq[String], urls: OptionalArgument[Seq[String]] = None)(implicit preference: Preference, randomProvider: RandomProvider, newFile: NewFile, workspace: Workspace, fileService: FileService): Unit = {
def install(name: String*)(implicit preference: Preference, randomProvider: RandomProvider, newFile: TmpDirectory, workspace: Workspace, fileService: FileService): Unit = install(name)
def install(names: Seq[String], urls: OptionalArgument[Seq[String]] = None)(implicit preference: Preference, randomProvider: RandomProvider, newFile: TmpDirectory, workspace: Workspace, fileService: FileService): Unit = {
val toInstall = urls.getOrElse(module.indexes).flatMap(url module.selectableModules(url)).filter(sm names.contains(sm.module.name))
if (toInstall.isEmpty) println("The module(s) is/are already installed.")
else
......
......@@ -27,7 +27,7 @@ import org.openmole.tool.crypto.Cypher
import org.openmole.tool.logger.JavaLogger
import org.openmole.core.services._
import org.openmole.core.workflow.mole._
import org.openmole.core.workspace.NewFile
import org.openmole.core.workspace.TmpDirectory
import org.openmole.core.dsl._
import scala.annotation.tailrec
......@@ -121,13 +121,13 @@ class Console(script: Option[String] = None) {
println("File " + scriptFile + " doesn't exist.")
ExitCodes.scriptDoesNotExist
case e: CompilationError
newFile.directory.recursiveDelete
tmpDirectory.directory.recursiveDelete
println(e.error.stackString)
ExitCodes.compilationError
case compiled: Compiled
Try(compiled.eval) match {
case Success(res)
val moleServices = MoleServices.create()
val moleServices = MoleServices.create(applicationExecutionDirectory = services.tmpDirectory.directory)
val ex = dslToPuzzle(res).toExecution()(moleServices)
Try(ex.run) match {
case Failure(e)
......@@ -137,7 +137,7 @@ class Console(script: Option[String] = None) {
ExitCodes.ok
}
case Failure(e)
newFile.directory.recursiveDelete
tmpDirectory.directory.recursiveDelete
println(s"Error during script evaluation: ")
print(e.stackString)
ExitCodes.compilationError
......@@ -147,7 +147,7 @@ class Console(script: Option[String] = None) {
}
}
def withREPL[T](args: ConsoleVariables)(f: ScalaREPL T)(implicit newFile: NewFile, fileService: FileService) = {
def withREPL[T](args: ConsoleVariables)(f: ScalaREPL T)(implicit newFile: TmpDirectory, fileService: FileService) = {
val loop =
OpenMOLEREPL.newREPL(
args,
......
......@@ -26,7 +26,7 @@ import org.openmole.core.pluginmanager.PluginManager
import org.openmole.core.workflow.task.TaskExecutionContext
import org.openmole.tool.logger.{ JavaLogger, LoggerService }
import org.openmole.core.tools.service.Retry
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.core.workspace.{ TmpDirectory, Workspace }
import org.openmole.core.tools.service._
import org.openmole.core.workflow.execution._
import org.openmole.core.communication.message._
......@@ -64,7 +64,7 @@ class Runtime {
outputMessagePath: String,
threads: Int,
debug: Boolean
)(implicit serializerService: SerializerService, newFile: NewFile, fileService: FileService, preference: Preference, threadProvider: ThreadProvider, eventDispatcher: EventDispatcher, workspace: Workspace, loggerService: LoggerService) = {
)(implicit serializerService: SerializerService, newFile: TmpDirectory, fileService: FileService, preference: Preference, threadProvider: ThreadProvider, eventDispatcher: EventDispatcher, workspace: Workspace, loggerService: LoggerService) = {
/*--- get execution message and job for runtime---*/
val usedFiles = new HashMap[String, File]
......@@ -148,6 +148,7 @@ class Runtime {
try {
val taskExecutionContext = TaskExecutionContext(
applicationExecutionDirectory = newFile.makeNewDir("application"),
moleExecutionDirectory = newFile.makeNewDir("runtime"),
taskExecutionDirectory = newFile.makeNewDir("task"),
localEnvironment = environment,
......
......@@ -31,7 +31,7 @@ import org.openmole.core.event.EventDispatcher
import org.openmole.core.fileservice.FileService
import org.openmole.core.preference.Preference
import org.openmole.core.threadprovider.ThreadProvider
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.core.workspace.{ TmpDirectory, Workspace }
object SimExplorer extends JavaLogger {
......@@ -87,7 +87,7 @@ object SimExplorer extends JavaLogger {
if (config.debug) LoggerConfig.level(Level.FINEST)
implicit val workspace = Workspace(new File(config.workspace.get).getCanonicalFile)
implicit val newFile = NewFile(workspace)
implicit val newFile = TmpDirectory(workspace)
implicit val serializerService = SerializerService()
implicit val preference = Preference.memory()
implicit val threadProvider = ThreadProvider(config.nbThread.get + 5)
......
......@@ -28,7 +28,7 @@ import org.openmole.core.console.ScalaREPL
import org.openmole.core.exception.UserBadDataError
import org.openmole.core.logconfig.LoggerConfig
import org.openmole.core.pluginmanager.PluginManager
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.core.workspace.{ TmpDirectory, Workspace }
import org.openmole.rest.server.RESTServer
import org.openmole.tool.logger.JavaLogger
......
......@@ -30,7 +30,7 @@ object Test {
implicit val ws = Workspace(workspace)
implicit val cypher = Cypher(password)
implicit val preference = Services.preference(ws)
implicit val newFile = NewFile(workspace)
implicit val newFile = TmpDirectory(workspace)
implicit val seeder = Seeder()
implicit val serializerService = SerializerService()
implicit val threadProvider = ThreadProvider()
......
......@@ -34,9 +34,9 @@ trait CodePackage extends FilePackage with StatisticsPackage with MathPackage {
def newRandom(seed: Long): java.util.Random = Random(seed)
def newRandom()(implicit randomProvider: RandomProvider): java.util.Random = Random()
def newFile(prefix: String = Workspace.fixedPrefix, suffix: String = Workspace.fixedPostfix)(implicit newFile: NewFile) = newFile.newFile(prefix, suffix)
def newDir(prefix: String = Workspace.fixedDir)(implicit newFile: NewFile) = newFile.newDir(prefix)
def mkDir(prefix: String = Workspace.fixedDir)(implicit newFile: NewFile) = {
def newFile(prefix: String = Workspace.fixedPrefix, suffix: String = Workspace.fixedPostfix)(implicit newFile: TmpDirectory) = newFile.newFile(prefix, suffix)
def newDir(prefix: String = Workspace.fixedDir)(implicit newFile: TmpDirectory) = newFile.newDir(prefix)
def mkDir(prefix: String = Workspace.fixedDir)(implicit newFile: TmpDirectory) = {
val dir = newFile.newDir(prefix)
dir.mkdirs
dir
......
......@@ -27,7 +27,7 @@ import org.openmole.core.workflow.execution.Environment.RuntimeLog
import org.openmole.core.workflow.job.MoleJob._
import org.openmole.core.workflow.job._
import org.openmole.core.workflow.task.Task
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.core.workspace.{ TmpDirectory, Workspace }
import util.Try
import org.openmole.tool.file._
......@@ -50,7 +50,7 @@ package object message {
case class FileMessage(path: String, hash: String)
object ReplicatedFile {
def download(replicatedFile: ReplicatedFile)(download: (String, File) Unit, verifyHash: Boolean = false)(implicit newFile: NewFile, fileService: FileService) = {
def download(replicatedFile: ReplicatedFile)(download: (String, File) Unit, verifyHash: Boolean = false)(implicit newFile: TmpDirectory, fileService: FileService) = {
val localDirectory = newFile.makeNewDir("replica")
try {
def verify(cache: File) =
......@@ -90,7 +90,7 @@ package object message {
finally fileService.deleteWhenEmpty(localDirectory)
}
def upload(file: File, upload: File String)(implicit newFile: NewFile) = {
def upload(file: File, upload: File String)(implicit newFile: TmpDirectory) = {
val isDir = file.isDirectory
val toReplicate =
......@@ -113,7 +113,7 @@ package object message {
case class RuntimeSettings(archiveResult: Boolean)
object ExecutionMessage {
def load(file: File)(implicit serialiserService: SerializerService, fileService: FileService, newFile: NewFile) = {
def load(file: File)(implicit serialiserService: SerializerService, fileService: FileService, newFile: TmpDirectory) = {
serialiserService.deserializeAndExtractFiles[ExecutionMessage](file)
}
}
......@@ -121,7 +121,7 @@ package object message {
case class ExecutionMessage(plugins: Iterable[ReplicatedFile], files: Iterable[ReplicatedFile], jobs: File, runtimeSettings: RuntimeSettings)
object RuntimeResult {
def load(file: File)(implicit serialiserService: SerializerService, fileService: FileService, newFile: NewFile) =
def load(file: File)(implicit serialiserService: SerializerService, fileService: FileService, newFile: TmpDirectory) =
serialiserService.deserializeAndExtractFiles[RuntimeResult](file)
}
......
......@@ -19,10 +19,10 @@ package org.openmole.core.communication.storage
import java.io.File
import org.openmole.core.workspace.NewFile
import org.openmole.core.workspace.TmpDirectory
trait RemoteStorage {
def upload(src: File, dest: Option[String], options: TransferOptions = TransferOptions.default)(implicit newFile: NewFile): String
def download(src: String, dest: File, options: TransferOptions = TransferOptions.default)(implicit newFile: NewFile): Unit
def upload(src: File, dest: Option[String], options: TransferOptions = TransferOptions.default)(implicit newFile: TmpDirectory): String
def download(src: String, dest: File, options: TransferOptions = TransferOptions.default)(implicit newFile: TmpDirectory): Unit
}
......@@ -35,7 +35,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.tools.nsc.interpreter._
import monocle.macros._
import org.openmole.core.fileservice.FileService
import org.openmole.core.workspace.NewFile
import org.openmole.core.workspace.TmpDirectory
import scala.tools.nsc.io.AbstractFile
import org.openmole.tool.osgi._
......@@ -45,7 +45,7 @@ import scala.tools.nsc
object ScalaREPL {
def apply(priorityBundles: Seq[Bundle] = Nil, jars: Seq[JFile] = Seq.empty, quiet: Boolean = true)(implicit newFile: NewFile, fileService: FileService) = {
def apply(priorityBundles: Seq[Bundle] = Nil, jars: Seq[JFile] = Seq.empty, quiet: Boolean = true)(implicit newFile: TmpDirectory, fileService: FileService) = {
val classDirectory = newFile.newDir("classDirectory")
fileService.deleteWhenGarbageCollected(classDirectory)
new ScalaREPL(priorityBundles, jars, quiet, classDirectory)
......@@ -288,7 +288,7 @@ class ScalaREPL(priorityBundles: ⇒ Seq[Bundle], jars: Seq[JFile], quiet: Boole
object Interpreter {
def apply(priorityBundles: Seq[Bundle] = Nil, jars: Seq[JFile] = Seq.empty, quiet: Boolean = true)(implicit newFile: NewFile, fileService: FileService) = {
def apply(priorityBundles: Seq[Bundle] = Nil, jars: Seq[JFile] = Seq.empty, quiet: Boolean = true)(implicit newFile: TmpDirectory, fileService: FileService) = {
val classDirectory = newFile.newDir("classDirectory")
fileService.deleteWhenGarbageCollected(classDirectory)
new Interpreter(priorityBundles, jars, quiet, classDirectory)
......
......@@ -18,18 +18,18 @@
package org.openmole.core.dsl
import org.openmole.core.serializer.SerializerService
import org.openmole.core.workspace.NewFile
import org.openmole.core.workspace.TmpDirectory
trait Serializer {
def load(file: File)(implicit serialiserService: SerializerService) = serialiserService.deserialize[Object](file)
def loadArchive(file: File)(implicit newFile: NewFile, serialiserService: SerializerService) = serialiserService.deserializeAndExtractFiles[Object](file)
def loadArchive(file: File)(implicit newFile: TmpDirectory, serialiserService: SerializerService) = serialiserService.deserializeAndExtractFiles[Object](file)
def load(file: String)(implicit serialiserService: SerializerService): Object = load(new File(file))
def loadArchive(file: String)(implicit newFile: NewFile, serialiserService: SerializerService): Object = loadArchive(new File(file))
def loadArchive(file: String)(implicit newFile: TmpDirectory, serialiserService: SerializerService): Object = loadArchive(new File(file))
def save(obj: Object, file: File)(implicit serialiserService: SerializerService) = serialiserService.serialize(obj, file)
def saveArchive(obj: Object, file: File)(implicit newFile: NewFile, serialiserService: SerializerService) = serialiserService.serializeAndArchiveFiles(obj, file)
def saveArchive(obj: Object, file: File)(implicit newFile: TmpDirectory, serialiserService: SerializerService) = serialiserService.serializeAndArchiveFiles(obj, file)
def save(obj: Object, file: String)(implicit serialiserService: SerializerService): Unit = save(obj, new File(file))
def saveArchive(obj: Object, file: String)(implicit newFile: NewFile, serialiserService: SerializerService): Unit = saveArchive(obj, new File(file))
def saveArchive(obj: Object, file: String)(implicit newFile: TmpDirectory, serialiserService: SerializerService): Unit = saveArchive(obj, new File(file))
}
......@@ -22,7 +22,7 @@ import java.io.InputStream
import org.openmole.core.context.{ Context, Val }
import org.openmole.core.exception.UserBadDataError
import org.openmole.core.fileservice.FileService
import org.openmole.core.workspace.NewFile
import org.openmole.core.workspace.TmpDirectory
import org.openmole.tool.stream.{ StringInputStream, StringOutputStream }
import org.openmole.tool.random._
......
......@@ -25,7 +25,7 @@ import org.openmole.tool.file._
import cats._
import cats.implicits._
import org.openmole.core.fileservice.FileService
import org.openmole.core.workspace.NewFile
import org.openmole.core.workspace.TmpDirectory
import scala.annotation.tailrec
......@@ -86,7 +86,7 @@ object FromContext extends LowPriorityFromContext {
implicit val monad: Monad[FromContext] = new Monad[FromContext] {
def tailRecM[A, B](a: A)(f: A FromContext[Either[A, B]]): FromContext[B] = {
@tailrec def computeB(a: A, context: Context)(implicit rng: RandomProvider, newFile: NewFile, fileService: FileService): B = {
@tailrec def computeB(a: A, context: Context)(implicit rng: RandomProvider, newFile: TmpDirectory, fileService: FileService): B = {
f(a)(context) match {
case Left(a) computeB(a, context)
case Right(b) b
......@@ -190,8 +190,8 @@ object FromContext extends LowPriorityFromContext {
* @param newFile
* @param fileService
*/
case class Parameters(context: Context, implicit val random: RandomProvider, implicit val newFile: NewFile, implicit val fileService: FileService)
case class ValidationParameters(inputs: Seq[Val[_]], implicit val newFile: NewFile, implicit val fileService: FileService)
case class Parameters(context: Context, implicit val random: RandomProvider, implicit val newFile: TmpDirectory, implicit val fileService: FileService)
case class ValidationParameters(inputs: Seq[Val[_]], implicit val newFile: TmpDirectory, implicit val fileService: FileService)
/**
* Construct a FromContext from a function of [[Parameters]]
......@@ -240,9 +240,9 @@ object FromContext extends LowPriorityFromContext {
}
class FromContext[+T](c: FromContext.Parameters T, v: FromContext.ValidationParameters Seq[Throwable]) {
def apply(context: Context)(implicit rng: RandomProvider, newFile: NewFile, fileService: FileService): T = c(FromContext.Parameters(context, rng, newFile, fileService))
def from(context: Context)(implicit rng: RandomProvider, newFile: NewFile, fileService: FileService): T = apply(context)
def validate(inputs: Seq[Val[_]])(implicit newFile: NewFile, fileService: FileService): Seq[Throwable] = v(FromContext.ValidationParameters(inputs, newFile, fileService))
def apply(context: Context)(implicit rng: RandomProvider, newFile: TmpDirectory, fileService: FileService): T = c(FromContext.Parameters(context, rng, newFile, fileService))
def from(context: Context)(implicit rng: RandomProvider, newFile: TmpDirectory, fileService: FileService): T = apply(context)
def validate(inputs: Seq[Val[_]])(implicit newFile: TmpDirectory, fileService: FileService): Seq[Throwable] = v(FromContext.ValidationParameters(inputs, newFile, fileService))
def validate(v2: FromContext.ValidationParameters Seq[Throwable]) = {
def nv(p: FromContext.ValidationParameters) = v(p) ++ v2(p)
......
......@@ -24,14 +24,14 @@ import org.openmole.core.exception._
import org.openmole.core.fileservice.FileService
import org.openmole.core.pluginmanager._
import org.openmole.core.tools.obj.ClassUtils._
import org.openmole.core.workspace.NewFile
import org.openmole.core.workspace.TmpDirectory
import org.openmole.tool.cache._
import org.openmole.tool.random._
import scala.util._
trait CompilationClosure[+T] extends ScalaCompilation.ContextClosure[T] {
def apply(context: Context, rng: RandomProvider, newFile: NewFile): T
def apply(context: Context, rng: RandomProvider, newFile: TmpDirectory): T
}
/**
......@@ -77,7 +77,7 @@ object ScalaCompilation {
* @tparam RETURN
* @return
*/
def compile[RETURN](code: String, plugins: Seq[File] = Seq.empty, libraries: Seq[File] = Seq.empty)(implicit newFile: NewFile, fileService: FileService) = {
def compile[RETURN](code: String, plugins: Seq[File] = Seq.empty, libraries: Seq[File] = Seq.empty)(implicit newFile: TmpDirectory, fileService: FileService) = {
val osgiMode = org.openmole.core.console.Activator.osgi
val interpreter =
if (osgiMode) Interpreter(priorityBundles(plugins), libraries)
......@@ -113,12 +113,12 @@ object ScalaCompilation {
native getOrElse t
}
def function[RETURN](inputs: Seq[Val[_]], source: String, plugins: Seq[File], libraries: Seq[File], wrapping: OutputWrapping[RETURN], returnType: ValType[_ <: RETURN])(implicit newFile: NewFile, fileService: FileService) = {
def function[RETURN](inputs: Seq[Val[_]], source: String, plugins: Seq[File], libraries: Seq[File], wrapping: OutputWrapping[RETURN], returnType: ValType[_ <: RETURN])(implicit newFile: TmpDirectory, fileService: FileService) = {
val s = script(inputs, source, wrapping, returnType)
compile[CompilationClosure[RETURN]](s, plugins, libraries)
}
def closure[RETURN](inputs: Seq[Val[_]], source: String, plugins: Seq[File], libraries: Seq[File], wrapping: OutputWrapping[RETURN], returnType: ValType[_ <: RETURN])(implicit newFile: NewFile, fileService: FileService) =
def closure[RETURN](inputs: Seq[Val[_]], source: String, plugins: Seq[File], libraries: Seq[File], wrapping: OutputWrapping[RETURN], returnType: ValType[_ <: RETURN])(implicit newFile: TmpDirectory, fileService: FileService) =
function[RETURN](inputs, source, plugins, libraries, wrapping, returnType)
/**
......@@ -145,7 +145,7 @@ object ScalaCompilation {
*/
def script[RETURN](inputs: Seq[Val[_]], source: String, wrapping: OutputWrapping[RETURN], returnType: ValType[_ <: RETURN]) =
s"""new ${classOf[CompilationClosure[_]].getName}[${toScalaNativeType(returnType)}] {
| def apply(${prefix}context: ${manifest[Context].toString}, ${prefix}RNG: ${manifest[RandomProvider].toString}, ${prefix}NewFile: ${manifest[NewFile].toString}) = {
| def apply(${prefix}context: ${manifest[Context].toString}, ${prefix}RNG: ${manifest[RandomProvider].toString}, ${prefix}NewFile: ${manifest[TmpDirectory].toString}) = {
| object $inputObject {
| ${inputs.toSeq.map(i ⇒ s"""var ${i.name} = ${prefix}context("${i.name}").asInstanceOf[${toScalaNativeType(i.`type`)}]""").mkString("; ")}
| }
......@@ -164,7 +164,7 @@ object ScalaCompilation {
wrapping: OutputWrapping[R] = RawOutput(),
libraries: Seq[File] = Seq.empty,
plugins: Seq[File] = Seq.empty
)(implicit m: Manifest[_ <: R], newFile: NewFile, fileService: FileService) =
)(implicit m: Manifest[_ <: R], newFile: TmpDirectory, fileService: FileService) =
closure[R](inputs, code, plugins, libraries, wrapping, ValType(m)).get
def dynamic[R: Manifest](code: String, wrapping: OutputWrapping[R] = RawOutput[R]()) = {
......@@ -174,12 +174,12 @@ object ScalaCompilation {
val cache = Cache(collection.mutable.HashMap[Seq[Val[_]], Try[ContextClosure[R]]]())
def compiled(context: Context)(implicit newFile: NewFile, fileService: FileService): Try[ContextClosure[R]] = {
def compiled(context: Context)(implicit newFile: TmpDirectory, fileService: FileService): Try[ContextClosure[R]] = {
val contextPrototypes = context.toSeq.map { case (_, v) v.prototype }
compiled(contextPrototypes)
}
def compiled(inputs: Seq[Val[_]])(implicit newFile: NewFile, fileService: FileService): Try[ContextClosure[R]] =
def compiled(inputs: Seq[Val[_]])(implicit newFile: TmpDirectory, fileService: FileService): Try[ContextClosure[R]] =
cache().synchronized {
val allInputMap = inputs.groupBy(_.name)
......@@ -197,21 +197,21 @@ object ScalaCompilation {
}
}
def validate(inputs: Seq[Val[_]])(implicit newFile: NewFile, fileService: FileService): Option[Throwable] = {
def validate(inputs: Seq[Val[_]])(implicit newFile: TmpDirectory, fileService: FileService): Option[Throwable] = {
compiled(inputs) match {
case Success(_) None
case Failure(e) Some(e)
}
}
def apply()(implicit newFile: NewFile, fileService: FileService): FromContext[R] = FromContext { p compiled(p.context).get(p.context, p.random, p.newFile) }
def apply()(implicit newFile: TmpDirectory, fileService: FileService): FromContext[R] = FromContext { p compiled(p.context).get(p.context, p.random, p.newFile) }
}
new ScalaWrappedCompilation()
}
type ContextClosure[+R] = (Context, RandomProvider, NewFile) R
type ContextClosure[+R] = (Context, RandomProvider, TmpDirectory) R
trait OutputWrapping[+R] {
def wrapOutput: String
......
......@@ -77,7 +77,7 @@ class FileService(implicit preference: Preference) {
private[fileservice] val deleteEmpty = ListBuffer[File]()
def hashNoCache(file: File, hashType: HashType = SHA1)(implicit newFile: NewFile) = {
def hashNoCache(file: File, hashType: HashType = SHA1)(implicit newFile: TmpDirectory) = {
if (file.isDirectory) newFile.withTmpFile { archive
file.archive(archive, time = false)
hashFile(archive, hashType)
......@@ -85,12 +85,12 @@ class FileService(implicit preference: Preference) {
else hashFile(file, hashType)
}
def hash(file: File)(implicit newFile: NewFile, fileServiceCache: FileServiceCache): Hash = {
def hash(file: File)(implicit newFile: TmpDirectory, fileServiceCache: FileServiceCache): Hash = {
def hash = hashFile(if (file.isDirectory) archiveForDir(file).file else file)
fileServiceCache.hashCache.get(file.getCanonicalPath, hash)
}
def archiveForDir(directory: File)(implicit newFile: NewFile, fileServiceCache: FileServiceCache): FileCache = {
def archiveForDir(directory: File)(implicit newFile: TmpDirectory, fileServiceCache: FileServiceCache): FileCache = {
def archive = {
val ret = newFile.newFile("archive", ".tar")
directory.archive(ret, time = false)
......
......@@ -19,7 +19,7 @@ package org.openmole.core
import java.io.File
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.core.workspace.{ TmpDirectory, Workspace }
import org.openmole.tool.file._
import org.openmole.tool.hash._
import squants.time.Time
......
......@@ -39,10 +39,10 @@ package object market {
import org.json4s.jackson.Serialization
implicit val formats = Serialization.formats(NoTypeHints)
def indexURL(implicit preference: Preference, randomProvider: RandomProvider, newFile: NewFile, fileService: FileService) =
def indexURL(implicit preference: Preference, randomProvider: RandomProvider, newFile: TmpDirectory, fileService: FileService) =
ExpandedString(preference(MarketIndex.marketIndexLocation)).from(Context("version" buildinfo.version))
def marketIndex(implicit preference: Preference, randomProvider: RandomProvider, newFile: NewFile, fileService: FileService) =
def marketIndex(implicit preference: Preference, randomProvider: RandomProvider, newFile: TmpDirectory, fileService: FileService) =
Serialization.read[MarketIndex](http.get(indexURL))
def downloadEntry(entry: MarketIndexEntry, path: File) = try {
......
......@@ -22,7 +22,7 @@ import java.nio.file.FileAlreadyExistsException
import gridscale.http
import org.openmole.core.pluginmanager.PluginManager
import org.openmole.core.workspace.{ NewFile, Workspace }
import org.openmole.core.workspace.{ TmpDirectory, Workspace }
import org.openmole.tool.file._
import org.openmole.tool.stream._
import org.openmole.core.expansion._
......@@ -33,7 +33,7 @@ import org.openmole.tool.random.RandomProvider
package object module {
def indexes(implicit preference: Preference, randomProvider: RandomProvider, newFile: NewFile, fileService: FileService) =
def indexes(implicit preference: Preference, randomProvider: RandomProvider, newFile: TmpDirectory, fileService: FileService) =
preference(ModuleIndex.moduleIndexes).map(ExpandedString(_).from(Context("version" buildinfo.version)))
def pluginDirectory(implicit workspace: Workspace) = workspace.location /> "plugins"
......@@ -51,7 +51,7 @@ package object module {
case class SelectableModule(baseURL: String, module: Module)
def install(modules: Seq[SelectableModule])(implicit newFile: NewFile, workspace: Workspace) = newFile.withTmpDir { dir
def install(modules: Seq[SelectableModule])(implicit newFile: TmpDirectory, workspace: Workspace) = newFile.withTmpDir { dir
case class DownloadableComponent(baseURL: String, component: Component)
val downloadableComponents = modules.flatMap { m m.module.components.map(c DownloadableComponent(m.baseURL, c)) }
val hashes = downloadableComponents.map(_.component.hash).distinct.toSet -- PluginManager.bundleHashes.map(_.toString)
......@@ -67,7 +67,7 @@ package object module {
def components[T](implicit m: Manifest[T]) = PluginManager.pluginsForClass(m.erasure).toSeq
def components(o: Object) = PluginManager.pluginsForClass(o.getClass).toSeq
def addPluginsFiles(files: Seq[File], move: Boolean, directory: File)(implicit workspace: Workspace, newFile: NewFile): Seq[(File, Throwable)] = synchronized {
def addPluginsFiles(files: Seq[File], move: Boolean, directory: File)(implicit workspace: Workspace, newFile: TmpDirectory): Seq[(File, Throwable)] = synchronized {
val destinations = files.map { file file (directory / file.getName) }
destinations.filter(_._2.exists).toList match {
......
......@@ -23,7 +23,7 @@ import org.openmole.core.exception.InternalProcessingError
import org.openmole.core.fileservice.FileService
import org.openmole.core.pluginmanager.PluginInfo
import org.openmole.core.workflow.tools._
import org.openmole.core.workspace.NewFile
import org.openmole.core.workspace.TmpDirectory
object OpenMOLEREPL {
......@@ -54,7 +54,7 @@ object OpenMOLEREPL {
keywordNamespaceCode
)
def newREPL(args: ConsoleVariables, quiet: Boolean = false)(implicit newFile: NewFile, fileService: FileService) = {
def newREPL(args: ConsoleVariables, quiet: Boolean = false)(implicit newFile: TmpDirectory, fileService: FileService) = {
def initialise(loop: ScalaREPL) = {
args.workDirectory.mkdirs()
loop.beQuietDuring {
......
......@@ -28,14 +28,14 @@ import org.openmole.core.fileservice.FileService
import org.openmole.core.project
import org.openmole.core.services._
import org.openmole.core.workflow.composition.DSL