• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.json_to_datetime函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypuppetdb.utils.json_to_datetime函数的典型用法代码示例。如果您正苦于以下问题:Python json_to_datetime函数的具体用法?Python json_to_datetime怎么用?Python json_to_datetime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_apiv4_with_failed_noop_status

    def test_apiv4_with_failed_noop_status(self):
        node = Node('_', 'node',
                    status_report='failed',
                    noop=True,
                    noop_pending=False,
                    report_environment='development',
                    catalog_environment='development',
                    facts_environment='development',
                    report_timestamp='2013-08-01T09:57:00.000Z',
                    catalog_timestamp='2013-08-01T09:57:00.000Z',
                    facts_timestamp='2013-08-01T09:57:00.000Z',
                    )

        assert node.name == 'node'
        assert node.deactivated is False
        assert node.expired is False
        assert node.report_environment == 'development'
        assert node.catalog_environment == 'development'
        assert node.facts_environment == 'development'
        assert node.report_timestamp == \
            json_to_datetime('2013-08-01T09:57:00.000Z')
        assert node.facts_timestamp == \
            json_to_datetime('2013-08-01T09:57:00.000Z')
        assert node.catalog_timestamp == \
            json_to_datetime('2013-08-01T09:57:00.000Z')
        assert node.status == 'failed'
        assert str(node) == str('node')
        assert unicode(node) == unicode('node')
        assert repr(node) == str('<Node: node>')
开发者ID:redref,项目名称:pypuppetdb,代码行数:29,代码来源:test_types.py


示例2: __init__

    def __init__(self, api, name, deactivated=None, report_timestamp=None,
                 catalog_timestamp=None, facts_timestamp=None,
                 status=None, events=None, unreported_time=None):
        self.name = name
        self.status = status
        self.events = events
        self.unreported_time = unreported_time

        if deactivated is not None:
            self.deactivated = json_to_datetime(deactivated)
        else:
            self.deactivated = False
        if report_timestamp is not None:
            self.report_timestamp = json_to_datetime(report_timestamp)
        else:
            self.report_timestamp = report_timestamp
        if facts_timestamp is not None:
            self.facts_timestamp = json_to_datetime(facts_timestamp)
        else:
            self.facts_timestamp = facts_timestamp
        if catalog_timestamp is not None:
            self.catalog_timestamp = json_to_datetime(catalog_timestamp)
        else:
            self.catalog_timestamp = catalog_timestamp

        self.__api = api
        self.__query_scope = '["=", "certname", "{0}"]'.format(self.name)
        self.__string = self.name
开发者ID:denmat,项目名称:pypuppetdb,代码行数:28,代码来源:types.py


示例3: test_report_with_none_noop_pending_status_unchanged

    def test_report_with_none_noop_pending_status_unchanged(self):
        report = Report(
            '_', 'node2.puppet.board', 'hash#',
            '2015-08-31T21:07:00.000Z',
            '2015-08-31T21:09:00.000Z',
            '2015-08-31T21:10:00.000Z',
            '1482347613', 4, '3.8.1',
            'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
            status='unchanged',
            noop=False,
            metrics=[
                {"name": "failure", "value": 1, "category": "events"},
                {"name": "noop", "value": 1, "category": "events"},
                {"name": "success", "value": 0, "category": "events"}])

        assert report.node == 'node2.puppet.board'
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
        assert report.agent_version == '3.8.1'
        assert report.run_time == report.end - report.start
        assert report.transaction == 'af9f16e3-75f6-4f90-acc6-f83d6524a6f3'
        assert report.status == 'unchanged'
        assert str(report) == str('hash#')
        assert unicode(report) == unicode('hash#')
        assert repr(report) == str('Report: hash#')
开发者ID:redref,项目名称:pypuppetdb,代码行数:29,代码来源:test_types.py


示例4: test_report_with_pending_noop

    def test_report_with_pending_noop(self):
        report = Report('_', 'node2.puppet.board', 'hash#',
                        '2015-08-31T21:07:00.000Z',
                        '2015-08-31T21:09:00.000Z',
                        '2015-08-31T21:10:00.000Z',
                        '1482347613', 4, '4.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        status='unchanged',
                        noop=True,
                        noop_pending=True)

        assert report.node == 'node2.puppet.board'
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
        assert report.agent_version == '4.2.1'
        assert report.run_time == report.end - report.start
        assert report.transaction == 'af9f16e3-75f6-4f90-acc6-f83d6524a6f3'
        assert report.status == 'noop'
        assert str(report) == str('hash#')
        assert unicode(report) == unicode('hash#')
        assert repr(report) == str('Report: hash#')
开发者ID:redref,项目名称:pypuppetdb,代码行数:25,代码来源:test_types.py


示例5: test_report_with_cataloguuid_codeid

    def test_report_with_cataloguuid_codeid(self):
        report = Report('_', 'node2.puppet.board', 'hash#',
                        '2015-08-31T21:07:00.000Z',
                        '2015-08-31T21:09:00.000Z',
                        '2015-08-31T21:10:00.000Z',
                        '1482347613', 4, '4.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        code_id=None,
                        catalog_uuid="0b3a4943-a164-4cea-bbf0-91d0ee931326",
                        cached_catalog_status="not_used")

        assert report.node == 'node2.puppet.board'
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
        assert report.agent_version == '4.2.1'
        assert report.run_time == report.end - report.start
        assert report.transaction == 'af9f16e3-75f6-4f90-acc6-f83d6524a6f3'
        assert report.catalog_uuid == "0b3a4943-a164-4cea-bbf0-91d0ee931326"
        assert report.cached_catalog_status == "not_used"
        assert str(report) == str('hash#')
        assert unicode(report) == unicode('hash#')
        assert repr(report) == str('Report: hash#')
开发者ID:redref,项目名称:pypuppetdb,代码行数:26,代码来源:test_types.py


示例6: test_report_with_noop

    def test_report_with_noop(self):
        report = Report(
            "_",
            "node2.puppet.board",
            "hash#",
            "2015-08-31T21:07:00.000Z",
            "2015-08-31T21:09:00.000Z",
            "2015-08-31T21:10:00.000Z",
            "1482347613",
            4,
            "4.2.1",
            "af9f16e3-75f6-4f90-acc6-f83d6524a6f3",
            status="success",
            noop=True,
        )

        assert report.node == "node2.puppet.board"
        assert report.hash_ == "hash#"
        assert report.start == json_to_datetime("2015-08-31T21:07:00.000Z")
        assert report.end == json_to_datetime("2015-08-31T21:09:00.000Z")
        assert report.received == json_to_datetime("2015-08-31T21:10:00.000Z")
        assert report.version == "1482347613"
        assert report.format_ == 4
        assert report.agent_version == "4.2.1"
        assert report.run_time == report.end - report.start
        assert report.transaction == "af9f16e3-75f6-4f90-acc6-f83d6524a6f3"
        assert report.status == "noop"
        assert str(report) == str("hash#")
        assert unicode(report) == unicode("hash#")
        assert repr(report) == str("Report: hash#")
开发者ID:octomike,项目名称:pypuppetdb,代码行数:30,代码来源:test_types.py


示例7: test_report

    def test_report(self):
        report = Report(
            "_",
            "node1.puppet.board",
            "hash#",
            "2013-08-01T09:57:00.000Z",
            "2013-08-01T10:57:00.000Z",
            "2013-08-01T10:58:00.000Z",
            "1351535883",
            3,
            "3.2.1",
            "af9f16e3-75f6-4f90-acc6-f83d6524a6f3",
            status="success",
        )

        assert report.node == "node1.puppet.board"
        assert report.hash_ == "hash#"
        assert report.start == json_to_datetime("2013-08-01T09:57:00.000Z")
        assert report.end == json_to_datetime("2013-08-01T10:57:00.000Z")
        assert report.received == json_to_datetime("2013-08-01T10:58:00.000Z")
        assert report.version == "1351535883"
        assert report.format_ == 3
        assert report.agent_version == "3.2.1"
        assert report.run_time == report.end - report.start
        assert report.transaction == "af9f16e3-75f6-4f90-acc6-f83d6524a6f3"
        assert report.status == "success"
        assert str(report) == str("hash#")
        assert unicode(report) == unicode("hash#")
        assert repr(report) == str("Report: hash#")
开发者ID:octomike,项目名称:pypuppetdb,代码行数:29,代码来源:test_types.py


示例8: __init__

    def __init__(self, api, node, hash_, start, end, received, version,
                 format_, agent_version, transaction, status=None,
                 metrics={}, logs={}, environment=None,
                 noop=False, code_id=None, catalog_uuid=None,
                 cached_catalog_status=None):

        self.node = node
        self.hash_ = hash_
        self.start = json_to_datetime(start)
        self.end = json_to_datetime(end)
        self.received = json_to_datetime(received)
        self.version = version
        self.format_ = format_
        self.agent_version = agent_version
        self.run_time = self.end - self.start
        self.transaction = transaction
        self.environment = environment
        self.status = 'noop' if noop else status
        self.metrics = metrics
        self.logs = logs
        self.code_id = code_id
        self.catalog_uuid = catalog_uuid
        self.cached_catalog_status = cached_catalog_status
        self.__string = '{0}'.format(self.hash_)

        self.__api = api
        self.__query_scope = '["=", "report", "{0}"]'.format(self.hash_)
开发者ID:corey-hammerton,项目名称:pypuppetdb,代码行数:27,代码来源:types.py


示例9: test_report_with_event

 def test_report_with_event(self):
     report = Report('_', 'node2.puppet.board', 'hash#',
                     '2015-08-31T21:07:00.000Z',
                     '2015-08-31T21:09:00.000Z',
                     '2015-08-31T21:10:00.000Z',
                     '1482347613', 4, '4.2.1',
                     'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                     events=[{
                         "status": "success",
                         "timestamp": '2015-08-31T21:09:00.000Z',
                         "old_value": "file",
                         "resource_title": "/etc/httpd/conf.d/README",
                         "containment_path": [
                             "Stage['main']",
                             "Apache",
                             "File[/etc/httpd/conf.d/README]"
                         ],
                         "file": None,
                         "new_value": "absent",
                         "message": "removed",
                         "property": "ensure",
                         "line": None,
                         "resource_type": "File",
                         "containing_class": "Apache"}])
     assert report.node == 'node2.puppet.board'
     assert report.hash_ == 'hash#'
     assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
     assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
     assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
     assert report.version == '1482347613'
     assert report.format_ == 4
     assert report.agent_version == '4.2.1'
     assert report.run_time == report.end - report.start
     assert len(report.events) == 1
开发者ID:bhughes4128,项目名称:pypuppetdb,代码行数:34,代码来源:test_types.py


示例10: __init__

    def __init__(self, node, hash_, start, end, received, version, format_, agent_version, transaction):

        self.node = node
        self.hash_ = hash_
        self.start = json_to_datetime(start)
        self.end = json_to_datetime(end)
        self.received = json_to_datetime(received)
        self.version = version
        self.format_ = format_
        self.agent_version = agent_version
        self.run_time = self.end - self.start
        self.transaction = transaction
        self.__string = "{0}".format(self.hash_)
开发者ID:vicinus,项目名称:pypuppetdb,代码行数:13,代码来源:types.py


示例11: __init__

    def __init__(self, api, name, deactivated=None, expired=None,
                 report_timestamp=None, catalog_timestamp=None,
                 facts_timestamp=None, status_report=None,
                 noop=False, noop_pending=False, report=None,
                 unreported=False, unreported_time=None,
                 report_environment='production',
                 catalog_environment='production',
                 facts_environment='production',
                 latest_report_hash=None, cached_catalog_status=None):
        self.name = name
        self.report = report
        self.unreported_time = unreported_time
        self.report_timestamp = report_timestamp
        self.catalog_timestamp = catalog_timestamp
        self.facts_timestamp = facts_timestamp
        self.report_environment = report_environment
        self.catalog_environment = catalog_environment
        self.facts_environment = facts_environment
        self.latest_report_hash = latest_report_hash
        self.cached_catalog_status = cached_catalog_status

        if unreported:
            self.status = 'unreported'
        elif noop and noop_pending:
            self.status = 'noop'
        else:
            self.status = status_report

        if deactivated is not None:
            self.deactivated = json_to_datetime(deactivated)
        else:
            self.deactivated = False
        if expired is not None:
            self.expired = json_to_datetime(expired)
        else:
            self.expired = False
        if report_timestamp is not None:
            self.report_timestamp = json_to_datetime(report_timestamp)
        else:
            self.report_timestamp = report_timestamp
        if facts_timestamp is not None:
            self.facts_timestamp = json_to_datetime(facts_timestamp)
        else:
            self.facts_timestamp = facts_timestamp
        if catalog_timestamp is not None:
            self.catalog_timestamp = json_to_datetime(catalog_timestamp)
        else:
            self.catalog_timestamp = catalog_timestamp

        self.__api = api
        self.__string = self.name
开发者ID:redref,项目名称:pypuppetdb,代码行数:51,代码来源:types.py


示例12: test_report

def test_report():
    report = Report('node1.puppet.board', 'hash#', '2013-08-01T09:57:00.000Z',
                    '2013-08-01T10:57:00.000Z', '2013-08-01T10:58:00.000Z',
                    '1351535883', 3, '3.2.1',
                    'af9f16e3-75f6-4f90-acc6-f83d6524a6f3')
    assert report.node == 'node1.puppet.board'
    assert report.hash_ == 'hash#'
    assert report.start == json_to_datetime('2013-08-01T09:57:00.000Z')
    assert report.end == json_to_datetime('2013-08-01T10:57:00.000Z')
    assert report.received == json_to_datetime('2013-08-01T10:58:00.000Z')
    assert report.version == '1351535883'
    assert report.format_ == 3
    assert report.agent_version == '3.2.1'
    assert report.run_time == report.end - report.start
    assert report.transaction == 'af9f16e3-75f6-4f90-acc6-f83d6524a6f3'
开发者ID:KlavsKlavsen,项目名称:pypuppetdb,代码行数:15,代码来源:test_types.py


示例13: test_event

    def test_event(self):
        event = Event(
            "node",
            "failure",
            "2013-08-01T10:57:00.000Z",
            "hash#",
            "/etc/ssh/sshd_config",
            "ensure",
            "Nothing to say",
            "present",
            "absent",
            "file",
            "Ssh::Server",
            ["Stage[main]", "Ssh::Server", "File[/etc/ssh/sshd_config]"],
            "/etc/puppet/modules/ssh/manifests/server.pp",
            80,
        )

        assert event.node == "node"
        assert event.status == "failure"
        assert event.failed is True
        assert event.timestamp == json_to_datetime("2013-08-01T10:57:00.000Z")
        assert event.hash_ == "hash#"
        assert event.item["title"] == "/etc/ssh/sshd_config"
        assert event.item["type"] == "file"
        assert event.item["property"] == "ensure"
        assert event.item["message"] == "Nothing to say"
        assert event.item["old"] == "absent"
        assert event.item["new"] == "present"
        assert str(event) == str("file[/etc/ssh/sshd_config]/hash#")
        assert unicode(event) == unicode("file[/etc/ssh/sshd_config]/hash#")
        assert repr(event) == str("Event: file[/etc/ssh/sshd_config]/hash#")
开发者ID:octomike,项目名称:pypuppetdb,代码行数:32,代码来源:test_types.py


示例14: test_expired

 def test_expired(self):
     node = Node("_", "node", expired="2013-08-01T09:57:00.000Z")
     assert node.name == "node"
     assert node.expired == json_to_datetime("2013-08-01T09:57:00.000Z")
     assert str(node) == str("node")
     assert unicode(node) == unicode("node")
     assert repr(node) == str("<Node: node>")
开发者ID:octomike,项目名称:pypuppetdb,代码行数:7,代码来源:test_types.py


示例15: test_expired

 def test_expired(self):
     node = Node('_', 'node',
                 expired='2013-08-01T09:57:00.000Z',)
     assert node.name == 'node'
     assert node.expired == json_to_datetime('2013-08-01T09:57:00.000Z')
     assert str(node) == str('node')
     assert unicode(node) == unicode('node')
     assert repr(node) == str('<Node: node>')
开发者ID:redref,项目名称:pypuppetdb,代码行数:8,代码来源:test_types.py


示例16: test_json_to_datetime

def test_json_to_datetime():
    json_datetime = '2013-08-01T09:57:00.000Z'
    python_datetime = json_to_datetime(json_datetime)
    assert python_datetime.dst() == datetime.timedelta(0)
    assert python_datetime.date() == datetime.date(2013, 8, 1)
    assert python_datetime.tzname() == 'UTC'
    assert python_datetime.utcoffset() == datetime.timedelta(0)
    assert python_datetime.dst() == datetime.timedelta(0)
开发者ID:denmat,项目名称:pypuppetdb,代码行数:8,代码来源:test_utils.py


示例17: test_without_status

    def test_without_status(self):
        node = Node('_', 'node',
                    report_timestamp='2013-08-01T09:57:00.000Z',
                    catalog_timestamp='2013-08-01T09:57:00.000Z',
                    facts_timestamp='2013-08-01T09:57:00.000Z',)

        assert node.name == 'node'
        assert node.deactivated is False
        assert node.expired is False
        assert node.report_timestamp == \
            json_to_datetime('2013-08-01T09:57:00.000Z')
        assert node.facts_timestamp == \
            json_to_datetime('2013-08-01T09:57:00.000Z')
        assert node.catalog_timestamp == \
            json_to_datetime('2013-08-01T09:57:00.000Z')
        assert str(node) == str('node')
        assert unicode(node) == unicode('node')
        assert repr(node) == str('<Node: node>')
开发者ID:redref,项目名称:pypuppetdb,代码行数:18,代码来源:test_types.py


示例18: test_without_status

    def test_without_status(self):
        node = Node(
            "_",
            "node",
            report_timestamp="2013-08-01T09:57:00.000Z",
            catalog_timestamp="2013-08-01T09:57:00.000Z",
            facts_timestamp="2013-08-01T09:57:00.000Z",
        )

        assert node.name == "node"
        assert node.deactivated is False
        assert node.expired is False
        assert node.report_timestamp == json_to_datetime("2013-08-01T09:57:00.000Z")
        assert node.facts_timestamp == json_to_datetime("2013-08-01T09:57:00.000Z")
        assert node.catalog_timestamp == json_to_datetime("2013-08-01T09:57:00.000Z")
        assert str(node) == str("node")
        assert unicode(node) == unicode("node")
        assert repr(node) == str("<Node: node>")
开发者ID:octomike,项目名称:pypuppetdb,代码行数:18,代码来源:test_types.py


示例19: test_report_with_producer

    def test_report_with_producer(self):
        report = Report('_', "test.test.com", "hash#",
                        '2015-08-31T21:07:00.000Z',
                        '2015-08-31T21:09:00.000Z',
                        '2015-08-31T21:10:00.000Z',
                        '1482347613', 4, '4.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        producer="puppet01.test.com")

        assert report.node == "test.test.com"
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
        assert report.agent_version == '4.2.1'
        assert report.run_time == report.end - report.start
        assert report.producer == "puppet01.test.com"
        assert str(report) == str('hash#')
        assert unicode(report) == unicode('hash#')
        assert repr(report) == str('Report: hash#')
开发者ID:redref,项目名称:pypuppetdb,代码行数:22,代码来源:test_types.py


示例20: test_with_status_unreported

    def test_with_status_unreported(self):
        node = Node(
            "_",
            "node",
            report_timestamp="2013-08-01T09:57:00.000Z",
            catalog_timestamp="2013-08-01T09:57:00.000Z",
            facts_timestamp="2013-08-01T09:57:00.000Z",
            status="unreported",
            unreported_time="0d 5h 20m",
        )

        assert node.name == "node"
        assert node.deactivated is False
        assert node.expired is False
        assert node.report_timestamp == json_to_datetime("2013-08-01T09:57:00.000Z")
        assert node.facts_timestamp == json_to_datetime("2013-08-01T09:57:00.000Z")
        assert node.catalog_timestamp == json_to_datetime("2013-08-01T09:57:00.000Z")
        assert node.status is "unreported"
        assert node.unreported_time is "0d 5h 20m"
        assert str(node) == str("node")
        assert unicode(node) == unicode("node")
        assert repr(node) == str("<Node: node>")
开发者ID:octomike,项目名称:pypuppetdb,代码行数:22,代码来源:test_types.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python annrpython.RPythonAnnotator类代码示例发布时间:2022-05-27
下一篇:
Python pypuppetdb.connect函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap