Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b8c02ccc authored by Bruno Guillaume's avatar Bruno Guillaume
Browse files

version 1.9.1 (ocaml)

parent 1ecb124d
No related branches found
No related tags found
No related merge requests found
1.9.0 1.9.1
...@@ -24,13 +24,29 @@ let json_error msg = ...@@ -24,13 +24,29 @@ let json_error msg =
(* ==================================================================================================== *) (* ==================================================================================================== *)
let run_command request = let run_command request =
let config = !Global.config in
let _ = Debug.log "run request >>>>%s<<<<" request in let _ = Debug.log "run request >>>>%s<<<<" request in
try try
let json = Yojson.Basic.from_string request in let json = Yojson.Basic.from_string request in
match json |> member "command" |> to_string_option with match json |> member "command" |> to_string_option with
| None -> failwith "no 'command' in request" | None -> failwith "no 'command' in request"
(* ======================= load_graph ======================= *) (* ======================= set_config ======================= *)
| Some "set_config" ->
begin
match json |> member "config" |> to_string_option with
| Some c ->
begin
try
Global.config := Conllx_config.build c;
Yojson.Basic.to_string (`Assoc [("status", `String "OK"); ("data", `Null)])
with Conllx_error js ->
Yojson.Basic.to_string (`Assoc [("status", `String "ERROR"); ("message", js)])
end
| None -> json_error "no 'config' in 'set_config' command"
end
(* ======================= load_graph ======================= *)
| Some "load_graph" -> | Some "load_graph" ->
begin begin
match json |> member "filename" |> to_string_option with match json |> member "filename" |> to_string_option with
...@@ -38,7 +54,7 @@ let run_command request = ...@@ -38,7 +54,7 @@ let run_command request =
let graph = Graph.load ~config filename in let graph = Graph.load ~config filename in
let data = Graph.to_json_python ~config graph in let data = Graph.to_json_python ~config graph in
Yojson.Basic.to_string (`Assoc [("status", `String "OK"); ("data", data)]) Yojson.Basic.to_string (`Assoc [("status", `String "OK"); ("data", data)])
| None -> json_error "no 'filename' in 'load_grs' command" | None -> json_error "no 'filename' in 'load_graph' command"
end end
(* ======================= save_graph ======================= *) (* ======================= save_graph ======================= *)
......
...@@ -5,7 +5,6 @@ open Libgrew ...@@ -5,7 +5,6 @@ open Libgrew
module Int_map = Map.Make (struct type t=int let compare=Stdlib.compare end) module Int_map = Map.Make (struct type t=int let compare=Stdlib.compare end)
let config = Conllx_config.build "ud"
exception Error of string exception Error of string
...@@ -38,6 +37,9 @@ end ...@@ -38,6 +37,9 @@ end
(* ==================================================================================================== *) (* ==================================================================================================== *)
module Global = struct module Global = struct
let config = ref (Conllx_config.build "ud")
let debug = ref false let debug = ref false
let (caller_pid: string option ref) = ref None let (caller_pid: string option ref) = ref None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment