[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-logonpy/usr/share/se3/logonpy/ -> se3DB.py (source)

   1  # -*- coding: utf-8 -*-
   2  # $Id: se3DB.py 6880 2012-02-06 18:06:27Z dbo $
   3  import sys, MySQLdb, os
   4  sys.path.append('/etc/se3/python/')
   5  from  mysqlinfo import *
   6  
   7  class se3DB:
   8  
   9      def __init__ (self,user, arch):
  10          """
  11              Connect to se3db base 
  12          """
  13          try:
  14              self.__db = MySQLdb.connect(dbhost, dbuser, dbpass, dbname)
  15              self.__user = user
  16              self.__arch = arch
  17          except MySQLdb.Error, e:
  18              print "Error %d: %s" % (e.args[0], e.args[1])
  19              sys.exit (1)
  20  
  21      def __del__ (self):
  22          """
  23              Close connexion
  24          """
  25          self.__db.close ()
  26  
  27      def getValue (self, name):
  28          """
  29              Get a value from params table
  30          """
  31          try:
  32              cursor = self.__db.cursor ()
  33              cursor.execute ("SELECT value FROM params where name = %s" , name)
  34              row = cursor.fetchone ()
  35              cursor.close ()
  36              return row[0]
  37  
  38          except TypeError:
  39              return 0
  40  
  41  
  42      def setValue (self, name, value):
  43          """
  44              Set a value in params table
  45          """
  46          query = "UPDATE params SET  value = '" + value + \
  47                  "' where name = '" + name + "'"
  48          cursor = self.__db.cursor ()
  49          cursor.execute ("UPDATE params SET value = %s WHERE name = %s" ,\
  50                          (value, name))
  51          cursor.close ()
  52  
  53      def getRestrictions(self, templates):
  54          """
  55              Return restriction list for a template
  56          """
  57          results = {}
  58          rest = []
  59          wallModule = False
  60          tileWallSet = False
  61  
  62          if ( os.access ("/var/se3/Docs/media/fonds_ecran/%s.bmp" % self.__user, os.F_OK) or \
  63             os.access ("/var/se3/Docs/media/fonds_ecran/%s.jpg" % self.__user, os.F_OK) ):
  64              wallModule = True
  65  
  66          cursor = self.__db.cursor()
  67          query = "Select Intitule,corresp.CleID,corresp.valeur,genre,OS,antidote,type,chemin,restrictions.valeur,restrictions.priorite FROM corresp,restrictions WHERE corresp.CleID = restrictions.cleID AND OS!=\"Win9x\" AND ( "
  68          i = 0
  69          for template in templates:
  70              print(template)
  71              if i == 0 :
  72                  query += " groupe=\"" + template + "\""
  73              else:
  74                  query += " OR groupe=\"" + template +"\""
  75              i += 1
  76          query += " ) GROUP BY CleID,restrictions.valeur ORDER BY priorite ASC"
  77  #        print (query)
  78          cursor.execute (query)
  79          for row in cursor.fetchall ():
  80              rest.append ((row[7], row[3], row[4], row[8]))
  81  #
  82  #            for result in cursor.fetchall ():
  83  #                results[result[0]] = result[1]
  84  #
  85  #        for key in results.keys():
  86  #            cursor.execute ("SELECT Chemin, Genre, OS FROM corresp where CleID='%s'\
  87  #                                    and OS!=\"Win9x\"", key)
  88  #            row2 = cursor.fetchone ()
  89  #
  90  #            if row2 != None:
  91  #                # Disable wallpaper key if wall module active
  92  #                if wallModule:
  93  #                    if not row2[0] in "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ClassicShell" \
  94  #                                      "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ForceActiveDesktopOn" \
  95  #                                      "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop\NoHTMLWallpaper":
  96  #
  97  #                        rest.append ((row2[0], row2[1], row2[2], results[key]))
  98  #                    if row2[0] == "HKEY_CURRENT_USER\Control Panel\Desktop\TileWallpaper":
  99  #                        tileWallSet = True
 100  #                        rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\WallpaperStyle",\
 101  #                              "REG_SZ", "2000,XP,Vista,Seven", results[key]))
 102  #                else:
 103  #                    rest.append ((row2[0], row2[1], row2[2], results[key]))
 104  
 105          cursor.close ()
 106  
 107          if self.getValue ("localmenu") == "1":
 108              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Programs', 'REG_EXPAND_SZ', '2000,XP,Vista,Seven','%USERPROFILE%\Demarrer\Programmes'))
 109              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Start Menu', 'REG_EXPAND_SZ', '2000,XP,Vista,Seven','%USERPROFILE%\Demarrer'))
 110              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Startup', 'REG_EXPAND_SZ', '2000,XP,Vista,Seven', '%USERPROFILE%\Demarrer\Programmes\Démarrage'.decode('utf8').encode('iso-8859-15')))
 111          else:
 112              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Programs', 'REG_EXPAND_SZ', '2000,XP,Vista,Seven', 'K:\profil\Demarrer\Programmes'))
 113              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Start Menu', 'REG_EXPAND_SZ', '2000,XP,Vista,Seven', 'K:\profil\Demarrer'))
 114              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Startup', 'REG_EXPAND_SZ', '2000,XP,Vista,Seven', 'K:\profil\Demarrer\Programmes\Démarrage'.decode('utf8').encode('iso-8859-15')))
 115  
 116          if self.getValue ("mes_docs"):
 117              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal', 'REG_EXPAND_SZ', '2000,XP,Vista,Seven', self.getValue ("mes_docs")))
 118          else:
 119              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal', 'REG_EXPAND_SZ', '2000,XP,Vista,Seven', 'K:\Docs'))
 120  
 121          if self.getValue ("corbeille") == "1":
 122              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{00000000-0000-0000-0000-000000210979}\\",\
 123                           "REG_SZ", "2000,XP,Vista,Seven", "Corbeille Réseau"))
 124              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-0000-0000-0000-000000210979}\\",\
 125                           "REG_SZ", "2000,XP,Vista,Seven", "Corbeille Réseau"))
 126              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\NonEnum\{00000000-0000-0000-0000-000000210979}",\
 127                           "REG_DWORD", "2000,XP,Vista,Seven", "0"))
 128          else:
 129              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\NonEnum\{00000000-0000-0000-0000-000000210979}",\
 130                           "REG_DWORD", "2000,XP,Vista,Seven", "1"))
 131  
 132          if self.getValue ("hide_logon") == "0":
 133              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\HideLogonScripts', 'REG_DWORD', 'XP', '0'))
 134          else:
 135              rest.append (('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\HideLogonScripts', 'REG_DWORD', 'XP', '1'))
 136  
 137          if wallModule:
 138              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ClassicShell",\
 139                           "REG_DWORD", "Vista,Seven", "SUPPR"))
 140              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ForceActiveDesktopOn",\
 141                           "REG_DWORD", "2000,XP", "0"))
 142              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ForceActiveDesktopOn",\
 143                           "REG_DWORD", "Vista,Seven", "1"))
 144              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoActiveDesktop",\
 145                           "REG_DWORD", "2000,XP", "1"))
 146              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop\NoChangingWallpaper",\
 147                           "REG_DWORD", "2000,XP,Vista,Seven", "1"))
 148              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop\NoHTMLWallpaper",\
 149                           "REG_DWORD", "Vista,Seven", "SUPPR"))
 150              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\Wallpaper",\
 151                           "REG_SZ", "2000,XP", "C:\Windows\Web\Wallpaper\%s_se3.bmp" % self.__user))
 152              rest.append (("HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",\
 153                           "REG_SZ", "2000,XP", "C:\Windows\Web\Wallpaper\\%s_se3.bmp" % self.__user))
 154              rest.append (("HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",\
 155                           "REG_DWORD", "2000,XP", "PROTECT"))          
 156              rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\Wallpaper",\
 157                           "REG_SZ", "Vista,Seven", "C:\Windows\Web\Wallpaper\%s_se3.jpg" % self.__user))
 158              rest.append (("HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",\
 159                           "REG_SZ", "Vista,Seven", "C:\Windows\Web\Wallpaper\%s_se3.jpg" % self.__user))
 160              if not tileWallSet:
 161                  rest.append (("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\WallpaperStyle",\
 162                           "REG_SZ", "2000,XP,Vista,Seven", "2"))
 163          return rest


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1