|
|
|
@ -15,8 +15,9 @@
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
from calculate.console.application.function import _print
|
|
|
|
|
|
|
|
|
|
from calculate.console.application.sid_func import get_sid
|
|
|
|
|
import sys
|
|
|
|
|
import datetime
|
|
|
|
|
from calculate.lib.utils.tools import classificate
|
|
|
|
|
|
|
|
|
|
_ = lambda x: x
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
@ -25,10 +26,14 @@ setLocalTranslate('cl_console3', sys.modules[__name__])
|
|
|
|
|
client_types = "console"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pid_inf(client, sid, pids):
|
|
|
|
|
def pid_inf(client, sid, pids, wait_thread=None):
|
|
|
|
|
""" get and show information about process """
|
|
|
|
|
for pid in pids:
|
|
|
|
|
for mark, pid in classificate(pids):
|
|
|
|
|
s = client.service.pid_info(sid, pid)
|
|
|
|
|
if wait_thread:
|
|
|
|
|
wait_thread.stop()
|
|
|
|
|
sys.stdout.write("\b")
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
if s == "":
|
|
|
|
|
print _("PID not found")
|
|
|
|
|
return 1
|
|
|
|
@ -36,21 +41,24 @@ def pid_inf(client, sid, pids):
|
|
|
|
|
print _("Permission denied")
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
_print('\n', _(u"Process name: %s") % s[0][4])
|
|
|
|
|
print _(u"Process ID: %s") % s[0][0]
|
|
|
|
|
_print(_(u"%s: process started") % s[0][2])
|
|
|
|
|
_print(_(u"Process name: %s") % s[0][4])
|
|
|
|
|
print _(u"ID: %s") % s[0][0]
|
|
|
|
|
_print(_(u"Start time: %s") % s[0][2].partition(".")[0])
|
|
|
|
|
if s[0][1] == '1':
|
|
|
|
|
print _(u"Process active")
|
|
|
|
|
status = _(u"Active")
|
|
|
|
|
elif s[0][1] == '0':
|
|
|
|
|
print _(u"Process completed")
|
|
|
|
|
status = _(u"Completed")
|
|
|
|
|
else:
|
|
|
|
|
print _(u"Process killed")
|
|
|
|
|
status = _(u"Killed")
|
|
|
|
|
print _(u"Status: %s") % status
|
|
|
|
|
if not mark.last:
|
|
|
|
|
print
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def client_list_pid(client):
|
|
|
|
|
""" get all process id for this session """
|
|
|
|
|
sid = get_sid(client.SID_FILE)
|
|
|
|
|
sid = client.get_sid()
|
|
|
|
|
|
|
|
|
|
red = '\033[31m * \033[0m'
|
|
|
|
|
green = '\033[32m * \033[0m'
|
|
|
|
@ -70,7 +78,7 @@ def client_list_pid(client):
|
|
|
|
|
|
|
|
|
|
def gen_pid_ls(client):
|
|
|
|
|
""" generation list with pid for this session """
|
|
|
|
|
sid = get_sid(client.SID_FILE)
|
|
|
|
|
sid = client.get_sid()
|
|
|
|
|
pid_ls = []
|
|
|
|
|
try:
|
|
|
|
|
list_pid = client.service.list_pid(sid=sid)
|
|
|
|
@ -86,20 +94,18 @@ def gen_pid_ls(client):
|
|
|
|
|
return pid_ls
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def client_pid_info(client):
|
|
|
|
|
def client_pid_info(client, wait_thread=None):
|
|
|
|
|
""" get information about selected process (or about all) """
|
|
|
|
|
# try:
|
|
|
|
|
sid = get_sid(client.SID_FILE)
|
|
|
|
|
sid = client.get_sid()
|
|
|
|
|
pid_ls = gen_pid_ls(client)
|
|
|
|
|
if wait_thread:
|
|
|
|
|
wait_thread.stop()
|
|
|
|
|
sys.stdout.write("\b")
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
if pid_ls:
|
|
|
|
|
pid_inf(client, sid, pid_ls)
|
|
|
|
|
pid_inf(client, sid, pid_ls, wait_thread=wait_thread)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# except:
|
|
|
|
|
# print _("Error get data")
|
|
|
|
|
# return 1
|
|
|
|
|
# return 0
|
|
|
|
|
|
|
|
|
|
def client_list_methods(client):
|
|
|
|
|
""" get & show all available methods for this certificate """
|
|
|
|
|
DAT = 0 # Access to data soap structure
|
|
|
|
@ -131,7 +137,7 @@ def client_list_methods(client):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def client_pid_kill(client, pid):
|
|
|
|
|
sid = get_sid(client.SID_FILE)
|
|
|
|
|
sid = client.get_sid()
|
|
|
|
|
|
|
|
|
|
result = client.service.pid_kill(pid, sid)
|
|
|
|
|
if result == 0:
|
|
|
|
|