def __init__(self, app, pos=wx.DefaultPosition, size=wx.DefaultSize, style=defaultStyle): wx.Dialog.__init__(self, None, title="Log in to Open Science Framework") self.session = app.osf_session self.app = app self.fieldsSizer = wx.GridBagSizer(vgap=5, hgap=5) if web.haveInternetAccess(): self.status = wx.StaticText(self, label="Status: Ready") else: self.status = wx.StaticText(self, label="No internet access") self.fieldsSizer.Add(self.status, pos=(0, 0), span=(1, 2), flag=wx.ALIGN_CENTER, border=10) # user info self.fieldsSizer.Add(wx.StaticText(self, label="OSF Username (email)"), pos=(1, 0), flag=wx.ALIGN_RIGHT) self.username = wx.TextCtrl(self) self.username.SetToolTipString("Your username on OSF " "(the email address you used)") self.fieldsSizer.Add(self.username, pos=(1, 1), flag=wx.ALIGN_LEFT) # pass info self.fieldsSizer.Add(wx.StaticText(self, label="Password"), pos=(2, 0), flag=wx.ALIGN_RIGHT) self.password = wx.TextCtrl(self, style=wx.TE_PASSWORD | wx.TE_PROCESS_ENTER) self.password.SetToolTipString("Your password on OSF " "(will be checked securely with https)") self.fieldsSizer.Add(self.password, pos=(2, 1), flag=wx.ALIGN_LEFT) # remember me self.fieldsSizer.Add(wx.StaticText(self, label="Remember me"), pos=(3, 0), flag=wx.ALIGN_RIGHT) self.rememberMe = wx.CheckBox(self, True) self.rememberMe.SetToolTipString("We won't store your password - " "just an authorisation token") self.fieldsSizer.Add(self.rememberMe, pos=(3, 1), flag=wx.ALIGN_LEFT) # buttons (Log in, Cancel) btnSizer = wx.BoxSizer(wx.HORIZONTAL) self.cancelBtn = wx.Button( self, wx.ID_CANCEL, 'Cancel') self.Bind(wx.EVT_BUTTON, self.onCancel, id=wx.ID_CANCEL) btnSizer.Add(self.cancelBtn, wx.ALIGN_RIGHT) self.okBtn = wx.Button(self, wx.ID_OK, "Login") self.okBtn.SetDefault() self.Bind(wx.EVT_BUTTON, self.onLogin, id=wx.ID_OK) btnSizer.Add(self.okBtn, wx.ALIGN_RIGHT) self.main_sizer = wx.BoxSizer(wx.VERTICAL) self.main_sizer.Add(self.fieldsSizer, 0, wx.ALL, 5) self.main_sizer.Add(btnSizer, 0, wx.ALL | wx.ALIGN_RIGHT, 5) self.SetSizerAndFit(self.main_sizer)
def _setSystemInfo(self): # machine name self['systemHostName'] = platform.node() self['systemMemTotalRAM'], self['systemMemFreeRAM'] = getRAM() # locale information: import locale loc = '.'.join(map(str, locale.getlocale())) # (None, None) -> str if loc == 'None.None': loc = locale.setlocale(locale.LC_ALL, '') self[ 'systemLocale'] = loc # == the locale in use, from OS or user-pref # platform name, etc if sys.platform in ['darwin']: OSXver, junk, architecture = platform.mac_ver() platInfo = 'darwin ' + OSXver + ' ' + architecture # powerSource = ... elif sys.platform.startswith('linux'): platInfo = 'linux ' + platform.release() # powerSource = ... elif sys.platform in ['win32']: platInfo = 'windowsversion=' + repr(sys.getwindowsversion()) # powerSource = ... else: platInfo = ' [?]' # powerSource = ... self['systemPlatform'] = platInfo #self['systemPowerSource'] = powerSource # count all unique people (user IDs logged in), and find current user name & UID self['systemUser'], self['systemUserID'] = _getUserNameUID() try: users = shellCall("who -q").splitlines()[0].split() self['systemUsersCount'] = len(set(users)) except: self['systemUsersCount'] = False # when last rebooted? try: lastboot = shellCall("who -b").split() self['systemRebooted'] = ' '.join(lastboot[2:]) except: # windows sysInfo = shellCall('systeminfo').splitlines() lastboot = [ line for line in sysInfo if line.find("System Up Time") == 0 or line.find("System Boot Time") == 0 ] lastboot += ['[?]'] # put something in the list just in case self['systemRebooted'] = lastboot[0].strip() # R (and r2py) for stats: try: Rver, err = shellCall("R --version", stderr=True) Rversion = Rver.splitlines()[0] if Rversion.startswith('R version'): self['systemRavailable'] = Rversion.strip() try: import rpy2 self['systemRpy2'] = rpy2.__version__ except: pass except: pass # encryption / security tools: try: vers, se = shellCall('openssl version', stderr=True) if se: vers = str(vers) + se.replace('\n', ' ')[:80] if vers.strip(): self['systemSec.OpenSSLVersion'] = vers except: pass try: so, se = shellCall('gpg --version', stderr=True) if so.find('GnuPG') > -1: self['systemSec.GPGVersion'] = so.splitlines()[0] self['systemSec.GPGHome'] = ''.join([ line.replace('Home:', '').lstrip() for line in so.splitlines() if line.startswith('Home:') ]) except: pass try: import ssl self['systemSec.pythonSSL'] = True except ImportError: self['systemSec.pythonSSL'] = False # pyo for sound: try: import pyo self['systemPyoVersion'] = '%i.%i.%i' % pyo.getVersion() try: # requires pyo svn r1024 or higher: inp, out = pyo.pa_get_devices_infos() self['systemPyo.InputDevices'] = inp self['systemPyo.OutputDevices'] = out except AttributeError: pass except ImportError: pass # flac (free lossless audio codec) for google-speech: flacv = '' if sys.platform == 'win32': flacexe = 'C:\\Program Files\\FLAC\\flac.exe' if os.path.exists(flacexe): flacv = core.shellCall(flacexe + ' --version') else: flac, se = core.shellCall('which flac', stderr=True) if not se and flac and not flac.find('Command not found') > -1: flacv = core.shellCall('flac --version') if flacv: self['systemFlacVersion'] = flacv # detect internet access or fail quickly: #web.setupProxy() & web.testProxy(web.proxies) # can take a long time to fail if there's no connection self['systemHaveInternetAccess'] = web.haveInternetAccess() if not self['systemHaveInternetAccess']: self['systemHaveInternetAccess'] = 'False (proxies not attempted)'
def _setSystemInfo(self): """System info """ # machine name self['systemHostName'] = platform.node() self['systemMemTotalRAM'], self['systemMemFreeRAM'] = getRAM() # locale information: # (None, None) -> str loc = '.'.join([str(x) for x in locale.getlocale()]) if loc == 'None.None': loc = locale.setlocale(locale.LC_ALL, '') # == the locale in use, from OS or user-pref self['systemLocale'] = loc # platform name, etc if sys.platform in ['darwin']: OSXver, _junk, architecture = platform.mac_ver() platInfo = 'darwin ' + OSXver + ' ' + architecture # powerSource = ... elif sys.platform.startswith('linux'): platInfo = 'linux ' + platform.release() # powerSource = ... elif sys.platform in ['win32']: platInfo = 'windowsversion=' + repr(sys.getwindowsversion()) # powerSource = ... else: platInfo = ' [?]' # powerSource = ... self['systemPlatform'] = platInfo # self['systemPowerSource'] = powerSource # count all unique people (user IDs logged in), and find current user # name & UID self['systemUser'], self['systemUserID'] = _getUserNameUID() try: users = shellCall("who -q").splitlines()[0].split() self['systemUsersCount'] = len(set(users)) except Exception: self['systemUsersCount'] = False # when last rebooted? try: lastboot = shellCall("who -b").split() self['systemRebooted'] = ' '.join(lastboot[2:]) except Exception: # windows sysInfo = shellCall('systeminfo').splitlines() lastboot = [ line for line in sysInfo if line.startswith("System Up Time") or line.startswith("System Boot Time") ] lastboot += ['[?]'] # put something in the list just in case self['systemRebooted'] = lastboot[0].strip() # R (and r2py) for stats: try: Rver = shellCall(["R", "--version"]) Rversion = Rver.splitlines()[0] if Rversion.startswith('R version'): self['systemRavailable'] = Rversion.strip() try: import rpy2 self['systemRpy2'] = rpy2.__version__ except ImportError: pass except Exception: pass # encryption / security tools: try: vers, se = shellCall('openssl version', stderr=True) if se: vers = str(vers) + se.replace('\n', ' ')[:80] if vers.strip(): self['systemSec.OpenSSLVersion'] = vers except Exception: pass try: so = shellCall(['gpg', '--version']) if so.find('GnuPG') > -1: self['systemSec.GPGVersion'] = so.splitlines()[0] _home = [ line.replace('Home:', '').lstrip() for line in so.splitlines() if line.startswith('Home:') ] self['systemSec.GPGHome'] = ''.join(_home) except Exception: pass try: import ssl self['systemSec.pythonSSL'] = True except ImportError: self['systemSec.pythonSSL'] = False # pyo for sound: if PY3: import importlib.util if importlib.util.find_spec('pyo') is not None: self['systemPyoVersion'] = '-' else: import imp try: imp.find_module('pyo') self['systemPyoVersion'] = '-' except: pass # try: # travis = bool(str(os.environ.get('TRAVIS')).lower() == 'true') # assert not travis # skip sound-related stuff on travis-ci.org # # import pyo # self['systemPyoVersion'] = '%i.%i.%i' % pyo.getVersion() # try: # # requires pyo svn r1024 or higher: # import psychopy.sound # inp, out = psychopy.sound.get_devices_infos() # for devList in [inp, out]: # for key in devList: # if isinstance(devList[key]['name'], str): # devList[key]['name'] = devList[key]['name'] # self['systemPyo.InputDevices'] = inp # self['systemPyo.OutputDevices'] = out # except AttributeError: # pass # except (AssertionError, ImportError): # pass # flac (free lossless audio codec) for google-speech: flacv = '' if sys.platform == 'win32': flacexe = 'C:\\Program Files\\FLAC\\flac.exe' if os.path.exists(flacexe): flacv = core.shellCall(flacexe + ' --version') else: flac, se = core.shellCall('which flac', stderr=True) if not se and flac and not flac.find('Command not found') > -1: flacv = core.shellCall('flac --version') if flacv: self['systemFlacVersion'] = flacv # detect internet access or fail quickly: # web.setupProxy() & web.testProxy(web.proxies) # can be slow # to fail if there's no connection self['systemHaveInternetAccess'] = web.haveInternetAccess() if not self['systemHaveInternetAccess']: self['systemHaveInternetAccess'] = 'False (proxies not attempted)'
def _setSystemInfo(self): """System info """ # machine name self['systemHostName'] = platform.node() self['systemMemTotalRAM'], self['systemMemFreeRAM'] = getRAM() # locale information: # (None, None) -> str loc = '.'.join([str(x) for x in locale.getlocale()]) if loc == 'None.None': loc = locale.setlocale(locale.LC_ALL, '') # == the locale in use, from OS or user-pref self['systemLocale'] = loc # platform name, etc if sys.platform in ['darwin']: OSXver, _junk, architecture = platform.mac_ver() platInfo = 'darwin ' + OSXver + ' ' + architecture # powerSource = ... elif sys.platform.startswith('linux'): platInfo = 'linux ' + platform.release() # powerSource = ... elif sys.platform in ['win32']: platInfo = 'windowsversion=' + repr(sys.getwindowsversion()) # powerSource = ... else: platInfo = ' [?]' # powerSource = ... self['systemPlatform'] = platInfo # self['systemPowerSource'] = powerSource # count all unique people (user IDs logged in), and find current user # name & UID self['systemUser'], self['systemUserID'] = _getUserNameUID() try: users = shellCall("who -q").splitlines()[0].split() self['systemUsersCount'] = len(set(users)) except Exception: self['systemUsersCount'] = False # when last rebooted? try: lastboot = shellCall("who -b").split() self['systemRebooted'] = ' '.join(lastboot[2:]) except Exception: # windows sysInfo = shellCall('systeminfo').splitlines() lastboot = [line for line in sysInfo if line.startswith( "System Up Time") or line.startswith("System Boot Time")] lastboot += ['[?]'] # put something in the list just in case self['systemRebooted'] = lastboot[0].strip() # R (and r2py) for stats: try: Rver = shellCall(["R", "--version"]) Rversion = Rver.splitlines()[0] if Rversion.startswith('R version'): self['systemRavailable'] = Rversion.strip() try: import rpy2 self['systemRpy2'] = rpy2.__version__ except ImportError: pass except Exception: pass # encryption / security tools: try: vers, se = shellCall('openssl version', stderr=True) if se: vers = str(vers) + se.replace('\n', ' ')[:80] if vers.strip(): self['systemSec.OpenSSLVersion'] = vers except Exception: pass try: so = shellCall(['gpg', '--version']) if so.find('GnuPG') > -1: self['systemSec.GPGVersion'] = so.splitlines()[0] _home = [line.replace('Home:', '').lstrip() for line in so.splitlines() if line.startswith('Home:')] self['systemSec.GPGHome'] = ''.join(_home) except Exception: pass try: import ssl self['systemSec.pythonSSL'] = True except ImportError: self['systemSec.pythonSSL'] = False # pyo for sound: if PY3: import importlib.util if importlib.util.find_spec('pyo') is not None: self['systemPyoVersion'] = '-' else: import imp try: imp.find_module('pyo') self['systemPyoVersion'] = '-' except: pass # try: # travis = bool(str(os.environ.get('TRAVIS')).lower() == 'true') # assert not travis # skip sound-related stuff on travis-ci.org # # import pyo # self['systemPyoVersion'] = '%i.%i.%i' % pyo.getVersion() # try: # # requires pyo svn r1024 or higher: # import psychopy.sound # inp, out = psychopy.sound.get_devices_infos() # for devList in [inp, out]: # for key in devList: # if isinstance(devList[key]['name'], str): # devList[key]['name'] = devList[key]['name'] # self['systemPyo.InputDevices'] = inp # self['systemPyo.OutputDevices'] = out # except AttributeError: # pass # except (AssertionError, ImportError): # pass # flac (free lossless audio codec) for google-speech: flacv = '' if sys.platform == 'win32': flacexe = 'C:\\Program Files\\FLAC\\flac.exe' if os.path.exists(flacexe): flacv = core.shellCall(flacexe + ' --version') else: flac, se = core.shellCall('which flac', stderr=True) if not se and flac and not flac.find('Command not found') > -1: flacv = core.shellCall('flac --version') if flacv: self['systemFlacVersion'] = flacv # detect internet access or fail quickly: # web.setupProxy() & web.testProxy(web.proxies) # can be slow # to fail if there's no connection self['systemHaveInternetAccess'] = web.haveInternetAccess() if not self['systemHaveInternetAccess']: self['systemHaveInternetAccess'] = 'False (proxies not attempted)'
def show_response(self): self.response = web.haveInternetAccess() return self.response
def _setSystemInfo(self): # machine name self['systemHostName'] = platform.node() self['systemMemTotalRAM'], self['systemMemFreeRAM'] = getRAM() # locale information: import locale loc = '.'.join(map(str,locale.getlocale())) # (None, None) -> str if loc == 'None.None': loc = locale.setlocale(locale.LC_ALL,'') self['systemLocale'] = loc # == the locale in use, from OS or user-pref # platform name, etc if sys.platform in ['darwin']: OSXver, junk, architecture = platform.mac_ver() platInfo = 'darwin '+OSXver+' '+architecture # powerSource = ... elif sys.platform.startswith('linux'): platInfo = 'linux '+platform.release() # powerSource = ... elif sys.platform in ['win32']: platInfo = 'windowsversion='+repr(sys.getwindowsversion()) # powerSource = ... else: platInfo = ' [?]' # powerSource = ... self['systemPlatform'] = platInfo #self['systemPowerSource'] = powerSource # count all unique people (user IDs logged in), and find current user name & UID self['systemUser'],self['systemUserID'] = _getUserNameUID() try: users = shellCall("who -q").splitlines()[0].split() self['systemUsersCount'] = len(set(users)) except: self['systemUsersCount'] = False # when last rebooted? try: lastboot = shellCall("who -b").split() self['systemRebooted'] = ' '.join(lastboot[2:]) except: # windows sysInfo = shellCall('systeminfo').splitlines() lastboot = [line for line in sysInfo if line.find("System Up Time") == 0 or line.find("System Boot Time") == 0] lastboot += ['[?]'] # put something in the list just in case self['systemRebooted'] = lastboot[0].strip() # R (and r2py) for stats: try: Rver,err = shellCall("R --version",stderr=True) Rversion = Rver.splitlines()[0] if Rversion.startswith('R version'): self['systemRavailable'] = Rversion.strip() try: import rpy2 self['systemRpy2'] = rpy2.__version__ except: pass except: pass # encryption / security tools: try: vers, se = shellCall('openssl version', stderr=True) if se: vers = str(vers) + se.replace('\n',' ')[:80] if vers.strip(): self['systemSec.OpenSSLVersion'] = vers except: pass try: so, se = shellCall('gpg --version', stderr=True) if so.find('GnuPG') > -1: self['systemSec.GPGVersion'] = so.splitlines()[0] self['systemSec.GPGHome'] = ''.join([line.replace('Home:','').lstrip() for line in so.splitlines() if line.startswith('Home:')]) except: pass try: import ssl self['systemSec.pythonSSL'] = True except ImportError: self['systemSec.pythonSSL'] = False # pyo for sound: try: import pyo self['systemPyoVersion'] = '%i.%i.%i' % pyo.getVersion() try: # requires pyo svn r1024 or higher: inp, out = pyo.pa_get_devices_infos() self['systemPyo.InputDevices'] = inp self['systemPyo.OutputDevices'] = out except AttributeError: pass except ImportError: pass # flac (free lossless audio codec) for google-speech: flacv = '' if sys.platform == 'win32': flacexe = 'C:\\Program Files\\FLAC\\flac.exe' if os.path.exists(flacexe): flacv = core.shellCall(flacexe + ' --version') else: flac, se = core.shellCall('which flac', stderr=True) if not se and flac and not flac.find('Command not found') > -1: flacv = core.shellCall('flac --version') if flacv: self['systemFlacVersion'] = flacv # detect internet access or fail quickly: #web.setupProxy() & web.testProxy(web.proxies) # can take a long time to fail if there's no connection self['systemHaveInternetAccess'] = web.haveInternetAccess() if not self['systemHaveInternetAccess']: self['systemHaveInternetAccess'] = 'False (proxies not attempted)'
class RunTimeInfo(dict): """Returns a snapshot of your configuration at run-time, for immediate or archival use. Returns a dict-like object with info about PsychoPy, your experiment script, the system & OS, your window and monitor settings (if any), python & packages, and openGL. If you want to skip testing the refresh rate, use 'refreshTest=None' Example usage: see runtimeInfo.py in coder demos. :Author: - 2010 written by Jeremy Gray, with input from Jon Peirce and Alex Holcombe """ def __init__(self, author=None, version=None, win=None, refreshTest='grating', userProcsDetailed=False, verbose=False): """ :Parameters: win : *None*, False, :class:`~psychopy.visual.Window` instance what window to use for refresh rate testing (if any) and settings. None -> temporary window using defaults; False -> no window created, used, nor profiled; a Window() instance you have already created author : *None*, string None = try to autodetect first __author__ in sys.argv[0]; string = user-supplied author info (of an experiment) version : *None*, string None = try to autodetect first __version__ in sys.argv[0]; string = user-supplied version info (of an experiment) verbose : *False*, True; how much detail to assess refreshTest : None, False, True, *'grating'* True or 'grating' = assess refresh average, median, and SD of 60 win.flip()s, using visual.getMsPerFrame() 'grating' = show a visual during the assessment; True = assess without a visual userProcsDetailed: *False*, True get details about concurrent user's processses (command, process-ID) :Returns: a flat dict (but with several groups based on key names): psychopy : version, rush() availability psychopyVersion, psychopyHaveExtRush, git branch and current commit hash if available experiment : author, version, directory, name, current time-stamp, SHA1 digest, VCS info (if any, svn or hg only), experimentAuthor, experimentVersion, ... system : hostname, platform, user login, count of users, user process info (count, cmd + pid), flagged processes systemHostname, systemPlatform, ... window : (see output; many details about the refresh rate, window, and monitor; units are noted) windowWinType, windowWaitBlanking, ...windowRefreshTimeSD_ms, ... windowMonitor.<details>, ... python : version of python, versions of key packages (wx, numpy, scipy, matplotlib, pyglet, pygame) pythonVersion, pythonScipyVersion, ... openGL : version, vendor, rendering engine, plus info on whether several extensions are present openGLVersion, ..., openGLextGL_EXT_framebuffer_object, ... """ dict.__init__( self ) # this will cause an object to be created with all the same methods as a dict self['psychopyVersion'] = psychopyVersion self['psychopyHaveExtRush'] = rush( False ) # NB: this looks weird, but avoids setting high-priority incidentally d = os.path.abspath(os.path.dirname(__file__)) githash = _getHashGitHead(d) # should be .../psychopy/psychopy/ if githash: self['psychopyGitHead'] = githash self._setExperimentInfo(author, version, verbose) self._setSystemInfo() # current user, locale, other software self._setCurrentProcessInfo(verbose, userProcsDetailed) # need a window for frame-timing, and some openGL drivers want a window open if win is None: # make a temporary window, later close it win = visual.Window(fullscr=True, monitor="testMonitor", autoLog=False) refreshTest = 'grating' usingTempWin = True elif win != False: # we were passed a window instance, use it for timing and profile it: usingTempWin = False self.winautoLog = win.autoLog win.autoLog = False else: # don't want any window usingTempWin = False if win: self._setWindowInfo(win, verbose, refreshTest, usingTempWin) self['pythonVersion'] = sys.version.split()[0] if verbose: self._setPythonInfo() if win: self._setOpenGLInfo() if usingTempWin: win.close() # close after doing openGL elif win != False: win.autoLog = self.winautoLog # restore def _setExperimentInfo(self, author, version, verbose): # try to auto-detect __author__ and __version__ in sys.argv[0] (= the users's script) if not author or not version: if os.path.isfile(sys.argv[0]): f = open(sys.argv[0], 'r') lines = f.read() f.close() if not author and '__author__' in lines: linespl = lines.splitlines() while linespl[0].find('__author__') == -1: linespl.pop(0) auth = linespl[0] if len(auth) and '=' in auth: try: author = str(eval(auth[auth.find('=') + 1:])) except: pass if not version and '__version__' in lines: linespl = lines.splitlines() while linespl[0].find('__version__') == -1: linespl.pop(0) ver = linespl[0] if len(ver) and ver.find('=') > 0: try: version = str(eval(ver[ver.find('=') + 1:])) except: pass if author or verbose: self['experimentAuthor'] = author if version or verbose: self['experimentAuthVersion'] = version # script identity & integrity information: self['experimentScript'] = os.path.basename(sys.argv[0]) # file name scriptDir = os.path.dirname(os.path.abspath(sys.argv[0])) self['experimentScript.directory'] = scriptDir # sha1 digest, text-format compatibility self['experimentScript.digestSHA1'] = _getSha1hexDigest( os.path.abspath(sys.argv[0]), isfile=True) # subversion revision? try: svnrev, last, url = _getSvnVersion(os.path.abspath( sys.argv[0])) # svn revision if svnrev: # or verbose: self['experimentScript.svnRevision'] = svnrev self['experimentScript.svnRevLast'] = last self['experimentScript.svnRevURL'] = url except: pass # mercurical revision? try: hgChangeSet = _getHgVersion(os.path.abspath(sys.argv[0])) if hgChangeSet: # or verbose: self['experimentScript.hgChangeSet'] = hgChangeSet except: pass # when was this run? self['experimentRunTime.epoch'] = core.getAbsTime() self['experimentRunTime'] = data.getDateStr( format="%Y_%m_%d %H:%M (Year_Month_Day Hour:Min)") def _setSystemInfo(self): """system info""" # system encoding osEncoding = sys.getfilesystemencoding() # machine name self['systemHostName'] = platform.node() self['systemMemTotalRAM'], self['systemMemFreeRAM'] = getRAM() # locale information: loc = '.'.join([str(x) for x in locale.getlocale()]) # (None, None) -> str if loc == 'None.None': loc = locale.setlocale(locale.LC_ALL, '') self[ 'systemLocale'] = loc # == the locale in use, from OS or user-pref # platform name, etc if sys.platform in ['darwin']: OSXver, _junk, architecture = platform.mac_ver() platInfo = 'darwin ' + OSXver + ' ' + architecture # powerSource = ... elif sys.platform.startswith('linux'): platInfo = 'linux ' + platform.release() # powerSource = ... elif sys.platform in ['win32']: platInfo = 'windowsversion=' + repr(sys.getwindowsversion()) # powerSource = ... else: platInfo = ' [?]' # powerSource = ... self['systemPlatform'] = platInfo #self['systemPowerSource'] = powerSource # count all unique people (user IDs logged in), and find current user name & UID self['systemUser'], self['systemUserID'] = _getUserNameUID() try: users = shellCall("who -q").splitlines()[0].split() self['systemUsersCount'] = len(set(users)) except: self['systemUsersCount'] = False # when last rebooted? try: lastboot = shellCall("who -b").split() self['systemRebooted'] = ' '.join(lastboot[2:]) except: # windows sysInfo = shellCall('systeminfo').splitlines() lastboot = [ line for line in sysInfo if line.startswith("System Up Time") or line.startswith("System Boot Time") ] lastboot += ['[?]'] # put something in the list just in case self['systemRebooted'] = lastboot[0].strip() # R (and r2py) for stats: try: Rver = shellCall(["R", "--version"]) Rversion = Rver.splitlines()[0] if Rversion.startswith('R version'): self['systemRavailable'] = Rversion.strip() try: import rpy2 self['systemRpy2'] = rpy2.__version__ except ImportError: pass except: pass # encryption / security tools: try: vers, se = shellCall('openssl version', stderr=True) if se: vers = str(vers) + se.replace('\n', ' ')[:80] if vers.strip(): self['systemSec.OpenSSLVersion'] = vers except: pass try: so = shellCall(['gpg', '--version']) if so.find('GnuPG') > -1: self['systemSec.GPGVersion'] = so.splitlines()[0] self['systemSec.GPGHome'] = ''.join([ line.replace('Home:', '').lstrip() for line in so.splitlines() if line.startswith('Home:') ]) except: pass try: import ssl self['systemSec.pythonSSL'] = True except ImportError: self['systemSec.pythonSSL'] = False # pyo for sound: try: travis = bool(str(os.environ.get('TRAVIS')).lower() == 'true') assert not travis # skip sound-related stuff on travis-ci.org import pyo self['systemPyoVersion'] = '%i.%i.%i' % pyo.getVersion() try: # requires pyo svn r1024 or higher: inp, out = pyo.pa_get_devices_infos() for devList in [inp, out]: for key in devList.keys(): if isinstance(devList[key]['name'], str): devList[key]['name'] = devList[key]['name'].decode( osEncoding) self['systemPyo.InputDevices'] = inp self['systemPyo.OutputDevices'] = out except AttributeError: pass except AssertionError, ImportError: pass # flac (free lossless audio codec) for google-speech: flacv = '' if sys.platform == 'win32': flacexe = 'C:\\Program Files\\FLAC\\flac.exe' if os.path.exists(flacexe): flacv = core.shellCall(flacexe + ' --version') else: flac, se = core.shellCall('which flac', stderr=True) if not se and flac and not flac.find('Command not found') > -1: flacv = core.shellCall('flac --version') if flacv: self['systemFlacVersion'] = flacv # detect internet access or fail quickly: #web.setupProxy() & web.testProxy(web.proxies) # can take a long time to fail if there's no connection self['systemHaveInternetAccess'] = web.haveInternetAccess() if not self['systemHaveInternetAccess']: self['systemHaveInternetAccess'] = 'False (proxies not attempted)'