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


Python PsDashRunner.get_local_node方法代码示例

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


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

示例1: test_reload_logs

# 需要导入模块: from psdash.run import PsDashRunner [as 别名]
# 或者: from psdash.run.PsDashRunner import get_local_node [as 别名]
 def test_reload_logs(self):
     _, filename = tempfile.mkstemp()
     r = PsDashRunner(args=['-l', filename])
     pre_count = len(r.get_local_node().logs.available)
     r.get_local_node().logs.add_patterns(r.app.config['PSDASH_LOGS'])
     post_count = len(r.get_local_node().logs.available)
     self.assertEqual(pre_count, post_count)
开发者ID:ArcherSys,项目名称:psdash,代码行数:9,代码来源:test_run.py

示例2: test_update_net_io_counters

# 需要导入模块: from psdash.run import PsDashRunner [as 别名]
# 或者: from psdash.run.PsDashRunner import get_local_node [as 别名]
    def test_update_net_io_counters(self):
        r = PsDashRunner()
        socket.getaddrinfo('example.org', 80)
        counters = r.get_local_node().net_io_counters.update()

        for c in counters.itervalues():
            if c['rx_per_sec'] > 0 and c['tx_per_sec'] > 0:
                break
        else:
            self.fail("Didn't find any changed network interface")
开发者ID:ArcherSys,项目名称:psdash,代码行数:12,代码来源:test_run.py

示例3: TestLogs

# 需要导入模块: from psdash.run import PsDashRunner [as 别名]
# 或者: from psdash.run.PsDashRunner import get_local_node [as 别名]
class TestLogs(unittest2.TestCase):
    def _create_log_file(self):
        fd, filename = tempfile.mkstemp()
        fp = os.fdopen(fd, 'w')
        fp.write('woha\n' * 100)
        fp.write('something\n')
        fp.write('woha\n' * 100)
        fp.flush()
        return filename

    def setUp(self):
        self.r = PsDashRunner()
        self.app = self.r.app
        self.client = self.app.test_client()
        self.filename = self._create_log_file()
        self.r.get_local_node().logs.add_available(self.filename)

    def test_logs(self):
        resp = self.client.get('/logs')
        self.assertEqual(resp.status_code, httplib.OK)

    def test_logs_removed_file(self):
        filename = self._create_log_file()
        self.r.get_local_node().logs.add_available(filename)

        # first visit to make sure the logs are properly initialized
        resp = self.client.get('/logs')
        self.assertEqual(resp.status_code, httplib.OK)

        os.unlink(filename)

        resp = self.client.get('/logs')
        self.assertEqual(resp.status_code, httplib.OK)

    def test_logs_removed_file_uninitialized(self):
        filename = self._create_log_file()
        self.r.get_local_node().logs.add_available(filename)

        os.unlink(filename)

        resp = self.client.get('/logs')
        self.assertEqual(resp.status_code, httplib.OK)

    def test_view(self):
        resp = self.client.get('/log?filename=%s' % self.filename)
        self.assertEqual(resp.status_code, httplib.OK)

    def test_search(self):
        resp = self.client.get('/log/search?filename=%s&text=%s' % (self.filename, 'something'),
                               environ_overrides={'HTTP_X_REQUESTED_WITH': 'xmlhttprequest'})

        self.assertEqual(resp.status_code, httplib.OK)
        try:
            data = json.loads(resp.data)
            self.assertIn('something', data['content'])
        except ValueError:
            self.fail('Log search did not return valid json data')

    def test_read(self):
        resp = self.client.get('/log?filename=%s' % self.filename,
                               environ_overrides={'HTTP_X_REQUESTED_WITH': 'xmlhttprequest'})
        self.assertEqual(resp.status_code, httplib.OK)

    def test_read_tail(self):
        resp = self.client.get('/log?filename=%s&seek_tail=1' % self.filename)
        self.assertEqual(resp.status_code, httplib.OK)

    def test_non_existing_file(self):
        filename = "/var/log/surelynotaroundright.log"

        resp = self.client.get('/log?filename=%s' % filename)
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

        resp = self.client.get('/log/search?filename=%s&text=%s' % (filename, 'something'))
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

        resp = self.client.get('/log/read?filename=%s' % filename)
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

        resp = self.client.get('/log/read_tail?filename=%s' % filename)
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)
开发者ID:ArcherSys,项目名称:psdash,代码行数:83,代码来源:test_web.py

示例4: TestEndpoints

# 需要导入模块: from psdash.run import PsDashRunner [as 别名]
# 或者: from psdash.run.PsDashRunner import get_local_node [as 别名]
class TestEndpoints(unittest2.TestCase):
    def setUp(self):
        self.r = PsDashRunner()
        self.app = self.r.app
        self.client = self.app.test_client()
        self.pid = os.getpid()
        self.r.get_local_node().net_io_counters.update()

    def test_index(self):
        resp = self.client.get('/')
        self.assertEqual(resp.status_code, httplib.OK)

    @unittest2.skipIf('TRAVIS' in os.environ, 'Functionality not supported on Travis CI')
    def test_disks(self):
        resp = self.client.get('/disks')
        self.assertEqual(resp.status_code, httplib.OK)

    def test_network(self):
        resp = self.client.get('/network')
        self.assertEqual(resp.status_code, httplib.OK)

    def test_processes(self):
        resp = self.client.get('/processes')
        self.assertEqual(resp.status_code, httplib.OK)

    def test_process_overview(self):
        resp = self.client.get('/process/%d' % self.pid)
        self.assertEqual(resp.status_code, httplib.OK)

    @unittest2.skipIf(os.environ.get('USER') == 'root', 'It would fail as root as we would have access to pid 1')
    def test_process_no_access(self):
        resp = self.client.get('/process/1')  # pid 1 == init
        self.assertEqual(resp.status_code, httplib.UNAUTHORIZED)

    def test_process_non_existing_pid(self):
        resp = self.client.get('/process/0')
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

    def test_process_children(self):
        resp = self.client.get('/process/%d/children' % self.pid)
        self.assertEqual(resp.status_code, httplib.OK)

    def test_process_connections(self):
        resp = self.client.get('/process/%d/connections' % self.pid)
        self.assertEqual(resp.status_code, httplib.OK)

    def test_process_environment(self):
        resp = self.client.get('/process/%d/environment' % self.pid)
        self.assertEqual(resp.status_code, httplib.OK)

    def test_process_files(self):
        resp = self.client.get('/process/%d/files' % self.pid)
        self.assertEqual(resp.status_code, httplib.OK)

    def test_process_threads(self):
        resp = self.client.get('/process/%d/threads' % self.pid)
        self.assertEqual(resp.status_code, httplib.OK)

    def test_process_memory(self):
        resp = self.client.get('/process/%d/memory' % self.pid)
        self.assertEqual(resp.status_code, httplib.OK)

    @unittest2.skipIf('TRAVIS' in os.environ, 'Functionality not supported on Travis CI')
    def test_process_limits(self):
        resp = self.client.get('/process/%d/limits' % self.pid)
        self.assertEqual(resp.status_code, httplib.OK)

    def test_process_invalid_section(self):
        resp = self.client.get('/process/%d/whatnot' % self.pid)
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

    def test_non_existing(self):
        resp = self.client.get('/prettywronghuh')
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

    def test_connection_filters(self):
        resp = self.client.get('/network?laddr=127.0.0.1')
        self.assertEqual(resp.status_code, httplib.OK)

    def test_register_node(self):
        resp = self.client.get('/register?name=examplehost&port=500')
        self.assertEqual(resp.status_code, httplib.OK)

    def test_register_node_all_params_required(self):
        resp = self.client.get('/register?name=examplehost')
        self.assertEqual(resp.status_code, httplib.BAD_REQUEST)

        resp = self.client.get('/register?port=500')
        self.assertEqual(resp.status_code, httplib.BAD_REQUEST)
开发者ID:ArcherSys,项目名称:psdash,代码行数:91,代码来源:test_web.py

示例5: test_local_node_is_added

# 需要导入模块: from psdash.run import PsDashRunner [as 别名]
# 或者: from psdash.run.PsDashRunner import get_local_node [as 别名]
 def test_local_node_is_added(self):
     r = PsDashRunner()
     self.assertIsInstance(r.get_local_node(), LocalNode)
开发者ID:ArcherSys,项目名称:psdash,代码行数:5,代码来源:test_run.py


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