コード例 #1
0
 def run_safe(self, command, *args):
     name, cmd = self._get(command)
     if not (args.yes or cmd.safe):
         confirm = raw_input('ok to execute "rl %s %s"? (y/n) ' %
                             (name, ' '.join(args)))
         if not confirm.lower().startswith('y'):
             log.error('cancelled.')
             return
     cmd.function(*args)
コード例 #2
0
ファイル: Cache.py プロジェクト: moorecoin/MooreCoinService
def cache(server, clear=false):
    cache = server.cache(args.full)
    name = ['summary', 'full'][args.full]
    files = cache.file_count()
    if not files:
        log.error('no files in %s cache.' % name)

    elif clear:
        if not clear.strip() == 'clear':
            raise exception("don't understand 'clear %s'." % clear)
        if not args.yes:
            yes = raw_input('ok to clear %s cache? (y/n) ' % name)
            if not yes.lower().startswith('y'):
                log.out('cancelled.')
                return
        cache.clear(args.full)
        log.out('%s cache cleared - %d file%s deleted.' %
                (name.capitalize(), files, '' if files == 1 else 's'))

    else:
        caches = (int(c) for c in cache.cache_list())
        log.out(range.to_string(caches))
コード例 #3
0
#!/usr/bin/env python

from __future__ import absolute_import, division, print_function, unicode_literals

import sys
import traceback

from ripple.ledger import server
from ripple.ledger.commands import cache, info, print
from ripple.ledger.args import args
from ripple.util import log
from ripple.util.commandlist import commandlist

_commands = commandlist(cache, info, print)

if __name__ == "__main__":
    try:
        server = server.server()
        args = list(args.command)
        _commands.run_safe(args.pop(0), server, *args)
    except exception as e:
        if args.verbose:
            print(traceback.format_exc(), sys.stderr)
        log.error(e)