fixed error messages

master
idziubenko 3 years ago
parent 57d53b571f
commit 8ce3cf5c7c

@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
import os
import pwd
import sys
@ -24,7 +22,7 @@ import socket
import time
import urllib.request as urllib2
from urllib.error import URLError
from .function import _print, get_ip_mac_type
from .function import _print, get_ip_mac_type, parse_error
import OpenSSL
import hashlib
from .client_class import HTTPSClientCertTransport
@ -117,7 +115,7 @@ def new_key_req(key, cert_path, server_host_name, private_key_passwd=None,
try:
pwdObj = pwd.getpwnam(user_name)
except KeyError as e:
_print(e)
_print(parse_error(e))
return None
os.chown(key, pwdObj.pw_uid, pwdObj.pw_gid)
os.chmod(key, 0o600)
@ -132,7 +130,7 @@ def delete_old_cert(client):
os.unlink(client.PKEY_FILE)
os.unlink(client.PubKEY_FILE)
except OSError as e:
_print(e)
_print(parse_error(e))
def client_post_request(cert_path, args):
@ -260,13 +258,13 @@ def client_get_cert(cert_path, args):
try:
os.unlink(cert_path + 'req_id')
except OSError as e:
_print(e)
_print(parse_error(e))
print(_('Certificate saved. Your certificate ID: %s') % req_id)
user_name = pwd.getpwuid(os.getuid()).pw_name
try:
pwdObj = pwd.getpwnam(user_name)
except KeyError as e:
_print(e)
_print(parse_error(e))
return None
os.chown(cert_file, pwdObj.pw_uid, pwdObj.pw_gid)
os.chmod(cert_file, 0o600)
@ -401,7 +399,7 @@ def create_socket(file_path, username):
try:
os.unlink(file_path)
except OSError as e:
_print(e)
_print(parse_error(e))
cmd = ['cl-consoled']
# print cmd

@ -14,13 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
import os
import re
import sys
import OpenSSL
from .function import _print
from .function import _print, parse_error
from calculate.core.datavars import DataVarsCore
from calculate.lib.utils.files import readFile
@ -263,7 +261,7 @@ def rm_ca_from_trusted(ca_cert):
try:
os.unlink(filename)
except OSError as e:
_print(e)
_print(parse_error(e))
else:
newfile += (line + '\n')
else:

@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
from calculate.core.server.local_call import Display, Methods, has_force_arg
from calculate.lib.utils.tools import unpack_single_opts
@ -43,7 +41,7 @@ from calculate.core.datavars import DataVarsCore
from .client_class import HTTPSClientCertTransport
from .methods_func import call_method, get_method_argparser, parse, get_view
from .function import (MessageReceiver, MessageDispatcher, clear, _print,
get_view_params)
get_view_params, parse_error)
from calculate.lib.utils.files import makeDirectory, readLinesFile
from calculate.lib.cl_lang import setLocalTranslate
@ -310,7 +308,7 @@ def https_server(client, args, unknown_args, url, clVarsCore, wait_thread):
mr.analysis(method_result)
# analysis(client, client.sid, method_result)
except URLError as e:
_print(e)
_print(parse_error(e))
except KeyboardInterrupt:
try:
print()
@ -327,7 +325,7 @@ def https_server(client, args, unknown_args, url, clVarsCore, wait_thread):
print(_("Failed to terminate the process"))
mr.analysis(method_result)
except Exception as e:
_print(e)
_print(parse_error(e))
try:
mess = method_result[0][0]

@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import time
import os
import sys
@ -37,6 +36,10 @@ setLocalTranslate('cl_console3', sys.modules[__name__])
def _print(*args):
print(" ".join(map(str, args)))
def parse_error(e):
if hasattr(e, "message"):
return e.message
return e
# get list of certificate and session id
@ -50,7 +53,7 @@ def clear():
try:
os.unlink(filename)
except OSError as e:
_print(e)
_print(parse_error(e))
except Exception:
print(_("Failed to clear the cache! "))
return 1
@ -338,3 +341,5 @@ class MessageDispatcher(object):
def ask_password(self, message):
answer = self.methods.askPassword(message.message, message.id == 2)
self.parent.send_message(answer)

@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# from __future__ import print_function
# from __future__ import absolute_import
import argparse
import sys
from calculate.core.server.api_types import ViewInfoAdapter

@ -13,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from .function import _print
import sys

@ -13,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import os
import sys
@ -60,7 +59,7 @@ def client_session_info(client, sid=None):
and e[1] == 'Forbidden':
print(_("Access forbidden!"))
else:
print(e)
_print(parseError(e))
return 1
@ -74,7 +73,7 @@ def client_session_list(client):
and e[1] == 'Forbidden':
print(_("Access forbidden!"))
else:
print(e)
_print(parseError(e))
return 1
if hasattr(res, 'string'):
if res.string:
@ -98,7 +97,7 @@ def session_clean(client):
and e[1] == 'Forbidden':
print(_("Access forbidden!"))
else:
print(e)
_print(parseError(e))
class SessionId():

Loading…
Cancel
Save