|
|
@ -125,7 +125,7 @@ class PassUi(wx.Frame):
|
|
|
|
def add_tools(self, index: Union[None, int] = None):
|
|
|
|
def add_tools(self, index: Union[None, int] = None):
|
|
|
|
"""add_tools.
|
|
|
|
"""add_tools.
|
|
|
|
|
|
|
|
|
|
|
|
:param index:
|
|
|
|
:param index: Union[None.int]
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
btn: wx.Button = wx.Button(self.pnl, label="Show tools")
|
|
|
|
btn: wx.Button = wx.Button(self.pnl, label="Show tools")
|
|
|
|
font: wx.Font = btn.GetFont().MakeBold()
|
|
|
|
font: wx.Font = btn.GetFont().MakeBold()
|
|
|
@ -138,17 +138,27 @@ class PassUi(wx.Frame):
|
|
|
|
def back_button_clicked(self, index: Union[None, int] = None):
|
|
|
|
def back_button_clicked(self, index: Union[None, int] = None):
|
|
|
|
"""back_button_clicked.
|
|
|
|
"""back_button_clicked.
|
|
|
|
|
|
|
|
|
|
|
|
:param index:
|
|
|
|
:param index: Union[None.int]
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
if index:
|
|
|
|
if index:
|
|
|
|
self.show_password_dialog(index)
|
|
|
|
self.show_password_dialog(index)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.add_buttons()
|
|
|
|
self.add_buttons()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def choice_button_clicked(self, event):
|
|
|
|
|
|
|
|
"""choice_button_clicked
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param event: wx.Event
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
choice = event.GetEventObject()
|
|
|
|
|
|
|
|
self.gpg_key = choice.GetString(choice.GetSelection())
|
|
|
|
|
|
|
|
print(self.gpg_key)
|
|
|
|
|
|
|
|
self.add_init()
|
|
|
|
|
|
|
|
|
|
|
|
def delete_password(self, index: int):
|
|
|
|
def delete_password(self, index: int):
|
|
|
|
"""delete_password.
|
|
|
|
"""delete_password.
|
|
|
|
|
|
|
|
|
|
|
|
:param index:
|
|
|
|
:param index: int
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
path: str = self.pass_handler.get_pass_path_from_index(index, "password")
|
|
|
|
path: str = self.pass_handler.get_pass_path_from_index(index, "password")
|
|
|
|
dlg: wx.MessageDialog = wx.MessageDialog(self.pnl,
|
|
|
|
dlg: wx.MessageDialog = wx.MessageDialog(self.pnl,
|
|
|
@ -162,20 +172,6 @@ class PassUi(wx.Frame):
|
|
|
|
self.pass_handler.delete_password(path)
|
|
|
|
self.pass_handler.delete_password(path)
|
|
|
|
self.back_button_clicked()
|
|
|
|
self.back_button_clicked()
|
|
|
|
|
|
|
|
|
|
|
|
def make_back_button(self, index: Union[None, int] = None) -> wx.Button:
|
|
|
|
|
|
|
|
"""make_back_button.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param index:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if index is not None:
|
|
|
|
|
|
|
|
label: str = self.pass_handler.get_pass_path_from_index(index, "password")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
label: str = self.pass_handler.cur_dir.replace(self.pass_handler.top_dir, '')
|
|
|
|
|
|
|
|
btn: wx.Button = wx.Button(self.pnl, label=label + '⤴')
|
|
|
|
|
|
|
|
font: wx.Font = btn.GetFont().MakeItalic().MakeBold()
|
|
|
|
|
|
|
|
btn.SetFont(font)
|
|
|
|
|
|
|
|
return btn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def git_button_clicked(self):
|
|
|
|
def git_button_clicked(self):
|
|
|
|
"""git_button_clicked.
|
|
|
|
"""git_button_clicked.
|
|
|
|
|
|
|
|
|
|
|
@ -184,6 +180,26 @@ class PassUi(wx.Frame):
|
|
|
|
# self.pass_handler.pass_init(self.gpg_key, git_repo)
|
|
|
|
# self.pass_handler.pass_init(self.gpg_key, git_repo)
|
|
|
|
# self.add_buttons()
|
|
|
|
# self.add_buttons()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def git_submit_btn_clicked(self, widget_list) -> str:
|
|
|
|
|
|
|
|
default_ports = {'git': 9418, 'git+ssh': 22, 'https': 443}
|
|
|
|
|
|
|
|
user: str = widget_list[1].GetLineText(0)
|
|
|
|
|
|
|
|
password: str = widget_list[3].GetLineText(0)
|
|
|
|
|
|
|
|
protocol: str = widget_list[5].GetString(widget_list[5].GetSelection())
|
|
|
|
|
|
|
|
host: str = widget_list[7].GetLineText(0)
|
|
|
|
|
|
|
|
port: str = widget_list[9].GetLineText(0)
|
|
|
|
|
|
|
|
path: str = widget_list[11].GetLineText(0)
|
|
|
|
|
|
|
|
if not port:
|
|
|
|
|
|
|
|
port = 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]])
|
|
|
|
|
|
|
|
run_command(
|
|
|
|
|
|
|
|
['/usr/bin/git', 'config', 'credential.helper', 'cache --timeout={}'.format(timeout_in_sec)])
|
|
|
|
|
|
|
|
os.unlink(temp_tuple[1])
|
|
|
|
|
|
|
|
self.init_button_clicked('{}://{}:{}{}'.format(protocol, host, port, path))
|
|
|
|
|
|
|
|
|
|
|
|
def gpg_button_clicked(self):
|
|
|
|
def gpg_button_clicked(self):
|
|
|
|
"""gpg_button_clicked.
|
|
|
|
"""gpg_button_clicked.
|
|
|
|
|
|
|
|
|
|
|
@ -202,6 +218,20 @@ class PassUi(wx.Frame):
|
|
|
|
self.pass_handler.pass_init(self.gpg_key, repo)
|
|
|
|
self.pass_handler.pass_init(self.gpg_key, repo)
|
|
|
|
self.add_buttons()
|
|
|
|
self.add_buttons()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_back_button(self, index: Union[None, int] = None) -> wx.Button:
|
|
|
|
|
|
|
|
"""make_back_button.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param index:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if index is not None:
|
|
|
|
|
|
|
|
label: str = self.pass_handler.get_pass_path_from_index(index, "password")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
label: str = self.pass_handler.cur_dir.replace(self.pass_handler.top_dir, '')
|
|
|
|
|
|
|
|
btn: wx.Button = wx.Button(self.pnl, label=label + '⤴')
|
|
|
|
|
|
|
|
font: wx.Font = btn.GetFont().MakeItalic().MakeBold()
|
|
|
|
|
|
|
|
btn.SetFont(font)
|
|
|
|
|
|
|
|
return btn
|
|
|
|
|
|
|
|
|
|
|
|
def password_button_clicked(self, index: int):
|
|
|
|
def password_button_clicked(self, index: int):
|
|
|
|
"""password_button_clicked.
|
|
|
|
"""password_button_clicked.
|
|
|
|
|
|
|
|
|
|
|
@ -265,12 +295,6 @@ class PassUi(wx.Frame):
|
|
|
|
self.sizer.Add(choice, 0, wx.EXPAND)
|
|
|
|
self.sizer.Add(choice, 0, wx.EXPAND)
|
|
|
|
self.Bind(wx.EVT_CHOICE, lambda event: self.choice_button_clicked(event), choice)
|
|
|
|
self.Bind(wx.EVT_CHOICE, lambda event: self.choice_button_clicked(event), choice)
|
|
|
|
|
|
|
|
|
|
|
|
def choice_button_clicked(self, event):
|
|
|
|
|
|
|
|
choice = event.GetEventObject()
|
|
|
|
|
|
|
|
self.gpg_key = choice.GetString(choice.GetSelection())
|
|
|
|
|
|
|
|
print(self.gpg_key)
|
|
|
|
|
|
|
|
self.add_init()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@redraw
|
|
|
|
@redraw
|
|
|
|
def show_new_dialog(self):
|
|
|
|
def show_new_dialog(self):
|
|
|
|
"""show_new_dialog.
|
|
|
|
"""show_new_dialog.
|
|
|
@ -418,26 +442,6 @@ class PassUi(wx.Frame):
|
|
|
|
self.Bind(wx.EVT_BUTTON, lambda event, m_widgets=widget_list: self.git_submit_btn_clicked(m_widgets),
|
|
|
|
self.Bind(wx.EVT_BUTTON, lambda event, m_widgets=widget_list: self.git_submit_btn_clicked(m_widgets),
|
|
|
|
widget_list[12])
|
|
|
|
widget_list[12])
|
|
|
|
|
|
|
|
|
|
|
|
def git_submit_btn_clicked(self, widget_list) -> str:
|
|
|
|
|
|
|
|
default_ports = {'git': 9418, 'git+ssh': 22, 'https': 443}
|
|
|
|
|
|
|
|
user: str = widget_list[1].GetLineText(0)
|
|
|
|
|
|
|
|
password: str = widget_list[3].GetLineText(0)
|
|
|
|
|
|
|
|
protocol: str = widget_list[5].GetString(widget_list[5].GetSelection())
|
|
|
|
|
|
|
|
host: str = widget_list[7].GetLineText(0)
|
|
|
|
|
|
|
|
port: str = widget_list[9].GetLineText(0)
|
|
|
|
|
|
|
|
path: str = widget_list[11].GetLineText(0)
|
|
|
|
|
|
|
|
if not port:
|
|
|
|
|
|
|
|
port = 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]])
|
|
|
|
|
|
|
|
run_command(
|
|
|
|
|
|
|
|
['/usr/bin/git', 'config', 'credential.helper', 'cache --timeout={}'.format(timeout_in_sec)])
|
|
|
|
|
|
|
|
os.unlink(temp_tuple[1])
|
|
|
|
|
|
|
|
self.init_button_clicked('{}://{}:{}{}'.format(protocol, host, port, path))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# When this module is run (not imported) then create the app, the
|
|
|
|
# When this module is run (not imported) then create the app, the
|
|
|
|