<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
import wx
from pyldaplite import ldap, PyLDAPLite
import utils

HIGHLIGHT_RED = '#F75D59'


class LoginWindow(wx.Dialog):
    def __init__(self, parent=None, title='User Login',
                 size=(500, 240),
                 style=wx.CAPTION | wx.STAY_ON_TOP,
                 root_user='root',
                 root_pass='<PASSWORD>',
                 last_user='',
                 domains=[],
                 server='',
                 base_dn='',
                 destroy=True):
        super(LoginWindow, self).__init__(parent, title=title, size=size,
                                          style=style)
        self.panel = wx.Panel(self)
        self.root_user = root_user
        self.root_pass = <PASSWORD>
        self.last_user = last_user
        self.current_user = None

        self.domains = domains or ['']
        self.server = server
        self.base_dn = base_dn
        self.destroy = destroy

        font = self.GetFont()
        font.SetWeight(wx.BOLD)
        font.SetPointSize(13)
        self.panel.SetFont(font)
        self.init_ui()
        self.panel.Layout()
        self.Bind(wx.EVT_BUTTON, self.on_login, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.on_quit, id=wx.ID_CANCEL)
        self.CenterOnScreen()
        self.Refresh()
        self.ShowModal()

    def init_ui(self):
        sizer = wx.BoxSizer(wx.VERTICAL)
        label_width = 150

        label_style = wx.BORDER_DOUBLE | wx.ALIGN_CENTER
        # Name field
        label = utils.add_label_field(self.panel, label='NT Name',
                                      width=label_width, style=label_style)
        label.SetForegroundColour("blue")
        self.name_tc = utils.add_text_field(self.panel, value=self.last_user)
        self.name_tc.Bind(wx.EVT_TEXT, self.on_enter_name)
        utils.add_quick_sizer(sizer, wgts=[(label, 0), (self.name_tc, 1)])

        # Password field
        label = utils.add_label_field(self.panel, label='Password',
                                      width=label_width, style=label_style)
        label.SetForegroundColour("blue")

        self.pwd_tc = utils.add_text_field(self.panel, style=wx.TE_PASSWORD)
        utils.add_quick_sizer(sizer, wgts=[(label, 0), (self.pwd_tc, 1)])

        combo_style = wx.CB_DROPDOWN | wx.CB_SORT
        if self.domains[0]:
            combo_style = combo_style | wx.CB_READONLY<commit_msg>focus password if provide username<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
import wx
from pyldaplite import ldap, PyLDAPLite
import utils

HIGHLIGHT_RED = '#F75D59'


class LoginWindow(wx.Dialog):
    def __init__(self, parent=None, title='User Login',
                 size=(500, 240),
                 style=wx.CAPTION | wx.STAY_ON_TOP,
                 root_user='root',
                 root_pass='<PASSWORD>',
                 last_user='',
                 domains=[],
                 server='',
                 base_dn='',
                 destroy=True):
        super(LoginWindow, self).__init__(parent, title=title, size=size,
                                          style=style)
        self.panel = wx.Panel(self)
        self.root_user = root_user
        self.root_pass = <PASSWORD>
        self.last_user = last_user
        self.current_user = None

        self.domains = domains or ['']
        self.server = server
        self.base_dn = base_dn
        self.destroy = destroy

        font = self.GetFont()
        font.SetWeight(wx.BOLD)
        font.SetPointSize(13)
        self.panel.SetFont(font)
        self.init_ui()
        self.panel.Layout()
        self.Bind(wx.EVT_BUTTON, self.on_login, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.on_quit, id=wx.ID_CANCEL)
        self.CenterOnScreen()
        self.Refresh()
        self.ShowModal()

    def init_ui(self):
        sizer = wx.BoxSizer(wx.VERTICAL)
        label_width = 150

        label_style = wx.BORDER_DOUBLE | wx.ALIGN_CENTER
        # Name field
        label = utils.add_label_field(self.panel, label='NT Name',
                                      width=label_width, style=label_style)
        label.SetForegroundColour("blue")
        self.name_tc = utils.add_text_field(self.panel, value=self.last_user)
        self.name_tc.Bind(wx.EVT_TEXT, self.on_enter_name)
        utils.add_quick_sizer(sizer, wgts=[(label, 0), (self.name_tc, 1)])

        # Password field
        label = utils.add_label_field(self.panel, label='Password',
                                      width=label_width, style=label_style)
        label.SetForegroundColour("blue")

        self.pwd_tc = utils.add_text_field(self.panel, style=wx.TE_PASSWORD)
        if self.last_user:
            self.pwd_tc.SetFocus()

        utils.add_quick_sizer(sizer, wgts=[(label, 0), (self.pwd_tc, 1)])

        combo_style = wx.CB_DROPDOWN | wx.CB_SORT
        if self.domains[0]:
            combo_style = combo_style | wx.CB_READONLY
{'fraction_non_alphanumeric': 0.11133122028526149, 'fraction_numerical': 0.00832012678288431, 'mean_word_length': 1.9911137440758293, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '871392', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1605, 'n_words': 264}