retrait msg d'erreur

This commit is contained in:
bruno 2022-11-10 21:22:25 -05:00
parent 45a6522e2f
commit ede365af7d
1 changed files with 27 additions and 24 deletions

View File

@ -22,7 +22,7 @@ import std/asyncdispatch
import ../../commun/utils # Joplin utils procedures and types import ../../commun/utils # Joplin utils procedures and types
# from os import sleep # from os import sleep
from posix import read, write, fdatasync, close # from posix import read, write, fdatasync, close
# --==--==--==--==--==--==--==--==--==--==-- # # --==--==--==--==--==--==--==--==--==--==-- #
# TYPE : Setup joplin_ping data # TYPE : Setup joplin_ping data
@ -245,8 +245,8 @@ proc get_joplin_notes*(token: string): Future[joplin_notes] {.async.} =
# store json info into an object # store json info into an object
var count: int = 1 var count: int = 1
var epochTime: int # var epochTime: int
var humanTime: Time # var humanTime: Time
for nb in joplin_notes_Json["items"]: for nb in joplin_notes_Json["items"]:
j_notes.id.add(nb["id"].getstr) j_notes.id.add(nb["id"].getstr)
j_notes.parent_id.add(nb["parent_id"].getstr) j_notes.parent_id.add(nb["parent_id"].getstr)
@ -271,8 +271,8 @@ proc get_joplin_note*(token: string, noteid: string): Future[
# Variables # Variables
var j_note: joplin_note var j_note: joplin_note
var has_more: bool = true # var has_more: bool = true
var page: int = 1 # var page: int = 1
var url: string var url: string
var client = newAsyncHttpClient() var client = newAsyncHttpClient()
@ -377,10 +377,10 @@ proc get_joplin_tags*(token: string): Future[joplin_tags] {.async.} =
proc get_joplin_cli_token*(): string = proc get_joplin_cli_token*(): string =
var flagName: string = "" var flagName: string = ""
var flagValue: string = "" var flagValue: string = ""
var result = execCmdEx("joplin config api.token") var resultExec = execCmdEx("joplin config api.token")
if result.exitCode == 0: if resultExec.exitCode == 0:
let param1 = result.output let param1 = resultExec.output
let flagSplit = param1.split(" = ") let flagSplit = param1.split(" = ")
flagName = flagSplit[0] flagName = flagSplit[0]
flagValue = flagSplit[1] flagValue = flagSplit[1]
@ -395,9 +395,9 @@ proc launchProgram(app: string = "", workingPath: string = "", arguments: array[
var p = startProcess(joinPath(workingPath, app), workingPath, arguments) var p = startProcess(joinPath(workingPath, app), workingPath, arguments)
let pid = p.processID() let pid = p.processID()
var outhdl = outputHandle(p) # var outhdl = outputHandle(p)
var inputhdl = inputHandle(p) # var inputhdl = inputHandle(p)
var errhdl = errorHandle(p) # var errhdl = errorHandle(p)
return pid return pid
# --==--==--==--==--==--==--==--==--==--==-- # # --==--==--==--==--==--==--==--==--==--==-- #
@ -422,40 +422,43 @@ proc joplin_cli_stop*(): int {.thread.} =
# --==--==--==--==--==--==--==--==--==--==-- # # --==--==--==--==--==--==--==--==--==--==-- #
proc joplin_cli_status*(): bool = proc joplin_cli_status*(): bool =
var rc = false var rc = false
var result = execCmdEx("joplin server status") var resultExec = execCmdEx("joplin server status")
if result.exitCode == 0: if resultExec.exitCode == 0:
if "Server is not running" in result.output: if "Server is not running" in resultExec.output:
echo "Joplin Terminal cli status is down : ", result.output echo "Joplin Terminal cli status is down : ", resultExec.output
rc = false rc = false
else: else:
echo "Joplin Terminal cli status is up : ", result.output echo "Joplin Terminal cli status is up : ", resultExec.output
rc = true rc = true
else: else:
echo "Error validate joplin terminal status : ", result.output echo "Error validate joplin terminal status : ", resultExec.output
return rc return rc
# --==--==--==--==--==--==--==--==--==--==-- # # --==--==--==--==--==--==--==--==--==--==-- #
# PROC : start or stop Joplin Terminal # PROC : start or stop Joplin Terminal
# --==--==--==--==--==--==--==--==--==--==-- # # --==--==--==--==--==--==--==--==--==--==-- #
proc joplin_cli_start_stop*(): int = proc joplin_cli_start_stop*(): bool =
var isStart: int = 0 var idExec: int = 0
var isStart: bool = false
var sleep_delay_frame: int = 50 var sleep_delay_frame: int = 50
var sleep_max: int = 5000 # var sleep_max: int = 5000
if joplin_cli_status() == false: if joplin_cli_status() == false:
isStart = joplin_cli_start() idExec = joplin_cli_start()
while joplin_cli_status() == false: while joplin_cli_status() == false:
sleep(sleep_delay_frame) sleep(sleep_delay_frame)
echo "Joplin client Terminal started: ", isStart echo "Joplin client Terminal started: ", idExec
isStart = true
else: else:
echo "Joplin client Terminal is alredy started !" echo "Joplin client Terminal is alredy started !"
#if joplin_cli_status() == true: #if joplin_cli_status() == true:
isStart = joplin_cli_stop() idExec = joplin_cli_stop()
while joplin_cli_status() == true: while joplin_cli_status() == true:
sleep(sleep_delay_frame) sleep(sleep_delay_frame)
echo "Joplin client Terminal stopped: ", isStart echo "Joplin client Terminal stopped: ", idExec
isStart = false
return isStart return isStart