Lines 82-87
Link Here
|
82 |
return 0 |
82 |
return 0 |
83 |
|
83 |
|
84 |
|
84 |
|
|
|
85 |
def machine_walk(hive, ih, folderpath): |
86 |
# Handle parameters and values |
87 |
for paramname in ih.get_parameters(folderpath): |
88 |
parampath = folderpath + "/" + paramname |
89 |
value = ih.get_string(parampath) |
90 |
print parampath, "=", |
91 |
if value != "": |
92 |
print value |
93 |
else: |
94 |
print |
95 |
#hive.set_string(parampath, value) |
96 |
|
97 |
for subname in ih.get_folders(folderpath): |
98 |
if subname == "/": |
99 |
continue |
100 |
if folderpath != "/": |
101 |
subname = "/" + subname |
102 |
subfolder = folderpath + subname |
103 |
machine_walk(hive, ih, subfolder) |
104 |
|
105 |
|
85 |
def imp_walk(hive, ih, folderpath): |
106 |
def imp_walk(hive, ih, folderpath): |
86 |
# Handle parameters and values |
107 |
# Handle parameters and values |
87 |
for paramname in ih.get_parameters(folderpath): |
108 |
for paramname in ih.get_parameters(folderpath): |
Lines 125-130
Link Here
|
125 |
hivetool [options] [type:]parameter[=value] ... |
146 |
hivetool [options] [type:]parameter[=value] ... |
126 |
|
147 |
|
127 |
-a,--all-entries Print all parameters and values in a folder |
148 |
-a,--all-entries Print all parameters and values in a folder |
|
|
149 |
-A Like -a, but with machine parseable output |
128 |
-i,--import <file> Import all parameters in specified file |
150 |
-i,--import <file> Import all parameters in specified file |
129 |
-p,--purge <file> Remove parameters in specified file which exists elsewhere |
151 |
-p,--purge <file> Remove parameters in specified file which exists elsewhere |
130 |
-R,--recursive When using -a, ascend folders recursively |
152 |
-R,--recursive When using -a, ascend folders recursively |
Lines 152-158
Link Here
|
152 |
|
174 |
|
153 |
def main(): |
175 |
def main(): |
154 |
try: |
176 |
try: |
155 |
opts, args = getopt.getopt(sys.argv[1:], "a:i:p:Rr:ve:E:x?", |
177 |
opts, args = getopt.getopt(sys.argv[1:], "a:A:i:p:Rr:ve:E:x?", |
156 |
["all-entries=", "import=", "purge=", "recursive", "root=", "version", "help", |
178 |
["all-entries=", "import=", "purge=", "recursive", "root=", "version", "help", |
157 |
"eval=", "export"]) |
179 |
"eval=", "export"]) |
158 |
except getopt.GetoptError: |
180 |
except getopt.GetoptError: |
Lines 161-166
Link Here
|
161 |
|
183 |
|
162 |
roothive = DEFAULT_ROOT_HIVE |
184 |
roothive = DEFAULT_ROOT_HIVE |
163 |
walk_folders = [] |
185 |
walk_folders = [] |
|
|
186 |
machine_folders = [] |
164 |
imp_files = [] |
187 |
imp_files = [] |
165 |
purge_files = [] |
188 |
purge_files = [] |
166 |
recursive = 0 |
189 |
recursive = 0 |
Lines 170-175
Link Here
|
170 |
for o, a in opts: |
193 |
for o, a in opts: |
171 |
if o in ("-a", "--all-entries"): |
194 |
if o in ("-a", "--all-entries"): |
172 |
walk_folders.append(a) |
195 |
walk_folders.append(a) |
|
|
196 |
if o in ("-A",): |
197 |
machine_folders.append(a) |
173 |
if o in ("-i", "--import"): |
198 |
if o in ("-i", "--import"): |
174 |
imp_files.append(a) |
199 |
imp_files.append(a) |
175 |
if o in ("-p", "--purge"): |
200 |
if o in ("-p", "--purge"): |
Lines 235-241
Link Here
|
235 |
errors += handle_param(hive, param) |
260 |
errors += handle_param(hive, param) |
236 |
|
261 |
|
237 |
# Walk |
262 |
# Walk |
238 |
for foldername in walk_folders: |
263 |
for foldername in walk_folders + machine_folders: |
239 |
folder = hive.lookup(foldername) |
264 |
folder = hive.lookup(foldername) |
240 |
if not folder: |
265 |
if not folder: |
241 |
print >>sys.stderr, "%s: Folder not found" % foldername |
266 |
print >>sys.stderr, "%s: Folder not found" % foldername |
Lines 244-252
Link Here
|
244 |
if not isinstance(folder, hiveconf.Folder): |
269 |
if not isinstance(folder, hiveconf.Folder): |
245 |
print >>sys.stderr, "%s: not a folder" % foldername |
270 |
print >>sys.stderr, "%s: not a folder" % foldername |
246 |
continue |
271 |
continue |
247 |
|
|
|
248 |
folder.walk(recursive) |
249 |
|
272 |
|
|
|
273 |
if foldername in walk_folders: |
274 |
folder.walk(recursive) |
275 |
else: |
276 |
machine_walk(hive, folder, "/") |
277 |
|
250 |
sys.exit(errors) |
278 |
sys.exit(errors) |
251 |
|
279 |
|
252 |
if __name__ == "__main__": |
280 |
if __name__ == "__main__": |