| 134 | v.Close() |
| 135 | |
| 136 | def init_database(name, schema, |
| 137 | ProductName, ProductCode, ProductVersion, |
| 138 | Manufacturer): |
| 139 | try: |
| 140 | os.unlink(name) |
| 141 | except OSError: |
| 142 | pass |
| 143 | ProductCode = ProductCode.upper() |
| 144 | # Create the database |
| 145 | db = OpenDatabase(name, MSIDBOPEN_CREATE) |
| 146 | # Create the tables |
| 147 | for t in schema.tables: |
| 148 | t.create(db) |
| 149 | # Fill the validation table |
| 150 | add_data(db, "_Validation", schema._Validation_records) |
| 151 | # Initialize the summary information, allowing atmost 20 properties |
| 152 | si = db.GetSummaryInformation(20) |
| 153 | si.SetProperty(PID_TITLE, "Installation Database") |
| 154 | si.SetProperty(PID_SUBJECT, ProductName) |
| 155 | si.SetProperty(PID_AUTHOR, Manufacturer) |
| 156 | if AMD64: |
| 157 | si.SetProperty(PID_TEMPLATE, "x64;1033") |
| 158 | else: |
| 159 | si.SetProperty(PID_TEMPLATE, "Intel;1033") |
| 160 | si.SetProperty(PID_REVNUMBER, gen_uuid()) |
| 161 | si.SetProperty(PID_WORDCOUNT, 2) # long file names, compressed, original media |
| 162 | si.SetProperty(PID_PAGECOUNT, 200) |
| 163 | si.SetProperty(PID_APPNAME, "Python MSI Library") |
| 164 | # XXX more properties |
| 165 | si.Persist() |
| 166 | add_data(db, "Property", [ |
| 167 | ("ProductName", ProductName), |
| 168 | ("ProductCode", ProductCode), |
| 169 | ("ProductVersion", ProductVersion), |
| 170 | ("Manufacturer", Manufacturer), |
| 171 | ("ProductLanguage", "1033")]) |
| 172 | db.Commit() |
| 173 | return db |
| 174 | |
| 175 | def add_tables(db, module): |
| 176 | for table in module.tables: |