def Run(self, args): """Run the capture upload command.""" mgr = capture.CaptureManager() result = mgr.UploadCapture(args.capture_id, args.source_location, args.target_path) output_dir = args.output_directory files.MakeDir(output_dir) output_dir = os.path.realpath(output_dir) extended_contexts = result['source_contexts'] result = dict(result) result['extended_context_file'] = os.path.join(output_dir, 'source-contexts.json') with open(result['extended_context_file'], 'w') as f: json.dump(extended_contexts, f) result['context_file'] = os.path.join(output_dir, 'source-context.json') best_context = context_util.BestSourceContext(extended_contexts) result['best_context'] = context_util.BestSourceContext( extended_contexts) with open(result['context_file'], 'w') as f: json.dump(best_context, f) log.status.write('Wrote {0} file(s), {1} bytes.\n'.format( result['files_written'], result['size_written'])) files_skipped = result['files_skipped'] if files_skipped: log.status.write( 'Skipped {0} file(s) due to size limitations.\n'.format( files_skipped)) return [result]
def Run(self, args): """Run the delete command.""" manager = capture.CaptureManager() deleted_list = [] for name in args.capture_id: d = manager.DeleteCapture(name) log.DeletedResource(d) deleted_list.append(d) return deleted_list
def Run(self, args): """Run the capture upload command.""" mgr = capture.CaptureManager() result = mgr.UploadCapture(args.capture_id, args.source_location, args.target_path) if args.context_file: if os.path.isdir(args.context_file): json_filename = os.path.join(args.context_file, 'source-contexts.json') else: json_filename = args.context_file else: json_filename = 'source-contexts.json' with open(json_filename, 'w') as source_context_file: json.dump(result['source_contexts'], source_context_file) log.Print('Created context file {0}\n'.format(json_filename)) return result
def Run(self, args): """Run the capture upload command.""" mgr = capture.CaptureManager() result = mgr.UploadCapture(args.capture_id, args.source_location, args.target_path) if args.context_file: if os.path.isdir(args.context_file): json_filename = os.path.join(args.context_file, 'source-contexts.json') else: json_filename = args.context_file else: json_filename = 'source-contexts.json' with open(json_filename, 'w') as source_context_file: json.dump(result['source_contexts'], source_context_file) result = dict(result) result['context_file'] = json_filename log.status.write('Created context file {0}.\n'.format(json_filename)) log.status.write('Created source capture {0}.\n'.format( unicode(result['capture']).split('/')[-1])) log.status.write('Wrote {0} files, {1} bytes.\n'.format( result['files_written'], result['size_written'])) return result
def Run(self, args): """Run the capture command.""" mgr = capture.CaptureManager() return mgr.ListCaptures()