View | Details | Raw Unified | Return to bug 5811
Collapse All | Expand All

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

Return to bug 5811