diff --git a/views/routine_list.nim b/views/routine_list.nim
index 7771f3d..af18d4b 100644
--- a/views/routine_list.nim
+++ b/views/routine_list.nim
@@ -4,7 +4,9 @@ EZ-Bkup is released under the General Public License 3.0.
See COPYING or for details.]#
import owlkettle
-import std/osproc
+import std/osproc, std/os
+#import asynctools
+#import threadpool
import edit_routine_dialog
import "../models/routine", "../shared"
@@ -12,9 +14,19 @@ viewable RoutineList:
## Displays a list of routines
routineModel: RoutineModel ## Model of all routines
runStatus: string
+ rsyncRun: tuple[output: string, exitCode: int]
proc changed(state: bool)
+var thread: Thread[RoutineListState]
+#var rsyncRun: tuple[output: string, exitCode: int]
+
+proc rsyncThread(list: RoutineListState, rsyncCommand: string) {.thread.} =
+ while true:
+ list.rsyncRun = execCmdEx(rsyncCommand)
+ list.redrawFromThread()
+ sleep(1000)
+
method view(list: RoutineListState): Widget {.locks: "unknown".} =
result = gui:
ScrolledWindow:
@@ -138,7 +150,7 @@ method view(list: RoutineListState): Widget {.locks: "unknown".} =
useMarkup = true
proc clicked() =
list.runStatus = "Running Bkup..."
- var rsyncRun: tuple[output: string, exitCode: int]
+ #var rsyncRun: tuple[output: string, exitCode: int]
var rsyncErrors: seq[string]
var routineRunCount = 0
for routine in list.routineModel.routineSeq():
@@ -151,18 +163,29 @@ method view(list: RoutineListState): Widget {.locks: "unknown".} =
for destination in routine.destinations:
list.runStatus = "Bkup " & source & " to " & destination & "..."
#try without requiring superuser privs by default.
- rsyncRun = execCmdEx("rsync -aq " & source & " " & destination)
- if rsyncRun.exitCode != 0:
+ #rsyncRun = execCmdEx("rsync -aq " & source & " " & destination)
+ let rsyncRunCmd = "rsync -aq " & source & " " & destination
+ #let rsyncThreadProcCall = rsyncThread(rsyncRunCmd)
+ createThread(thread, rsyncThread(list, rsyncRunCmd), list)
+ #createThread(thread, rsyncThreadProcCall, list)
+ #rsyncRun = spawn execCmdEx("rsync -aq " & source & " " & destination)
+ #sync()
+ #rsyncRun = await asynctools.execProcess("rsync -aq " & source & " " & destination)
+ if list.rsyncRun.exitCode != 0:
#handle permission denied error.
- if rsyncRun.exitCode == 23:
+ if list.rsyncRun.exitCode == 23:
let rsyncRunCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -aq " & source & " " & destination
- rsyncRun = execCmdEx(rsyncRunCmd)
- if rsyncRun.exitCode != 0:
+ #rsyncRun = execCmdEx(rsyncRunCmd)
+ #rsyncRun = spawn execCmdEx(rsyncRunCmd)
+ #sync()
+ createThread(thread, rsyncThread(rsyncRunCmd), list)
+ #rsyncRun = await asynctools.execProcess(rsyncRunCmd)
+ if list.rsyncRun.exitCode != 0:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
else:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
#makes the "Bkup Complete" msg below wait on the rsyncRun to finish.
- if rsyncRun.exitCode == 1 or rsyncRun.exitCode == 0:
+ if list.rsyncRun.exitCode == 1 or list.rsyncRun.exitCode == 0:
if rsyncErrors.len > 0:
list.runStatus = "Error! Please see the log at ~/.ez-bkup/errors.log"
for err in rsyncErrors: