Smol fix to make temp file usage clearer

Most likely this temp file solution does
not do what I though...
main
Micke Nordin 3 years ago
parent 9fc9c77396
commit fa3d747cba
Signed by: micke
GPG Key ID: 0DA0A7A5708FE257

@ -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):

Loading…
Cancel
Save