Skip to content

Commit

Permalink
include engine evaluator as a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 2, 2014
1 parent 28f3764 commit e5a9abb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "submodules/boardcreator"]
path = submodules/boardcreator
url = https://github.com/clarkerubber/board-creator
[submodule "submodules/evaluator"]
path = submodules/evaluator
url = https://github.com/clarkerubber/engine-evaluator
4 changes: 2 additions & 2 deletions modules/evaluation/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ final class Env(
system: ActorSystem) {

private val CollectionEvaluation = config getString "collection.evaluation"
private val EvaluatorScriptPath = config getString "evaluator.script_path"
private val EvaluatorExecPath = config getString "evaluator.exec_path"
private val ActorName = config getString "actor.name"
private val ApiToken = config getString "api.token"
private val ApiUrl = config getString "api.url"

lazy val evaluator = new Evaluator(
coll = db(CollectionEvaluation),
script = EvaluatorScriptPath,
execPath = EvaluatorExecPath,
reporter = hub.actor.report,
analyser = hub.actor.analyser,
marker = hub.actor.mod,
Expand Down
11 changes: 6 additions & 5 deletions modules/evaluation/src/main/Evaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import lila.user.{ User, UserRepo, Perfs }

final class Evaluator(
coll: Coll,
script: String,
execPath: String,
reporter: ActorSelection,
analyser: ActorSelection,
marker: ActorSelection,
Expand Down Expand Up @@ -116,12 +116,13 @@ final class Evaluator(
}

private def run(userId: String, deep: Boolean): Try[String] = {
val command = s"""$script $userId ${deep.fold("true", "false")} $token $apiUrl/"""
import scala.sys.process._
import java.io.File
val exec = Process(Seq("php", "engine-evaluator.php", userId, deep.fold("true", "false"), token, s"$apiUrl/"), new File(execPath))
Try {
import scala.sys.process._
command.!!
exec.!!
} match {
case Failure(e) => Failure(new Exception(s"$command $e"))
case Failure(e) => Failure(new Exception(s"$exec $e"))
case x => x
}
}
Expand Down
1 change: 1 addition & 0 deletions submodules/evaluator
Submodule evaluator added at 1efb18

0 comments on commit e5a9abb

Please sign in to comment.