当前位置: 首页>>代码示例>>Python>>正文


Python jsonpickle.dumps方法代码示例

本文整理汇总了Python中jsonpickle.dumps方法的典型用法代码示例。如果您正苦于以下问题:Python jsonpickle.dumps方法的具体用法?Python jsonpickle.dumps怎么用?Python jsonpickle.dumps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jsonpickle的用法示例。


在下文中一共展示了jsonpickle.dumps方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _execute

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def _execute(self, ctx):
        self._check_closed()

        # Temporary file used to pass arguments to the started subprocess
        file_descriptor, arguments_json_path = tempfile.mkstemp(prefix='executor-', suffix='.json')
        os.close(file_descriptor)
        with open(arguments_json_path, 'wb') as f:
            f.write(pickle.dumps(self._create_arguments_dict(ctx)))

        env = self._construct_subprocess_env(task=ctx.task)
        # Asynchronously start the operation in a subprocess
        proc = subprocess.Popen(
            [
                sys.executable,
                os.path.expanduser(os.path.expandvars(__file__)),
                os.path.expanduser(os.path.expandvars(arguments_json_path))
            ],
            env=env)

        self._tasks[ctx.task.id] = _Task(ctx=ctx, proc=proc) 
开发者ID:apache,项目名称:incubator-ariatosca,代码行数:22,代码来源:process.py

示例2: site_map

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def site_map():
    output = []
    for rule in app.url_map.iter_rules():
        options = {}
    for arg in rule.arguments:
        options[arg] = "[{0}]".format(arg)

    methods = ','.join(rule.methods)
    url = str(rule)
    import urllib.request

    line = urllib.request.unquote("{:50s} {:20s} {}".format(rule.endpoint, methods, url))
    output.append(line)

    logging.info(str(output))
    response = app.response_class(
      response=jsonpickle.dumps(output),
      status=200,
      mimetype='application/json'
    )
    return response 
开发者ID:kmadathil,项目名称:sanskrit_parser,代码行数:23,代码来源:flask_helper.py

示例3: export

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def export(self, event):
        """ Export the current model to stl """
        from twisted.internet import reactor
        options = event.parameters.get('options')
        if not options:
            raise ValueError("An export `options` parameter is required")

        # Pickle the configured exporter and send it over
        cmd = [sys.executable]
        if not sys.executable.endswith('declaracad'):
            cmd.extend(['-m', 'declaracad'])

        data = jsonpickle.dumps(options)
        assert data != 'null', f"Exporter failed to serialize: {options}"
        cmd.extend(['export', data])

        log.debug(" ".join(cmd))
        protocol = ProcessLineReceiver()
        reactor.spawnProcess(
            protocol, sys.executable, args=cmd, env=os.environ)
        return protocol 
开发者ID:codelv,项目名称:declaracad,代码行数:23,代码来源:plugin.py

示例4: send

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def send(self, raise_exception=False, user=None):
        """
        Handles the preparing the notification for sending. Called to trigger the send from code.
        If raise_exception is True, it will raise any exceptions rather than simply logging them.
        returns boolean whether or not the notification was sent successfully
        """
        context = self.get_context_data()

        recipients = self.get_recipients()

        if 'text' in self.render_types:
            text_content = self.render('text', context)
        else:
            text_content = None

        if 'html' in self.render_types:
            html_content = self.render('html', context)
        else:
            html_content = None

        sent_from = self.get_sent_from()
        subject = self.get_subject()
        extra_data = self.get_extra_data()

        sent_notification = SentNotification(
            recipients=','.join(recipients),
            text_content=text_content,
            html_content=html_content,
            sent_from=sent_from,
            subject=subject,
            extra_data=json.dumps(extra_data) if extra_data else None,
            notification_class=self.get_class_path(),
            attachments=self._get_encoded_attachments(),
            user=user,
        )

        return self.resend(sent_notification, raise_exception=raise_exception) 
开发者ID:worthwhile,项目名称:django-herald,代码行数:39,代码来源:base.py

示例5: _get_encoded_attachments

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def _get_encoded_attachments(self):
        attachments = self.get_attachments()

        new_attachments = []

        for attachment in attachments or []:
            if isinstance(attachment, File):
                # cannot do with attachment.open() since django 1.11 doesn't support that
                attachment.open()
                new_attachments.append((attachment.name, attachment.read(), guess_type(attachment.name)[0]))
                attachment.close()
            else:
                new_attachments.append(attachment)

        return jsonpickle.dumps(new_attachments) 
开发者ID:worthwhile,项目名称:django-herald,代码行数:17,代码来源:base.py

示例6: _send

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def _send(self, data: Dict[str, object]):
        self.statsPublisher.send(jsonpickle.dumps(data)) 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:4,代码来源:plugin_firebase_stats_consumer.py

示例7: serialize_instance

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def serialize_instance(self, instance: Instance) -> str:
        """
        Serializes an `Instance` to a string.  We use this for caching the processed data.

        The default implementation is to use `jsonpickle`.  If you would like some other format
        for your pre-processed data, override this method.
        """
        return jsonpickle.dumps(instance) 
开发者ID:allenai,项目名称:allennlp,代码行数:10,代码来源:dataset_reader.py

示例8: get_state

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def get_state(self):
        return jsonpickle.dumps([o.order_id for _, o in self._delayed_orders]).encode('utf-8') 
开发者ID:Raytone-D,项目名称:puppet,代码行数:4,代码来源:broker.py

示例9: get_state

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def get_state(self):
        result = {}
        for key, obj in six.iteritems(self._objects):
            state = obj.get_state()
            if state is not None:
                result[key] = state

        return jsonpickle.dumps(result).encode('utf-8') 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:10,代码来源:persisit_helper.py

示例10: get_state

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def get_state(self):
        return jsonpickle.dumps({
            'open_orders': [o.get_state() for account, o in self._open_orders],
            'delayed_orders': [o.get_state() for account, o in self._delayed_orders]
        }).encode('utf-8') 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:7,代码来源:simulation_broker.py

示例11: _send_message

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def _send_message(connection, message):

    # Packing the length of the entire msg using struct.pack.
    # This enables later reading of the content.
    def _pack(data):
        return struct.pack(_INT_FMT, len(data))

    data = jsonpickle.dumps(message)
    msg_metadata = _pack(data)
    connection.send(msg_metadata)
    connection.sendall(data) 
开发者ID:apache,项目名称:incubator-ariatosca,代码行数:13,代码来源:process.py

示例12: format

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def format(self):
        """ Return formatted option values for the exporter app to parse """
        return json.dumps(self.__getstate__()) 
开发者ID:codelv,项目名称:declaracad,代码行数:5,代码来源:plugin.py

示例13: send_message

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def send_message(self, method, *args, **kwargs):
        # Defer until it's ready
        if not self.transport or not self.window_id:
            #log.debug('renderer | message not ready deferring')
            timed_call(1000, self.send_message, method, *args, **kwargs)
            return
        _id = kwargs.pop('_id')
        _silent = kwargs.pop('_silent', False)

        request = {'jsonrpc': '2.0', 'method': method, 'params': args or kwargs}
        if _id is not None:
            request['id'] = _id
        if not _silent:
            log.debug(f'renderer | sent | {request}')
        self.transport.write(jsonpickle.dumps(request).encode()+b'\r\n') 
开发者ID:codelv,项目名称:declaracad,代码行数:17,代码来源:plugin.py

示例14: save_area

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def save_area(self):
        """ Save the dock area for the workspace.

        """
        area = self.content.find('dock_area')
        try:
            with open('declaracad.workspace.db', 'w') as f:
                f.write(pickle.dumps(area))
        except Exception as e:
            print("Error saving dock area: {}".format(e))
            return e 
开发者ID:codelv,项目名称:declaracad,代码行数:13,代码来源:workspace.py

示例15: send_message

# 需要导入模块: import jsonpickle [as 别名]
# 或者: from jsonpickle import dumps [as 别名]
def send_message(self, message):
        response = {'jsonrpc': '2.0'}
        response.update(message)
        self.transport.write(jsonpickle.dumps(response).encode()+b'\r\n') 
开发者ID:codelv,项目名称:declaracad,代码行数:6,代码来源:utils.py


注:本文中的jsonpickle.dumps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。