import acrort
import acrobind
def main():
specs = acrobind.create_viewspec_storage('stdspecs', acrobind.dir_here())
parser = acrobind.CommandLineParser()
parser.append_processor(acrobind.ConnectionArgumentsProcessor(tenancy_required=True))
parser.append_processor(acrobind.PostOfficeArgumentsProcessor(std_specs=specs.enumerate()))
parser.append_processor(acrobind.OutputArgumentsProcessor())
parser.append_processor(acrobind.DebugTraceArgumentsProcessor())
try:
config = parser.parse_arguments()
except acrort.Exception as exception:
error = exception.to_error()
ret = error.to_exit_code()
if ret == acrort.common.EXCEPTION_AWARE_RETURN_CODE:
error.throw()
return ret
printer = acrobind.Output(config, end='\n\n')
queue = acrort.common.Queue(sigint=True, size_limit=1)
connection, error = acrobind.connect_to_service(config, queue=queue, printer=printer)
if connection is None:
return error.to_exit_code()
post_office = acrobind.PostOffice(connection, queue)
action_id = post_office.execute_request(config)
on_stop = False
while True:
msg = queue.get()
if not on_stop and acrort.common.interrupt_sentinel:
on_stop = True
acrort.common.cancel_action(action_id)
if not on_stop or msg.type_id not in acrort.common.MESSAGE_FAMILY_DML:
printer.write(msg)
if msg.type_id == acrort.common.MESSAGE_TYPE_COMPLETION:
break
if __name__ == '__main__':
exit(acrobind.interruptable_safe_execute(main))
|