~therve/landscape-client/285086-customgraph-acceptedtype

« back to all changes in this revision

Viewing changes to landscape/broker/configuration.py

  • Committer: Jamu Kakar
  • Date: 2008-08-02 02:02:48 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: jkakar@kakar.ca-20080802020248-hagy23ddhpa4a979
- Replaced check_config decorator with simpler inline code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    stream.flush()
31
31
 
32
32
 
33
 
def check_config(*args):
34
 
    names = args
35
 
    def decorator(function):
36
 
        def decorated(*args, **kwargs):
37
 
            self = args[0]
38
 
            for name in names:
39
 
                if name in self.config.get_command_line_options():
40
 
                    break
41
 
            else:
42
 
                function(*args, **kwargs)
43
 
        return decorated
44
 
    return decorator
45
 
 
46
 
 
47
33
class BrokerConfigurationScript(object):
48
34
    """
49
35
    An interactive procedure which manages the prompting and temporary storage
131
117
            else:
132
118
                return default
133
119
 
134
 
    @check_config("computer_title")
135
120
    def query_computer_title(self):
 
121
        if "computer_title" in self.config.get_command_line_options():
 
122
            return
 
123
 
136
124
        self.show_help(
137
125
            """
138
126
            The computer title you provide will be used to represent this
143
131
 
144
132
        self.prompt("computer_title", "This computer's title", True)
145
133
 
146
 
    @check_config("account_name")
147
134
    def query_account_name(self):
 
135
        if "account_name" in self.config.get_command_line_options():
 
136
            return
 
137
 
148
138
        self.show_help(
149
139
            """
150
140
            You must now specify the name of the Landscape account you
155
145
 
156
146
        self.prompt("account_name", "Account name", True)
157
147
 
158
 
    @check_config("registration_password")
159
148
    def query_registration_password(self):
 
149
        if "registration_password" in self.config.get_command_line_options():
 
150
            return
 
151
 
160
152
        self.show_help(
161
153
            """
162
154
            A registration password may be associated with your Landscape
171
163
        self.password_prompt("registration_password",
172
164
                             "Account registration password")
173
165
 
174
 
    @check_config("http_proxy", "https_proxy")
175
166
    def query_proxies(self):
 
167
        options = self.config.get_command_line_options()
 
168
        if "http_proxy" in options and "https_proxy" in options:
 
169
            return
 
170
 
176
171
        self.show_help(
177
172
            """
178
173
            The Landscape client communicates with the server over HTTP and
181
176
            proxies now.  If you don't use a proxy, leave these fields empty.
182
177
            """)
183
178
 
184
 
        self.prompt("http_proxy", "HTTP proxy URL")
185
 
        self.prompt("https_proxy", "HTTPS proxy URL")
 
179
        if not "http_proxy" in options:
 
180
            self.prompt("http_proxy", "HTTP proxy URL")
 
181
        if not "https_proxy" in options:
 
182
            self.prompt("https_proxy", "HTTPS proxy URL")
186
183
 
187
 
    @check_config("include_manager_plugins", "script_users")
188
184
    def query_script_plugin(self):
 
185
        options = self.config.get_command_line_options()
 
186
        if "include_manager_plugins" in options and "script_users" in options:
 
187
            return
 
188
 
189
189
        self.show_help(
190
190
            """
191
191
            Landscape has a feature which enables administrators to run