home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / JunkMatcher 1.5.5.dmg / JunkMatcher.app / Contents / Resources / sysInfo.py < prev    next >
Encoding:
Python Source  |  2005-06-01  |  2.0 KB  |  58 lines

  1. #
  2. #  sysInfo.py
  3. #  JunkMatcher
  4. #
  5. #  Created by Benjamin Han on 3/11/05.
  6. #  Copyright (c) 2005 Benjamin Han. All rights reserved.
  7. #
  8.  
  9. # This program is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU General Public License
  11. # as published by the Free Software Foundation; either version 2
  12. # of the License, or (at your option) any later version.
  13.  
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU General Public License for more details.
  18.  
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  
  23. #/usr/bin/env python
  24.  
  25. import os, sys, re
  26.  
  27.  
  28. def sysInfo ():
  29.     myID=os.environ['USER']
  30.  
  31.     osVersion = os.popen('sw_vers -productVersion').read().rstrip()
  32.     osBuild = os.popen('sw_vers -buildVersion').read().rstrip()
  33.     darwinVer = os.popen('uname -r').read().rstrip()
  34.  
  35.     admins = os.popen('/usr/bin/niutil -readprop . /groups/admin users').read().rstrip().split(' ')
  36.     shell = os.popen('/usr/bin/niutil -readprop . /users/%s shell' % myID).read().rstrip()
  37.  
  38.     sysProfile = os.popen('/usr/sbin/system_profiler SPHardwareDataType').read().strip()
  39.     machineModel = re.compile(r'(?i)Machine Model: ([^\n]+)').search(sysProfile).group(1)
  40.     cpu = re.compile(r'(?i)CPU Speed: ([^\n]+)').search(sysProfile).group(1)
  41.     mem = re.compile(r'(?i)Memory: ([^\n]+)').search(sysProfile).group(1)
  42.  
  43.     ret = []
  44.     ret.append('OS: %s %s (%s)' % (osVersion, osBuild, darwinVer))
  45.     ret.append('Machine: %s; CPU: %s; Memory: %s' % (machineModel , cpu, mem))
  46.     if myID in admins:
  47.         ret.append('Running as an admin, using shell %s' % shell)
  48.     else:
  49.         ret.append('Running as a non-admin, using shell %s' % shell)
  50.  
  51.     ret.append('Python version %s' % sys.version)
  52.  
  53.     return '\n'.join(ret)
  54.  
  55.  
  56. if __name__ == '__main__':
  57.     print sysInfo()
  58.