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)
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)
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))
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))
#!/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)