diff --git a/pym/console/application/cl_client.py b/pym/console/application/cl_client.py index 95c9d3b..1cda035 100644 --- a/pym/console/application/cl_client.py +++ b/pym/console/application/cl_client.py @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from calculate.core.server.local_call import Display, Methods +from calculate.core.server.local_call import Display, Methods, has_force_arg from sudsds import WebFault from sudsds.transport import TransportError @@ -276,17 +276,31 @@ def https_server(client, args, unknown_args, url, clVarsCore, wait_thread): return 1 elif args.method and args.help: - view_params = get_view_params(client, args.method + '_view', - step = None, expert = True, - onlyhelp = True) - view = get_view(client, args.method, client.sid, view_params) - wait_thread.stop() - sys.stdout.write("\b") - sys.stdout.flush() - method_parser = get_method_argparser(view, args) - method_parser.print_help() - client.service.clear_method_cache(client.sid, args.method) - + # вычислить наличие флага --force + try: + dispatch_usenew = has_force_arg(unknown_args) + while True: + view_params = get_view_params(client, args.method + '_view', + step=None, expert=True, + onlyhelp=True, + dispatch_usenew=dispatch_usenew) + view = get_view(client, args.method, client.sid, view_params) + method_parser = get_method_argparser(view, args) + + _unknown_args = method_parser.fixBoolVariables(unknown_args) + + _args, _unknown_args = method_parser.parse_known_args(_unknown_args) + + if dispatch_usenew == _args.no_questions: + method_parser.print_help() + break + else: + client.service.clear_method_cache(client.sid, args.method) + dispatch_usenew = _args.no_questions + finally: + wait_thread.stop() + sys.stdout.write("\b") + sys.stdout.flush() else: method_result = call_method(client, args, unknown_args, wait_thread) mr = get_message_receiver(client) @@ -336,7 +350,6 @@ def main(wait_thread): sym_link = os.path.basename(sys.argv[0]) if sym_link != 'cl-console': import calculate.core.server.loaded_methods as loaded_methods - from calculate.core.datavars import DataVarsCore ob = DataVarsCore() ob.importCore() diff --git a/pym/console/application/function.py b/pym/console/application/function.py index c2c4348..f76af03 100644 --- a/pym/console/application/function.py +++ b/pym/console/application/function.py @@ -13,8 +13,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import argparse import time, os, sys +import re import subprocess from OpenSSL import crypto import shlex @@ -127,12 +129,13 @@ def _create_obj(client, method): return view_params def get_view_params(client, method, step = None, expert = None, brief = None, - onlyhelp = False): + onlyhelp = False, dispatch_usenew = False): view_params = _create_obj(client, method) view_params.step = step view_params.expert = expert view_params.brief = brief view_params.onlyhelp = onlyhelp + view_params.dispatch_usenew = dispatch_usenew return view_params @@ -339,3 +342,4 @@ class MessageDispatcher(object): def ask_password(self, message): answer = self.methods.askPassword(message.message, message.id == 2) self.parent.send_message(answer) + diff --git a/pym/console/application/methods_func.py b/pym/console/application/methods_func.py index e1a613c..7029afe 100644 --- a/pym/console/application/methods_func.py +++ b/pym/console/application/methods_func.py @@ -16,7 +16,7 @@ import argparse, sys from calculate.core.server.api_types import ViewInfoAdapter -from calculate.core.server.local_call import Methods +from calculate.core.server.local_call import Methods, has_force_arg from function import _create_obj, get_view_params, print_brief, _print from calculate.lib.cl_lang import setLocalTranslate @@ -112,11 +112,37 @@ def get_view(client, method, sid, view_params): def call_method(client, args, unknown_args, wait_thread): method = args.method stdin_passwd = args.stdin_passwd - view_params = get_view_params(client, method + '_view', step=None, \ - expert=True) - view = get_view(client, method, client.sid, view_params) - method_parser = get_method_argparser(view, args) + # вычислить наличие флага --force + try: + dispatch_usenew = has_force_arg(unknown_args) + except BaseException: + wait_thread.stop() + sys.stdout.write('\r') + sys.stdout.flush() + raise + + method_parser = None + view = None + + while True: + view_params = get_view_params(client, method + '_view', step=None, + expert=True, + dispatch_usenew=dispatch_usenew) + + view = get_view(client, method, client.sid, view_params) + method_parser = get_method_argparser(view, args) + + _unknown_args = method_parser.fixBoolVariables(unknown_args) + + _args, _drop_args = method_parser.parse_known_args(_unknown_args) + + if dispatch_usenew == _args.no_questions: + break + else: + client.service.clear_method_cache(client.sid, args.method) + dispatch_usenew = _args.no_questions + param_object = _create_obj(client, method) try: unknown_args = method_parser.fixBoolVariables(unknown_args) @@ -133,7 +159,7 @@ def call_method(client, args, unknown_args, wait_thread): sys.stdout.flush() _print (_('Unknown parameter'), i) raise Exception(1) - if not view.groups is None: + if view.groups is not None: param_object, steps = collect_object(client, param_object, view, args, wait_thread,stdin_passwd=stdin_passwd) if steps.label and hasattr (param_object, 'CheckOnly'):