Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: installer/emb.py

Issue 4565805475823616: Issue 1984 - Do not use VBScript in installer build tools (Closed)
Patch Set: Created April 13, 2015, 10:39 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | installer/emb.vbs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: installer/emb.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/installer/emb.py
@@ -0,0 +1,29 @@
+import sys
+import msilib
+import argparse
+
+def main():
+ # Check arguments
+ parser = argparse.ArgumentParser(description='Embed .mst transform into the MSI database.')
+ parser.add_argument('storageName', metavar='storageName', help="The name of the storage (language name)")
+ parser.add_argument('databasePath', metavar='databasePath', help="Path to MSI in which to embed")
+ parser.add_argument('importPath', metavar='importPath', help="Path to transform file (.mst)")
+
+ args = parser.parse_args();
+ # Open database and create a view on the _Storages table
+ sqlQuery = "SELECT `Name`,`Data` FROM _Storages"
+ database = msilib.OpenDatabase(args.databasePath, 1)
+ view = database.OpenView(sqlQuery)
+
+ # Create and Insert the row with 2 fields.
+ record = msilib.CreateRecord(2)
+ record.SetString(1, args.storageName)
+ view.Execute(record)
+
+ # Insert storage - copy data into stream
+ record.SetStream(2, args.importPath)
+ view.Modify(3, record)
+ database.Commit()
+
+if __name__ == "__main__":
+ main()
« no previous file with comments | « no previous file | installer/emb.vbs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld