-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,12 @@ | |
# Copyright: (c) <[email protected]> | ||
# Released under the AGPL-3.0 License. | ||
from django_redis import get_redis_connection | ||
from libs.utils import human_seconds_time | ||
from libs.ssh import SSH | ||
import threading | ||
import socket | ||
import json | ||
import time | ||
|
||
|
||
def exec_worker_handler(job): | ||
|
@@ -51,12 +53,15 @@ def run(self): | |
if not self.token: | ||
with self.ssh: | ||
return self.ssh.exec_command(self.command, self.env) | ||
flag = time.time() | ||
self.send('\r\n\x1b[36m### Executing ...\x1b[0m\r\n') | ||
code = -1 | ||
try: | ||
with self.ssh: | ||
for code, out in self.ssh.exec_command_with_stream(self.command, self.env): | ||
self.send(out) | ||
human_time = human_seconds_time(time.time() - flag) | ||
self.send(f'\r\n\x1b[36m** 执行结束,总耗时:{human_time} **\x1b[0m') | ||
except socket.timeout: | ||
code = 130 | ||
self.send('\r\n\x1b[31m### Time out\x1b[0m') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters