def write_empty_schema(): with open(file_location, 'w') as file: file.write( json_encode(Connections(servers=[ Server(uri='mongodb://localhost:27017', label='local') ]), unpicklable=False)) file.flush()
def __encode_as_json(cls, neuroml_document): neuroml_document = cls.__sanitize_doc(neuroml_document) from jsonpickle import encode as json_encode try: # Enable encoding of numpy arrays with recent jsonpickle versions import jsonpickle.ext.numpy as jsonpickle_numpy jsonpickle_numpy.register_handlers() except ImportError: pass # older version of jsonpickle encoded = json_encode(neuroml_document) return encoded
def ship(self, computer_obj): try: computer_json = json_encode(computer_obj, unpicklable=True) payload = { 'payload': computer_json } response = http_post(self._server_ship_address, data=payload, timeout=self.timeout) if response.status_code == 200: pass elif response.status_code == 202: logger.warning('The server ignored the shipped measurement') else: logger.warning( 'Server responded with status code %i and message %s' % (response.status_code, response.text)) except Exception as ex: logger.critical("Cannot ship to the server") logger.critical("Exception msg: [%s]" % str(ex))
def __encode_as_json(cls, neuroml_document): neuroml_document = cls.__sanitize_doc(neuroml_document) from jsonpickle import encode as json_encode encoded = json_encode(neuroml_document) return encoded
def __encode_as_json(cls,neuroml_document): neuroml_document = cls.__sanitize_doc(neuroml_document) from jsonpickle import encode as json_encode encoded = json_encode(neuroml_document) return encoded
def __encode_as_json(cls,neuroml_document): neuroml_document = cls.__sanitize_doc(neuroml_document) encoded = json_encode(neuroml_document) return encoded
def __encode_as_json(cls, neuroml_document): neuroml_document = cls.__sanitize_doc(neuroml_document) encoded = json_encode(neuroml_document) return encoded