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

(-)a/tlmisc/hiveconf/hivetool (-7 / +15 lines)
Lines 35-45 def get_value(s): Link Here
35
        return tuple(words)
35
        return tuple(words)
36
36
37
37
38
def handle_param(hive, param):
38
def handle_param(hive, param, delete=False):
39
    """Print parameter. Returns zero on success"""
39
    """ Get / Set or Delete parameter. Returns zero on success"""
40
    (paramtype, param) = get_type(param)
40
    (paramtype, param) = get_type(param)
41
    (parampath, value) = get_value(param)
41
    (parampath, value) = get_value(param)
42
42
43
    if delete:
44
        # Delete parameter
45
        hive.delete(parampath)
46
        return 0
47
43
    if not value:
48
    if not value:
44
        # Display value
49
        # Display value
45
        method = getattr(hive, "get_%s" % paramtype)
50
        method = getattr(hive, "get_%s" % paramtype)
Lines 48-54 def handle_param(hive, param): Link Here
48
        except hiveconf.NotAParameterError:
53
        except hiveconf.NotAParameterError:
49
            print >>sys.stderr, "%s: Not a parameter" % parampath
54
            print >>sys.stderr, "%s: Not a parameter" % parampath
50
            return 1
55
            return 1
51
            
56
52
        if value == None:
57
        if value == None:
53
            print >>sys.stderr, "%s: No such parameter" % parampath
58
            print >>sys.stderr, "%s: No such parameter" % parampath
54
            return 1
59
            return 1
Lines 81-87 def eval_print(hive, varname, param, export): Link Here
81
    else:
86
    else:
82
        return 0
87
        return 0
83
88
84
85
def imp_walk(hive, ih, folderpath):
89
def imp_walk(hive, ih, folderpath):
86
    # Handle parameters and values
90
    # Handle parameters and values
87
    for paramname in ih.get_parameters(folderpath):
91
    for paramname in ih.get_parameters(folderpath):
Lines 126-131 hivetool [options] [type:]parameter[=value] ... Link Here
126
130
127
  -a,--all-entries        Print all parameters and values in a folder
131
  -a,--all-entries        Print all parameters and values in a folder
128
  -i,--import <file>      Import all parameters in specified file
132
  -i,--import <file>      Import all parameters in specified file
133
  -d,--delete             Delete all specified parameters
129
  -p,--purge <file>       Remove parameters in specified file which exists elsewhere
134
  -p,--purge <file>       Remove parameters in specified file which exists elsewhere
130
  -R,--recursive	  When using -a, ascend folders recursively
135
  -R,--recursive	  When using -a, ascend folders recursively
131
  -r,--root <file>	  Specify root hive file. Default is /etc/root.hconf
136
  -r,--root <file>	  Specify root hive file. Default is /etc/root.hconf
Lines 152-158 hivetool [options] [type:]parameter[=value] ... Link Here
152
157
153
def main():
158
def main():
154
    try:
159
    try:
155
        opts, args = getopt.getopt(sys.argv[1:], "a:i:p:Rr:ve:E:x?",
160
        opts, args = getopt.getopt(sys.argv[1:], "a:i:dp:Rr:ve:E:x?",
156
                                   ["all-entries=", "import=", "purge=", "recursive", "root=", "version", "help",
161
                                   ["all-entries=", "import=", "purge=", "recursive", "root=", "version", "help",
157
                                    "eval=", "export"])
162
                                    "eval=", "export"])
158
    except getopt.GetoptError:
163
    except getopt.GetoptError:
Lines 164-169 def main(): Link Here
164
    imp_files = []
169
    imp_files = []
165
    purge_files = []
170
    purge_files = []
166
    recursive = 0
171
    recursive = 0
172
    delete_params = False
167
    e_params =[]
173
    e_params =[]
168
    E_params = []
174
    E_params = []
169
    eval_export = 0 
175
    eval_export = 0 
Lines 172-177 def main(): Link Here
172
            walk_folders.append(a)
178
            walk_folders.append(a)
173
        if o in ("-i", "--import"):
179
        if o in ("-i", "--import"):
174
            imp_files.append(a)
180
            imp_files.append(a)
181
        if o in ("-d", "--delete"):
182
            delete_params = True
175
        if o in ("-p", "--purge"):
183
        if o in ("-p", "--purge"):
176
            purge_files.append(a)
184
            purge_files.append(a)
177
        if o in ("-R", "--recursive"):
185
        if o in ("-R", "--recursive"):
Lines 230-238 def main(): Link Here
230
        for param in params:
238
        for param in params:
231
            errors += eval_print(folder, param, param, eval_export)
239
            errors += eval_print(folder, param, param, eval_export)
232
240
233
    # Get/set listed parameters
241
    # Get/set/delete listed parameters
234
    for param in args:
242
    for param in args:
235
        errors += handle_param(hive, param)
243
        errors += handle_param(hive, param, delete_params)
236
244
237
    # Walk
245
    # Walk
238
    for foldername in walk_folders:
246
    for foldername in walk_folders:

Return to bug 6122