1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# Copyright 2008 The Tor Project, Inc. See LICENSE for licensing information.
import subprocess
import logging
import thandy.util
import thandy.packagesys.PackageSystem as ps
import thandy.packagesys.PackageDB as pdb
class ExePackageSystem(pdb.DBBackedPackageSystem):
def __init__(self, repo):
pdb.DBBackedPackageSystem.__init__(self)
self._repo = repo
def getName(self):
return "exe"
def packageHandlesFromJSON(self, pkg):
if pkg['format'] != 'exe':
raise thandy.FormatException()
handles = []
for entry in pkg['files']:
if len(entry) < 3:
continue
rp, h, extra = entry[:3]
version = pkg['version']
handles.append(
ExePackageHandle(self.getDB(),
pkg['name'],
version,
[], # filelist not implemented in this.
rp,
self._repo.getFilename(rp),
arguments=extra.get('exe_args', []),
registry_ent=extra.get('registry_ent')))
return handles
def canBeAutomatic(self):
return True
def canHaveUI(self):
return True
class ExePackageHandle(pdb.DBBackedPackageHandle):
def __init__(self, packageDB, name, version, filelist, relpath, filename,
arguments, registry_ent=None):
pdb.DBBackedPackageHandle.__init__(self, packageDB, name, version, filelist)
self._relPath = relpath
self._filename = filename
self._arguments = arguments
self._registry_ent = registry_ent
def getRelativePath(self):
return self._relPath
def getInstalledVersion(self, transaction=None):
if self._registry_ent != None:
try:
ver = thandy.util.getRegistryValue(self._registry_ent[0])
if ver != None:
return ver
except thandy.util.NoRegistry:
pass
return pdb.DBBackedPackageHandle.getInstalledVersion(self, transaction)
def isInstalled(self, transaction=None):
if self._registry_ent != None:
try:
ver = thandy.util.getRegistryValue(self._registry_ent[0])
return ver == self._registry_ent[1]
except thandy.util.NoRegistry:
pass
return pdb.DBBackedPackageHandle.isInstalled(self, transaction)
def _doInstall(self):
commandline = [ self._filename ] + self._arguments
logging.info("Installing %s. Command line: %s", self._filename,
commandline)
subprocess.call(commandline)
|