From fe04a136c979fbbabebfcee5b31781a7cc2dbd9b Mon Sep 17 00:00:00 2001 From: idziubenko Date: Thu, 1 Jul 2021 11:29:07 +0300 Subject: [PATCH] fixed rsa bugs, fixed show_msg crash, added post-install script for crutch_lib --- libs_crutch/README | 1 - pym/consolegui/application/DisplayMethod.py | 21 ++++++++++--------- pym/consolegui/application/LeftMenu.py | 21 ++++++++++--------- pym/consolegui/application/client_class.py | 2 +- pym/consolegui/application/conf_connection.py | 2 +- pym/consolegui/application/create_cert.py | 4 ++-- setup.py | 15 +++++++++---- 7 files changed, 37 insertions(+), 29 deletions(-) delete mode 100644 libs_crutch/README diff --git a/libs_crutch/README b/libs_crutch/README deleted file mode 100644 index a73fffd..0000000 --- a/libs_crutch/README +++ /dev/null @@ -1 +0,0 @@ -These are placeholder python3 libs for console-gui. These were migrated to py3 in a very shallow way, any functionality not used by console-gui probablys wasn't tested. \ No newline at end of file diff --git a/pym/consolegui/application/DisplayMethod.py b/pym/consolegui/application/DisplayMethod.py index 9325701..0578ec1 100644 --- a/pym/consolegui/application/DisplayMethod.py +++ b/pym/consolegui/application/DisplayMethod.py @@ -274,16 +274,17 @@ class DisplayMethod(qt.QWidget): if type(view) == Exception: - if hasattr (view, 'message'): - view = view.message - - if type(view.message) == tuple: - if view.message[0] == 403: - msg = _('Permission denied') - else: - msg = ' '.join(map(lambda x: str(x), view.message)) - else: - msg = view.message.__str__() + # if hasattr (view, 'message'): + # view = view.message + + # if type(view) == tuple: + # if view.message[0] == 403: + # msg = _('Permission denied') + # else: + # msg = ' '.join(map(lambda x: str(x), view.message)) + # else: + # msg = view.message.__str__() + msg = str(view) show_msg(msg) return 1 diff --git a/pym/consolegui/application/LeftMenu.py b/pym/consolegui/application/LeftMenu.py index 2cd3dbc..fae7c00 100644 --- a/pym/consolegui/application/LeftMenu.py +++ b/pym/consolegui/application/LeftMenu.py @@ -238,16 +238,17 @@ class LeftMenu(qt.QScrollArea): def onActivated_after(self, view): if type(view) == Exception: - if hasattr (view.message, 'message'): - view = view.message - - if type(view.message) == tuple: - if view.message[0] == 403: - msg = _('Permission denied') - else: - msg = ' '.join(map(lambda x: str(x), view.message)) - else: - msg = view.message.__str__() + # if hasattr (view.message, 'message'): + # view = view.message + + # if type(view.message) == tuple: + # if view.message[0] == 403: + # msg = _('Permission denied') + # else: + # msg = ' '.join(map(lambda x: str(x), view.message)) + # else: + # msg = view.message.__str__() + msg = str(view) show_msg(msg) return 1 diff --git a/pym/consolegui/application/client_class.py b/pym/consolegui/application/client_class.py index dce1257..f949947 100644 --- a/pym/consolegui/application/client_class.py +++ b/pym/consolegui/application/client_class.py @@ -691,7 +691,7 @@ class HTTPSClientCertTransport(HttpTransport): else: import M2Crypto bio = M2Crypto.BIO.openfile(key) - rsa = M2Crypto.m2.rsa_read_key(bio._ptr(),lambda *unused: None) + rsa = M2Crypto.m2.rsa_read_key(bio._ptr(),lambda *unused: b"") if not rsa: raise OpenSSL.crypto.Error with open(key) as key_file: diff --git a/pym/consolegui/application/conf_connection.py b/pym/consolegui/application/conf_connection.py index 81ce0e8..4f30917 100644 --- a/pym/consolegui/application/conf_connection.py +++ b/pym/consolegui/application/conf_connection.py @@ -329,7 +329,7 @@ class FrameConnection(qt.QWidget): bio = M2Crypto.BIO.openfile(CERT_KEY) rsa = M2Crypto.m2.rsa_read_key(bio._ptr(), lambda *unused: b"") if re_passwd != False: - self.str_passwd = re_passwd, "UTF-8" + self.str_passwd = re_passwd#, "UTF-8" if not rsa and not self.str_passwd and auto: self.passwd_wgt = LocalhostPasswd(self) passwd = self.passwd_wgt.text() diff --git a/pym/consolegui/application/create_cert.py b/pym/consolegui/application/create_cert.py index 4882861..26b4278 100644 --- a/pym/consolegui/application/create_cert.py +++ b/pym/consolegui/application/create_cert.py @@ -149,12 +149,12 @@ class RequestCreate (qt.QWidget): private_key_passwd = self.passwd_lineedit.text() rsa = generateRSAKey() rsa.save_key(self.key + '_pub', cipher = None, - callback = lambda *unused: "") + callback = lambda *unused: b"") pkey = makePKey(rsa) if not passphrase_callback(private_key_passwd): pkey.save_key(self.key, cipher = None, - callback = lambda *unused: "") + callback = lambda *unused: b"") else: pkey.save_key(self.key,\ callback= lambda *unused: bytes(private_key_passwd, "UTF-8")) diff --git a/setup.py b/setup.py index 2c50d18..bc6e35b 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,8 @@ import sys import distutils from distutils.core import setup from distutils.command.install_data import install_data - +from distutils.command.install import install +from distutils.dir_util import copy_tree import itertools icon_system_path = ['/usr/share/icons/Calculate/16x16/client-gui'] @@ -107,13 +108,19 @@ for theme in ("gnome","hicolor"): __version__ = "3.5.0_alpha1" __app__ = "calculate-console-gui" - +module_name = "calculate.consolegui" packages = [ "calculate."+str('.'.join(root.split(os.sep)[1:])) for root, dirs, files in os.walk('pym/consolegui') if '__init__.py' in files ] +#TODO remove this once actual libs are ported +class my_install(install): + def run(self): + install.run(self) + copy_tree("./libs_crutch", f"{self.install_lib}calculate") + setup( name = __app__, version = __version__, @@ -126,5 +133,5 @@ setup( package_dir = {'calculate.consolegui': "pym/consolegui"}, packages = packages, scripts = (glob('bin/*')), - cmdclass={'install_data': install_data} -) + cmdclass={'install_data': install_data, "install" : my_install} +) \ No newline at end of file