@add_argument('<STR_LIT>',<EOL>metavar='<STR_LIT>',<EOL>help="<STR_LIT>")<EOL>@add_argument('<STR_LIT>',<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>")<EOL>@add_argument('<STR_LIT>',<EOL>nargs='<STR_LIT:*>',<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>")<EOL>@add_argument('<STR_LIT>', '<STR_LIT>',<EOL>dest='<STR_LIT>',<EOL>action='<STR_LIT:store>',<EOL>default=None,<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>@add_argument('<STR_LIT>', '<STR_LIT>',<EOL>dest='<STR_LIT>',<EOL>action='<STR_LIT:store_true>',<EOL>default=False,<EOL>help="<STR_LIT>")<EOL>def turnstile_command(conf_file, command, arguments=[], channel=None,<EOL>debug=False):
<EOL>conf = config.Config(conf_file=conf_file)<EOL>db = conf.get_database()<EOL>control_channel = conf['<STR_LIT>'].get('<STR_LIT>', '<STR_LIT>')<EOL>command = command.lower()<EOL>ts_conv = False<EOL>if command == '<STR_LIT>':<EOL><INDENT>if arguments:<EOL><INDENT>channel = arguments[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>channel = str(uuid.uuid4())<EOL>arguments = [channel]<EOL><DEDENT>if len(arguments) < <NUM_LIT:2>:<EOL><INDENT>arguments.append(time.time())<EOL>ts_conv = True<EOL><DEDENT>arguments = arguments[:<NUM_LIT:2>]<EOL><DEDENT>if debug:<EOL><INDENT>cmd = [command] + arguments<EOL>print(("<STR_LIT>" %<EOL>'<STR_LIT:U+0020>'.join(cmd)), file=sys.stderr)<EOL><DEDENT>database.command(db, control_channel, command, *arguments)<EOL>if not channel:<EOL><INDENT>return<EOL><DEDENT>pubsub = db.pubsub()<EOL>pubsub.subscribe(channel)<EOL>try:<EOL><INDENT>count = <NUM_LIT:0><EOL>for msg in pubsub.listen():<EOL><INDENT>if debug:<EOL><INDENT>formatted = pprint.pformat(msg)<EOL>print("<STR_LIT>" % formatted, file=sys.stderr)<EOL><DEDENT>if (msg['<STR_LIT:type>'] not in ('<STR_LIT>', '<STR_LIT:message>') or<EOL>msg['<STR_LIT>'] != channel):<EOL><INDENT>continue<EOL><DEDENT>count += <NUM_LIT:1><EOL>response = msg['<STR_LIT:data>'].split('<STR_LIT::>')<EOL>if ts_conv and response[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>rtt = (time.time() - float(response[<NUM_LIT:2>])) * <NUM_LIT:100><EOL>response.append('<STR_LIT>' % rtt)<EOL><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>print("<STR_LIT>" % (count, '<STR_LIT:U+0020>'.join(response)))<EOL><DEDENT><DEDENT>except KeyboardInterrupt:<EOL><INDENT>pass<EOL><DEDENT>
Issue a command to all running control daemons.

:param conf_file: Name of the configuration file.
:param command: The command to execute.  Note that 'ping' is
                handled specially; in particular, the "channel"
                parameter is implied.  (A random value will be
                used for the channel to listen on.)
:param arguments: A list of arguments for the command.  Note that
                  the colon character (':') cannot be used.
:param channel: If not None, specifies the name of a message
                channel to listen for responses on.  Will wait
                indefinitely; to terminate the listening loop, use
                the keyboard interrupt sequence.
:param debug: If True, debugging messages are emitted while
              sending the command.