def print_result(self, result): """Pretty-print the result of the command. The default behavior is to dump a formatted JSON encoding of the result. Args: result: The JSON-serializable result to print. """ # We could have used the pprint module, but it produces # noisy output due to all of our keys and values being # unicode strings rather than simply ascii. print json.dumps(result, sort_keys=True, indent=2)
def WriteState(self): state = {'status': 'WAITING', 'update_time': time.time()} conn = boto.connect_gs(config.gs_access_key, config.gs_secret_key) bucket = conn.get_bucket(self._bucket) k = Key(bucket, '%s/%s/output/stitch.state' % (self._user, self._batch)) k.set_contents_from_string(simplejson.dumps(state, indent=2), policy='public-read', headers={'Content-Type': 'text/plain'})
def WriteState(self): state = { 'status': 'WAITING', 'update_time': time.time() } conn = boto.connect_gs(config.gs_access_key,config.gs_secret_key) bucket = conn.get_bucket(self._bucket) k = Key(bucket, '%s/%s/output/stitch.state' % (self._user, self._batch)) k.set_contents_from_string( simplejson.dumps(state, indent=2), policy='public-read',headers={'Content-Type': 'text/plain'})
def request(self, token_uri, method, body, headers, *args, **kwargs): self.body = body self.headers = headers return (self, simplejson.dumps(self.content))
def toJson(self): base = '%s/%s/%s' % (self._bucket, self._user, self._batch) return simplejson.dumps({ 'base': base, 'input_files': self._files })
s.netloc, s.path, s.params, query, s.fragment) uri = urlparse.urlunparse(d) if FLAGS.dump_request: print '--request-start--' print '%s %s' % (method, uri) if headers: for (h, v) in headers.iteritems(): print '%s: %s' % (h, v) print '' if body: print json.dumps(json.loads(body), sort_keys=True, indent=2) print '--request-end--' return request_orig(uri, method, body, headers, redirections, connection_type) http.request = new_request return http def print_result(self, result): """Pretty-print the result of the command. The default behavior is to dump a formatted JSON encoding
def to_json(self): """Returns a json representation.""" return simplejson.dumps(self.__dict__)
def toJson(self): base = '%s/%s/%s' % (self._bucket, self._user, self._batch) return simplejson.dumps({'base': base, 'input_files': self._files})