From fa3d747cba570febf14d0be1142933b84a519287 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Fri, 9 Jul 2021 14:58:37 +0200 Subject: [PATCH] Smol fix to make temp file usage clearer Most likely this temp file solution does not do what I though... --- src/main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.py b/src/main.py index 9d665ff..0a89f40 100755 --- a/src/main.py +++ b/src/main.py @@ -185,7 +185,7 @@ class PassUi(wx.Frame): # self.pass_handler.pass_init(self.gpg_key, git_repo) # self.add_buttons() - def git_submit_btn_clicked(self, widget_list) -> str: + def git_submit_btn_clicked(self, widget_list): default_ports = {'git': 9418, 'git+ssh': 22, 'https': 443} user: str = widget_list[1].GetLineText(0) password: str = widget_list[3].GetLineText(0) @@ -194,15 +194,18 @@ class PassUi(wx.Frame): port: str = widget_list[9].GetLineText(0) path: str = widget_list[11].GetLineText(0) if not port: - port = default_ports[protocol] + port = str(default_ports[protocol]) self.file_str = 'protocol={}\nhost={}:{}{}\nusername=\npassword={}\n'.format(protocol, host, port, path, user, password) timeout_in_sec = 24 * 60 * 60 - temp_tuple = tempfile.mkstemp(text=self.file_str) - run_command(['/usr/bin/git', 'credential-store', '--file', temp_tuple[1]]) + file_descriptor, file_name = tempfile.mkstemp(text=True) + with open(file_name, 'w') as file: + file.write(self.file_str) + os.close(file_descriptor) + run_command(['/usr/bin/git', 'credential-store', '--file', file_name]) run_command( ['/usr/bin/git', 'config', 'credential.helper', 'cache --timeout={}'.format(timeout_in_sec)]) - os.unlink(temp_tuple[1]) + os.unlink(file_name) self.init_button_clicked('{}://{}:{}{}'.format(protocol, host, port, path)) def gpg_button_clicked(self):