msi.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Copyright (C) 2001-2006 William Joseph.
  2. #
  3. # This file is part of GtkRadiant.
  4. #
  5. # GtkRadiant is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # GtkRadiant is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with GtkRadiant; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. import msiquery
  19. class Record:
  20. def __init__(self, record):
  21. self.record = record
  22. def setstring(self, index, string):
  23. self.record.setstring(index, string)
  24. class View:
  25. def __init__(self, view):
  26. self.view = view
  27. def fetch(self):
  28. record = self.view.fetch()
  29. if(record == None):
  30. raise Exception("no records available")
  31. return Record(record)
  32. def update(self, record):
  33. self.view.update(record.record)
  34. class Database:
  35. def __init__(self, name):
  36. self.msiDB = msiquery.MsiDB(name)
  37. def commit(self):
  38. result = self.msiDB.commit()
  39. if(result != 0):
  40. raise Exception("msi commit failed: error " + str(result))
  41. def openview(self, query):
  42. view = self.msiDB.openview(query)
  43. if(view == None):
  44. raise Exception("msi openview failed")
  45. return View(view);
  46. def setproperty(self, propertyName, propertyValue):
  47. query = "UPDATE `Property` SET `Property`.`Value`='" + propertyValue + "' WHERE `Property`.`Property`='" + propertyName + "'"
  48. self.openview(query)
  49. def setlicense(self, rtfString):
  50. view = self.openview("SELECT `Control`.`Text` FROM `Control` WHERE `Control`.`Control`='AgreementText'")
  51. record = view.fetch();
  52. record.setstring(1, rtfString)
  53. view.update(record)