コード例 #1
0
def logout():
    """Log the current user out of pavlovia.

    NB This function does not delete the cookie from the wx mini-browser
    if that has been set. Use pavlovia_ui for that.

     - set the user for the currentSession to None
     - save the appData so that the user is blank
    """
    # create a new currentSession with no auth token
    global _existingSession
    _existingSession = PavloviaSession()  # create an empty session (user is None)
    # set appData to None
    prefs.appData['projects']['pavloviaUser'] = None
    prefs.saveAppData()
    for frameWeakref in app.openFrames:
        frame = frameWeakref()
        if hasattr(frame, 'setUser'):
            frame.setUser(None)
コード例 #2
0
ファイル: pavlovia.py プロジェクト: hoechenberger/psychopy
def logout():
    """Log the current user out of pavlovia.

    NB This function does not delete the cookie from the wx mini-browser
    if that has been set. Use pavlovia_ui for that.

     - set the user for the currentSession to None
     - save the appData so that the user is blank
    """
    # create a new currentSession with no auth token
    global _existingSession
    _existingSession = PavloviaSession()  # create an empty session (user is None)
    # set appData to None
    prefs.appData['projects']['pavloviaUser'] = None
    prefs.saveAppData()
    for frameWeakref in app.openFrames:
        frame = frameWeakref()
        if hasattr(frame, 'setUser'):
            frame.setUser(None)
コード例 #3
0
def showNews(app=None, checkPrev=True):
    """Brings up an internal html viewer and show the latest psychopy news

    :Returns:
        itemShown : bool

    """
    if checkPrev and app.news:
        toShow = None
        if 'lastNewsDate' in prefs.appData:
            lastNewsDate = prefs.appData['lastNewsDate']
        else:
            lastNewsDate = ""

        for item in app.news:
            if item['importance'] >= ANNOUNCE and item['date'] > lastNewsDate:
                toShow = item
                break

        # update prefs lastNewsDate to match JavaScript Date().toISOString()
        now = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
        prefs.appData['lastNewsDate'] = now
        prefs.saveAppData()

        if not toShow:
            return 0
    else:
        return 0

    dlg = wx.Dialog(None,
                    style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                    size=(800, 400))
    browser = wx.html2.WebView.New(dlg)

    # do layout
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(browser, 1, wx.EXPAND, 10)
    dlg.SetSizer(sizer)

    browser.LoadURL(newsURL)
    dlg.Show()
    return 1