Ejemplo n.º 1
0
def makeConnections(app):
    """A helper function to be launched from a thread. Will setup proxies and check for updates.
    Should be run from a thread while the program continues to load.
    """
    if web.proxies is None:
        web.setupProxy()
    if web.proxies == 0:
        return
    if app.prefs.connections['allowUsageStats']:
        sendUsageStats()
    if app.prefs.connections['checkForUpdates']:
        app._latestAvailableVersion = getLatestVersionInfo()
Ejemplo n.º 2
0
def makeConnections(app):
    """A helper function to be launched from a thread. Will setup proxies and check for updates.
    Should be run from a thread while the program continues to load.
    """
    if web.proxies is None:
        web.setupProxy()
    if web.proxies == 0:
        return
    if app.prefs.connections["allowUsageStats"]:
        sendUsageStats()
    if app.prefs.connections["checkForUpdates"]:
        app._latestAvailableVersion = getLatestVersionInfo()
Ejemplo n.º 3
0
    def __init__(self, app=None, runningVersion=None):
        """The updater will check for updates and download/install them if necess.
        Several dialogs may be created as needed during the process.

        Usage::

            if app.prefs['AutoUpdate']:
                app.updates=Updater(app)
                app.updater.checkForUpdates()#if updates are found further dialogs will prompt
        """
        self.app = app
        if runningVersion == None: self.runningVersion = psychopy.__version__
        else: self.runningVersion = runningVersion

        #self.headers = {'User-Agent' : psychopy.constants.PSYCHOPY_USERAGENT}
        self.latest = None
        if web.proxies == None:
            web.setupProxy()
Ejemplo n.º 4
0
    def __init__(self,app=None, runningVersion=None):
        """The updater will check for updates and download/install them if necess.
        Several dialogs may be created as needed during the process.

        Usage::

            if app.prefs['AutoUpdate']:
                app.updates=Updater(app)
                app.updater.checkForUpdates()#if updates are found further dialogs will prompt
        """
        self.app=app
        if runningVersion==None:  self.runningVersion=psychopy.__version__
        else:  self.runningVersion=runningVersion

        #self.headers = {'User-Agent' : psychopy.constants.PSYCHOPY_USERAGENT}
        self.latest=None
        if web.proxies==None:
            web.setupProxy()
Ejemplo n.º 5
0
def sendUsageStats():
    """Sends anonymous, very basic usage stats to psychopy server:
      the version of PsychoPy
      the system used (platform and version)
      the date
    """

    v = psychopy.__version__
    dateNow = time.strftime("%Y-%m-%d_%H:%M")
    miscInfo = ''

    # urllib.install_opener(opener)
    # check for proxies
    if web.proxies is None:
        web.setupProxy()

    # get platform-specific info
    if sys.platform == 'darwin':
        OSXver, junk, architecture = platform.mac_ver()
        systemInfo = "OSX_%s_%s" % (OSXver, architecture)
    elif sys.platform.startswith('linux'):
        systemInfo = '%s_%s_%s' % (
            'Linux',
            ':'.join([x for x in platform.dist() if x != '']),
            platform.release())
    elif sys.platform == 'win32':
        ver = sys.getwindowsversion()
        if len(ver[4]) > 0:
            systemInfo = ("win32_v%i.%i.%i_%s" %
                          (ver[0], ver[1], ver[2], ver[4])).replace(' ', '')
        else:
            systemInfo = "win32_v%i.%i.%i" % (ver[0], ver[1], ver[2])
    else:
        systemInfo = platform.system() + platform.release()
    u = "http://www.psychopy.org/usage.php?date=%s&sys=%s&version=%s&misc=%s"
    URL = u % (dateNow, systemInfo, v, miscInfo)
    try:
        req = urllib.request.Request(URL)
        page = urllib.request.urlopen(req)  # proxies
    except Exception:
        logging.warning("Couldn't connect to psychopy.org\n"
                        "Check internet settings (and proxy "
                        "setting in PsychoPy Preferences.")
Ejemplo n.º 6
0
def sendUsageStats():
    """Sends anonymous, very basic usage stats to psychopy server:
      the version of PsychoPy
      the system used (platform and version)
      the date
    """

    v = psychopy.__version__
    dateNow = time.strftime("%Y-%m-%d_%H:%M")
    miscInfo = ''

    # urllib.install_opener(opener)
    # check for proxies
    if web.proxies is None:
        web.setupProxy()

    # get platform-specific info
    if sys.platform == 'darwin':
        OSXver, junk, architecture = platform.mac_ver()
        systemInfo = "OSX_%s_%s" % (OSXver, architecture)
    elif sys.platform.startswith('linux'):
        systemInfo = '%s_%s_%s' % ('Linux', ':'.join(
            [x for x in platform.dist() if x != '']), platform.release())
        if len(systemInfo) > 30:  # if it's too long PHP/SQL fails to store!?
            systemInfo = systemInfo[0:30]
    elif sys.platform == 'win32':
        ver = sys.getwindowsversion()
        if len(ver[4]) > 0:
            systemInfo = ("win32_v%i.%i.%i_%s" %
                          (ver[0], ver[1], ver[2], ver[4])).replace(' ', '')
        else:
            systemInfo = "win32_v%i.%i.%i" % (ver[0], ver[1], ver[2])
    else:
        systemInfo = platform.system() + platform.release()
    u = "http://www.psychopy.org/usage.php?date=%s&sys=%s&version=%s&misc=%s"
    URL = u % (dateNow, systemInfo, v, miscInfo)
    try:
        req = urllib.request.Request(URL)
        page = urllib.request.urlopen(req)  # proxies
    except Exception:
        logging.warning("Couldn't connect to psychopy.org\n"
                        "Check internet settings (and proxy "
                        "setting in PsychoPy Preferences.")
Ejemplo n.º 7
0
 def test_setupProxy(self):
     web.getPacFiles()
     web.getWpadFiles()
     web.proxyFromPacFiles(web.getPacFiles(), log=False)
     web.setupProxy()