Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3b6cc09

Browse files
committed
Revert r63378. These files need to stay compatible with Python 2.x (until Python 3.0 is actually used to package Python).
1 parent 5a72240 commit 3b6cc09

6 files changed

Lines changed: 1884 additions & 1879 deletions

File tree

Tools/msi/merge.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ def merge(msi, feature, rootdir, modules):
1919
# Step 1: Merge databases, extract cabfiles
2020
m = msilib.MakeMerge2()
2121
m.OpenLog("merge.log")
22-
print("Opened Log")
22+
print "Opened Log"
2323
m.OpenDatabase(msi)
24-
print("Opened DB")
24+
print "Opened DB"
2525
for module in modules:
26-
print(module)
26+
print module
2727
m.OpenModule(module,0)
28-
print("Opened Module",module)
28+
print "Opened Module",module
2929
m.Merge(feature, rootdir)
30-
print("Errors:")
30+
print "Errors:"
3131
for e in m.Errors:
32-
print(e.Type, e.ModuleTable, e.DatabaseTable)
33-
print(" Modkeys:", end=' ')
34-
for s in e.ModuleKeys: print(s, end=' ')
35-
print()
36-
print(" DBKeys:", end=' ')
37-
for s in e.DatabaseKeys: print(s, end=' ')
38-
print()
32+
print e.Type, e.ModuleTable, e.DatabaseTable
33+
print " Modkeys:",
34+
for s in e.ModuleKeys: print s,
35+
print
36+
print " DBKeys:",
37+
for s in e.DatabaseKeys: print s,
38+
print
3939
cabname = tempfile.mktemp(suffix=".cab")
4040
m.ExtractCAB(cabname)
4141
cab_and_filecount.append((cabname, len(m.ModuleFiles)))
@@ -56,7 +56,7 @@ def merge(msi, feature, rootdir, modules):
5656
seq = r.IntegerData(1)
5757
if seq > maxmedia:
5858
maxmedia = seq
59-
print("Start of Media", maxmedia)
59+
print "Start of Media", maxmedia
6060

6161
for cabname, count in cab_and_filecount:
6262
stream = "merged%d" % maxmedia

Tools/msi/msi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def build_database():
204204
schema, ProductName="Python "+full_current_version,
205205
ProductCode=product_code,
206206
ProductVersion=current_version,
207-
Manufacturer="Python Software Foundation")
207+
Manufacturer=u"Python Software Foundation")
208208
# The default sequencing of the RemoveExistingProducts action causes
209209
# removal of files that got just installed. Place it after
210210
# InstallInitialize, so we first uninstall everything, but still roll

Tools/msi/msilib.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
import win32com.client
66
import pythoncom, pywintypes
77
from win32com.client import constants
8-
import re, string, os, sets, glob, subprocess, sys, winreg, struct
8+
import re, string, os, sets, glob, subprocess, sys, _winreg, struct
9+
10+
try:
11+
basestring
12+
except NameError:
13+
basestring = (str, unicode)
914

1015
# Partially taken from Wine
1116
datasizemask= 0x00ff
@@ -90,7 +95,7 @@ def sql(self):
9095
index -= 1
9196
unk = type & ~knownbits
9297
if unk:
93-
print("%s.%s unknown bits %x" % (self.name, name, unk))
98+
print "%s.%s unknown bits %x" % (self.name, name, unk)
9499
size = type & datasizemask
95100
dtype = type & typemask
96101
if dtype == type_string:
@@ -109,7 +114,7 @@ def sql(self):
109114
tname="OBJECT"
110115
else:
111116
tname="unknown"
112-
print("%s.%sunknown integer type %d" % (self.name, name, size))
117+
print "%s.%sunknown integer type %d" % (self.name, name, size)
113118
if type & type_nullable:
114119
flags = ""
115120
else:
@@ -168,14 +173,14 @@ def gen_schema(destpath, schemapath):
168173
r = v.Fetch()
169174
if not r:break
170175
# Table, Column, Nullable
171-
f.write("(%r,%r,%r," %
172-
(r.StringData(1), r.StringData(2), r.StringData(3)))
176+
f.write("(%s,%s,%s," %
177+
(`r.StringData(1)`, `r.StringData(2)`, `r.StringData(3)`))
173178
def put_int(i):
174179
if r.IsNull(i):f.write("None, ")
175180
else:f.write("%d," % r.IntegerData(i))
176181
def put_str(i):
177182
if r.IsNull(i):f.write("None, ")
178-
else:f.write("%r," % r.StringData(i))
183+
else:f.write("%s," % `r.StringData(i)`)
179184
put_int(4) # MinValue
180185
put_int(5) # MaxValue
181186
put_str(6) # KeyTable
@@ -197,7 +202,7 @@ def gen_sequence(destpath, msipath):
197202
v = seqmsi.OpenView("SELECT * FROM _Tables");
198203
v.Execute(None)
199204
f = open(destpath, "w")
200-
f.write("import msilib,os;dirname=os.path.dirname(__file__)\n")
205+
print >>f, "import msilib,os;dirname=os.path.dirname(__file__)"
201206
tables = []
202207
while 1:
203208
r = v.Fetch()
@@ -230,12 +235,12 @@ def gen_sequence(destpath, msipath):
230235
else:
231236
rec.append(bytes)
232237
else:
233-
raise ValueError("Unsupported column type", info.StringData(i))
238+
raise "Unsupported column type", info.StringData(i)
234239
f.write(repr(tuple(rec))+",\n")
235240
v1.Close()
236241
f.write("]\n\n")
237242
v.Close()
238-
f.write("tables=%s\n" % repr(list(map(str,tables))))
243+
f.write("tables=%s\n" % repr(map(str,tables)))
239244
f.close()
240245

241246
class _Unspecified:pass
@@ -249,7 +254,7 @@ def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified):
249254
seqno = seq[i][2]
250255
seq[i] = (action, cond, seqno)
251256
return
252-
raise ValueError("Action not found in sequence")
257+
raise ValueError, "Action not found in sequence"
253258

254259
def add_data(db, table, values):
255260
d = MakeInstaller()
@@ -260,16 +265,16 @@ def add_data(db, table, values):
260265
assert len(value) == count, value
261266
for i in range(count):
262267
field = value[i]
263-
if isinstance(field, int):
268+
if isinstance(field, (int, long)):
264269
r.SetIntegerData(i+1,field)
265-
elif isinstance(field, str):
270+
elif isinstance(field, basestring):
266271
r.SetStringData(i+1,field)
267272
elif field is None:
268273
pass
269274
elif isinstance(field, Binary):
270275
r.SetStream(i+1, field.name)
271276
else:
272-
raise TypeError("Unsupported type %s" % field.__class__.__name__)
277+
raise TypeError, "Unsupported type %s" % field.__class__.__name__
273278
v.Modify(win32com.client.constants.msiViewModifyInsert, r)
274279
r.ClearData()
275280
v.Close()
@@ -365,9 +370,9 @@ def append(self, full, file, logical = None):
365370
logical = self.gen_id(dir, file)
366371
self.index += 1
367372
if full.find(" ")!=-1:
368-
self.file.write('"%s" %s\n' % (full, logical))
373+
print >>self.file, '"%s" %s' % (full, logical)
369374
else:
370-
self.file.write('%s %s\n' % (full, logical))
375+
print >>self.file, '%s %s' % (full, logical)
371376
return self.index, logical
372377

373378
def commit(self, db):
@@ -382,17 +387,17 @@ def commit(self, db):
382387
(r"Software\Microsoft\Win32SDK\Directories", "Install Dir"),
383388
]:
384389
try:
385-
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, k)
386-
dir = winreg.QueryValueEx(key, v)[0]
387-
winreg.CloseKey(key)
390+
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, k)
391+
dir = _winreg.QueryValueEx(key, v)[0]
392+
_winreg.CloseKey(key)
388393
except (WindowsError, IndexError):
389394
continue
390395
cabarc = os.path.join(dir, r"Bin", "cabarc.exe")
391396
if not os.path.exists(cabarc):
392397
continue
393398
break
394399
else:
395-
print("WARNING: cabarc.exe not found in registry")
400+
print "WARNING: cabarc.exe not found in registry"
396401
cabarc = "cabarc.exe"
397402
cmd = r'"%s" -m lzx:21 n %s.cab @%s.txt' % (cabarc, self.name, self.name)
398403
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
@@ -404,7 +409,7 @@ def commit(self, db):
404409
sys.stdout.write(line)
405410
sys.stdout.flush()
406411
if not os.path.exists(self.name+".cab"):
407-
raise IOError("cabarc failed")
412+
raise IOError, "cabarc failed"
408413
add_data(db, "Media",
409414
[(1, self.index, None, "#"+self.name, None, None)])
410415
add_stream(db, self.name, self.name+".cab")
@@ -523,7 +528,7 @@ def add_file(self, file, src=None, version=None, language=None):
523528
file = os.path.basename(file)
524529
absolute = os.path.join(self.absolute, src)
525530
assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names
526-
if file in self.keyfiles:
531+
if self.keyfiles.has_key(file):
527532
logical = self.keyfiles[file]
528533
else:
529534
logical = None
@@ -683,5 +688,5 @@ def set_arch_from_file(path):
683688
Win64 = 1
684689
arch_ext = '.amd64'
685690
else:
686-
raise ValueError("Unsupported architecture")
691+
raise ValueError, "Unsupported architecture"
687692
msi_type += ";1033"

0 commit comments

Comments
 (0)