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


Python VHost.from_string方法代码示例

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


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

示例1: test_to_string_full

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_to_string_full(self):
     vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system',
                   [Log('ACCESSLOG'), Log('WARNINGLOG')],
                   ['127.0.0.0/8', '192.168.0.0/16'],
                   {'host.domain': True, 'test.domain': None},
                   'private_key', 'certificate')
     copy = VHost.from_string(str(vhost))
     self.assertEqual(vhost, copy)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:10,代码来源:vhost_test.py

示例2: test_equality

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_equality(self):
     vhost_0 = VHost('test vhost', 80, 'HTTP', '/www', '/system',
                     [Log('ACCESSLOG'), Log('WARNINGLOG')],
                     ['127.0.0.0/8', '192.168.0.0/16'],
                     {'host.domain': None}, 'private_key', 'certificate')
     vhost_1 = VHost('test vhost', 80, 'HTTP', '/www', '/system',
                     [Log('ACCESSLOG'), Log('WARNINGLOG')],
                     ['127.0.0.0/8', '192.168.0.0/16'],
                     {'host.domain': None}, 'private_key', 'certificate')
     self.assertEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.set_name('different')
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.set_port(81)
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.set_protocol('HTTPS')
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.set_doc_root('/var/www')
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.set_sys_root('/var/system')
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.add_log(Log('NEWLOG'))
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.add_ip('10.0.0.0/8')
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.add_host('newhost', None)
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.set_private_key('new_key')
     self.assertNotEqual(vhost_0, vhost_1)
     vhost_1 = VHost.from_string(str(vhost_0))
     vhost_1.set_certificate('new certificate')
     self.assertNotEqual(vhost_0, vhost_1)
     self.assertNotEqual(vhost_0, [])
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:43,代码来源:vhost_test.py

示例3: test_vhost

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
    def test_vhost(self):
        text = '''
<VHOST custom="unknown">
  <PORT>123</PORT>
  <UNKNOWN>
    <CUSTOM />
  </UNKNOWN>
</VHOST>'''
        vhost = VHost.from_string(text)
        tree = vhost.to_lxml_element()
        self.assertEqual('unknown', tree.get('custom'))
        unknown = tree.findall('UNKNOWN')
        self.assertEqual(1, len(unknown))
        unknown = unknown[0]
        custom = list(unknown)
        self.assertEqual(1, len(custom))
        custom = custom[0]
        self.assertEqual('CUSTOM', custom.tag)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:20,代码来源:vhost_test.py

示例4: test_from_string_full

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
    def test_from_string_full(self):
        text = '''<VHOST>
  <NAME>test vhost</NAME>
  <PORT>80</PORT>
  <PROTOCOL>HTTP</PROTOCOL>
  <DOCROOT>/www</DOCROOT>
  <SYSROOT>/system</SYSROOT>
  <ACCESSLOG />
  <WARNINGLOG />
  <IP>127.0.0.0/8</IP>
  <IP>192.168.0.0/16</IP>
  <HOST useRegex="YES">host.domain</HOST>
  <HOST>test.domain</HOST>
  <SSL_PRIVATEKEY>private_key</SSL_PRIVATEKEY>
  <SSL_CERTIFICATE>certificate</SSL_CERTIFICATE>
</VHOST>'''
        vhost = VHost.from_string(text)
        right = VHost('test vhost', 80, 'HTTP', '/www', '/system',
                      [Log('ACCESSLOG'), Log('WARNINGLOG')],
                      ['127.0.0.0/8', '192.168.0.0/16'],
                      {'host.domain': True, 'test.domain': None},
                      'private_key', 'certificate')
        self.assertEqual(vhost, right)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:25,代码来源:vhost_test.py

示例5: test_to_string_logs

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_to_string_logs(self):
     vhost = VHost(logs = [Log('ACCESSLOG'), Log('SOMELOG')])
     copy = VHost.from_string(str(vhost))
     self.assertEqual(vhost, copy)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:6,代码来源:vhost_test.py

示例6: test_to_string_sys_root

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_to_string_sys_root(self):
     vhost = VHost(sys_root = '/system')
     copy = VHost.from_string(str(vhost))
     self.assertEqual(vhost, copy)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:6,代码来源:vhost_test.py

示例7: test_to_string_doc_root

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_to_string_doc_root(self):
     vhost = VHost(doc_root = '/www')
     copy = VHost.from_string(str(vhost))
     self.assertEqual(vhost, copy)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:6,代码来源:vhost_test.py

示例8: test_to_string_protocol

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_to_string_protocol(self):
     vhost = VHost(protocol = 'HTTP')
     copy = VHost.from_string(str(vhost))
     self.assertEqual(vhost, copy)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:6,代码来源:vhost_test.py

示例9: test_from_string_protocol

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_from_string_protocol(self):
     text = '<VHOST><PROTOCOL>HTTP</PROTOCOL></VHOST>'
     vhost = VHost.from_string(text)
     right = VHost(protocol = 'HTTP')
     self.assertEqual(vhost, right)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:7,代码来源:vhost_test.py

示例10: test_from_string_name

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_from_string_name(self):
     text = '<VHOST><NAME>test vhost</NAME></VHOST>'
     vhost = VHost.from_string(text)
     right = VHost('test vhost')
     self.assertEqual(vhost, right)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:7,代码来源:vhost_test.py

示例11: test_to_string_private_key

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_to_string_private_key(self):
     vhost = VHost(private_key = 'private_key')
     copy = VHost.from_string(str(vhost))
     self.assertEqual(vhost, copy)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:6,代码来源:vhost_test.py

示例12: test_from_string_certificate

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_from_string_certificate(self):
     text = '<VHOST><SSL_CERTIFICATE>certificate</SSL_CERTIFICATE></VHOST>'
     vhost = VHost.from_string(text)
     right = VHost(certificate = 'certificate')
     self.assertEqual(vhost, right)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:7,代码来源:vhost_test.py

示例13: test_from_string_private_key

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_from_string_private_key(self):
     text = '<VHOST><SSL_PRIVATEKEY>private_key</SSL_PRIVATEKEY></VHOST>'
     vhost = VHost.from_string(text)
     right = VHost(private_key = 'private_key')
     self.assertEqual(vhost, right)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:7,代码来源:vhost_test.py

示例14: test_from_string_host

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_from_string_host(self):
     text = '<VHOST><HOST useRegex="YES">.*</HOST><HOST>a.org</HOST></VHOST>'
     vhost = VHost.from_string(text)
     right = VHost(host = {'.*': True, 'a.org': None})
     self.assertEqual(vhost, right)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:7,代码来源:vhost_test.py

示例15: test_from_string_ip

# 需要导入模块: from vhost import VHost [as 别名]
# 或者: from vhost.VHost import from_string [as 别名]
 def test_from_string_ip(self):
     text = '<VHOST><IP>127.0.0.0/8</IP></VHOST>'
     vhost = VHost.from_string(text)
     right = VHost(ip = ['127.0.0.0/8'])
     self.assertEqual(vhost, right)
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:7,代码来源:vhost_test.py


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