Exemplo n.º 1
0
 def _tag_pattern_search_panel(self):
     panel = wx.Panel(self._notebook)
     panel.SetSizer(VerticalSizer())
     tags_controls_sizer = VerticalSizer()
     tags_controls_sizer.Add(self._create_include_line(panel), 0, wx.ALL, 3)
     tags_controls_sizer.Add(self._create_exclude_line(panel), 0, wx.ALL, 3)
     controls_sizer = self._horizontal_sizer()
     controls_sizer.Add(tags_controls_sizer)
     controls_sizer.Add(self._create_switch_button(panel), 0, wx.CENTER, 3)
     controls_sizer.Add(self._create_tag_search_button(panel), 0,
                        wx.ALL | wx.EXPAND, 3)
     controls_sizer.Add(self._create_add_to_selected_button(panel), 0,
                        wx.ALL | wx.EXPAND, 3)
     panel.Sizer.Add(controls_sizer)
     panel.Sizer.Add(
         self._add_info_text(
             panel,
             "Find matches using tag patterns. See RF User Guide or 'pybot --help' for more information."
         ), 0, wx.ALL, 3)
     self._tags_results = _TestSearchListModel([])
     self._tags_list = VirtualList(panel, ['Test', 'Tags', 'Source'],
                                   self._tags_results)
     self._tags_list.add_selection_listener(self._select_tag_search_result)
     panel.Sizer.add_expanding(self._tags_list)
     self._tags_results_text = wx.StaticText(panel, -1, 'Results: ')
     panel.Sizer.Add(self._tags_results_text, 0, wx.ALL, 3)
     return panel
class RepositorySettingsDialog(Dialog):
    _width = 650
    _height = 250
    __repositories = ["git", "bitbucket"]

    def __init__(self, controller):
        self._user_name = "Admin"
        self._password = ""
        self._server_list = ""
        self._repository_list = ""
        self._repository_type = self.__repositories[0]
        self._controller = controller
        title = 'Repository settings'

        Dialog.__init__(self, title, size=(self._width, self._height))
        self._sizer = VerticalSizer()
        # self._add_server_list(self, self._sizer)
        # self._add_repository_list(self, self._sizer)
        # self._sizer = wx.GridSizer(0, 2, 0, 0)
        self.m_label_user = wx.StaticText(self, wx.ID_ANY, u"User", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_label_user.Wrap(-1)
        self._sizer.Add(self.m_label_user, 0, wx.ALL, 5)

        self.m_text_user = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
        self._sizer.Add(self.m_text_user, 0, wx.ALL, 5)

        self.m_label_pass = wx.StaticText(self, wx.ID_ANY, u"Pass", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_label_pass.Wrap(-1)
        self._sizer.Add(self.m_label_pass, 0, wx.ALL, 5)

        self.m_text_pass = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
        self._sizer.Add(self.m_text_pass, 0, wx.ALL, 5)

        self.m_button_push = wx.Button(self, wx.ID_ANY, u"Push", wx.DefaultPosition, wx.DefaultSize, 0)
        self._sizer.Add(self.m_button_push, 0, wx.ALL, 5)

        self.m_button_pull = wx.Button(self, wx.ID_ANY, u"Pull", wx.DefaultPosition, wx.DefaultSize, 0)
        self._sizer.Add(self.m_button_pull, 0, wx.ALL, 5)

        self.SetSizer(self._sizer)
        self.Layout()

        self.Centre(wx.BOTH)

        # Connect Events
        self.m_button_push.Bind(wx.EVT_BUTTON, self.m_button_push_on_button_click)
        self.m_button_pull.Bind(wx.EVT_BUTTON, self.m_button_pull_on_button_click)

    def __del__(self):
        pass

    def _execute(self):
        pass

    # Virtual event handlers, overide them in your derived class
    def m_button_push_on_button_click(self, event):
        self._execGitCommand('git push -f')

    def m_button_pull_on_button_click(self, event):
        self._execGitCommand('git pull -f')


    # def show(self):
    #     confirmed = self.ShowModal() == wx.ID_OK
    #     return confirmed, self._checkbox.IsChecked()

    def _add_server_list(self, sizer):
        buttons = self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL)
        sizer.Add(buttons, flag=wx.ALIGN_CENTER | wx.ALL, border=5)

    def _execGitCommand(self, command):
        pr = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        msg = pr.stdout.read()
        err = pr.stderr.read()
        #HB Todo: show message and count errors