Beispiel #1
0
 def gv(self):
     label = self.GetStringSelection()
     level = plogging.LoggingLevels.getByName(label)
     ret = plogging.LoggingLevels.WARNING #a good default, just in case
     if (level):
         ret = level
     #actually set the logging level
     plogging.set_level('client', ret)
     return ret
Beispiel #2
0
 def gv(self):
     label = self.GetStringSelection()
     level = plogging.LoggingLevels.getByName(label)
     ret = plogging.LoggingLevels.WARNING  #a good default, just in case
     if (level):
         ret = level
     #actually set the logging level
     plogging.set_level('client', ret)
     return ret
Beispiel #3
0
    def __init__(self, config, parent):
        self.config = config

        plogging.set_level('client', self.config.getValue('loglevel'))
        wx.Frame.__init__(self, parent, -1, 'MS Datasync Application: v%s' % (VERSION))
        self.countDownEnabled = True #sets the countdown to be active

        self.contentPanel = wx.Panel(self, -1)
        _cp = self.contentPanel


        #progressLabel = wx.StaticText(parent = _cp)
        #progressLabel.SetLabel(label="Progress")

        #First thing, set up the log.
        self.logArea = wx.CollapsiblePane(_cp, -1, "Log", name='LogArea')
        self.logAreaPane = self.logArea.GetPane()
        self.logAreaSizer = wx.BoxSizer(wx.VERTICAL)
        self.logTextCtrl = wx.TextCtrl(self.logAreaPane, -1,
                                    style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)



        #modify the log
        if wx.Platform == "__WXMAC__":
            self.logTextCtrl.MacCheckSpelling(False)

        self.log = Log(self.logTextCtrl)
        wx.Log_SetActiveTarget(self.log)



        #self.ListCtrlPanel = ListCtrlPanel(self, self.log)

        #menu bar
        #We set this up fairly early on in the piece so that the things below
        #status bars and timers etc, can enable/disable items in it.
        self.menuBar = wx.MenuBar()
        fileMenu = wx.Menu()
        #fileMenu.Append(ID_TEST_CONNECTION, "&Test Connection", "Test your connection to the server")
        fileMenu.Append(ID_CHECK_NOW, "&Check Now", "Check for required uploads now")
        fileMenu.AppendSeparator()
        fileMenu.Append(ID_PROGRAMUPDATES, "&Program Updates", "Check for new versions of this program")
        fileMenu.Append(ID_MINIMISE, "&Minimize", "Minimize the app to the system tray")
        fileMenu.Append(ID_QUIT, "&Quit", "Quits the application completely")

        editMenu = wx.Menu()
        editMenu.Append(ID_PREFERENCES, "&Preferences", "Application Preferences")

        helpMenu = wx.Menu()
        helpMenu.Append(ID_ABOUT, "&About", "About")
        helpMenu.Append(ID_PYCRUST, "&Pycrust", "Pycrust")

        self.menuBar.Append(fileMenu, "&File")
        self.menuBar.Append(editMenu, "&Edit")
        self.menuBar.Append(helpMenu, "&Help")

        #status bar
        self.StatusBar = StatusBar(self, self.log)
        self.SetStatusBar(self.StatusBar)
        self.state = APPSTATE.IDLE
        #self.StatusBar.SetStatusText(self.state)

        #sys tray icon
        self.SystrayIcon = SystrayIcon(self, self.log)
        self.SystrayIcon.SetIconTimer()

        self.setState(APPSTATE.IDLE)

        #Create a timer.
        self.timer = wx.Timer(self, -1)
        self.Bind(wx.EVT_TIMER, self.OnTimerTick, self.timer)
        self.timer.Start(milliseconds = 1000, oneShot = False)
        self.secondsUntilNextSync = 0
        self.syncFreq = 0 #local cache of syncfreq

        #Menu Events
        self.SetMenuBar(self.menuBar)
        self.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight)
        #self.Bind(wx.EVT_MENU, self.__testMenuFunction, id=ID_TEST_CONNECTION )
        self.Bind(wx.EVT_MENU, self.OnCheckNow, id=ID_CHECK_NOW )
        self.Bind(wx.EVT_MENU, self.OnMenuMinimise, id=ID_MINIMISE )
        self.Bind(wx.EVT_MENU, self.OnMenuQuit, id=ID_QUIT)
        self.Bind(wx.EVT_MENU, self.OnMenuPreferences, id=ID_PREFERENCES )
        self.Bind(wx.EVT_MENU, self.pycrust, id=ID_PYCRUST )
        self.Bind(wx.EVT_MENU, self.OnUpdateProgram, id=ID_PROGRAMUPDATES )
        self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_ABOUT )

        #Collapsible pane event (the logArea):
        self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged, self.logArea)

        #A button to send logs to the webserver
        self.logbutton = wx.Button(self.logAreaPane, ID_SENDLOGS_BUTTON)
        self.logbutton.SetLabel("Send Log")
        self.logbutton.Bind(wx.EVT_BUTTON, self.OnSendLog)
        self.screenshotbutton = wx.Button(self.logAreaPane, ID_SENDSCREENSHOT_BUTTON)
        self.screenshotbutton.SetLabel("Send Shot")
        self.screenshotbutton.Bind(wx.EVT_BUTTON, self.OnTakeScreenshot)
        logWrap = wx.CheckBox(parent=self.logAreaPane, label="Wrap")
        logWrap.SetValue(False)
        logWrap.Bind(wx.EVT_CHECKBOX, self.ToggleLogWrap)

        #now lay everything out.
        self.logAreaSizer.Add(self.logTextCtrl, 1, flag=wx.ALL|wx.GROW|wx.EXPAND, border=0)
        #Log  footer box
        logfooterbox = wx.BoxSizer(wx.HORIZONTAL)
        #A place to set the log variable
        conf = self.config.getConfig()
        if self.config.getConfig():

            box = wx.BoxSizer(wx.HORIZONTAL)
            ctrl = wx.TextCtrl(self.logAreaPane, -1, str(self.config.getValue('logfile')), size=(80,-1))
            ctrl.SetHelpText(  self.config.getHelpText('logfile') )

            def OnLogFilenameSave(evt):
                self.config.setValue('logfile', ctrl.GetValue() )
                self.config.save()

            label =  wx.StaticText(self.logAreaPane, -1, self.config.getFormalName('logfile'))
            label.SetHelpText(self.config.getHelpText('logfile'))
            btn = wx.Button(self.logAreaPane, -1)
            btn.SetLabel('Set')
            btn.Bind(wx.EVT_BUTTON, OnLogFilenameSave )
            box.Add(label, 0, wx.ALIGN_LEFT| wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0)
            box.Add(ctrl, 1, wx.ALIGN_CENTRE|wx.ALL, 0)
            box.Add(btn, 0, wx.ALIGN_RIGHT|wx.ALL, 0)
            logfooterbox.Add(box, 1,  wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0 )

        logfooterbox.Add(self.logbutton, 0, wx.ALL, 0)
        logfooterbox.Add(self.screenshotbutton, 0, wx.ALL, 0)
        logfooterbox.Add(logWrap, 0, wx.ALIGN_LEFT| wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0)
        self.logAreaSizer.Add(logfooterbox, 0, flag=wx.ALL|wx.GROW|wx.EXPAND, border=2)
        self.logAreaPane.SetSizerAndFit(self.logAreaSizer)

        #timing controls:
        timingbox = wx.BoxSizer(wx.HORIZONTAL)
        self.nextsynctxt = wx.StaticText(_cp, -1, label="Next Sync in:")
        self.freqspin = wx.SpinCtrl(_cp, -1)
        self.freqspin.SetRange(1, 100000)
        self.freqspin.SetValue(int(self.config.getValue('syncfreq')))
        self.freqspin.Bind(wx.EVT_SPINCTRL, self.OnSpin)
        #freqbox = wx.BoxSizer(wx.HORIZONTAL)
        freqlab1 = wx.StaticText(_cp, -1, "Sync Frequency:")
        freqlab2 = wx.StaticText(_cp, -1, "mins")
        freqbox = wx.BoxSizer(wx.HORIZONTAL)
        freqbox.Add(freqlab1, 1, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=0)
        freqbox.Add(self.freqspin, 1, wx.ALIGN_RIGHT | wx.GROW | wx.EXPAND | wx.ALL, border=0)
        freqbox.Add(freqlab2, 1, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=0)
        timingbox.Add(self.nextsynctxt, 1, wx.ALIGN_LEFT | wx.GROW | wx.EXPAND | wx.ALL, border=0)
        timingbox.Add(freqbox, 1, wx.ALIGN_RIGHT | wx.GROW | wx.EXPAND | wx.ALL, border=0)

        #Populate the main window with the components
        contentpanelsizer = wx.BoxSizer(wx.VERTICAL)
        contentpanelsizer.Add(timingbox, 0, wx.GROW | wx.EXPAND | wx.ALL, border=0)
        contentpanelsizer.Add(self.logArea, 1, wx.ALL | wx.GROW | wx.EXPAND, border=0)
        #contentpanelsizer.Add(self.logArea, 1, wx.ALL | wx.GROW | wx.EXPAND | wx.FIXED_MINSIZE, border=0)

        self.contentPanel.SetSizerAndFit(contentpanelsizer)
        self.contentpanelsizer = contentpanelsizer

        #Expand the debug area by default:
        self.logArea.Expand()

        self.OnPaneChanged() #force a layout fit

        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        self.log('Finished loading application')