Beispiel #1
0
 def testGetHostsFromCsv(self):
     from Exscript.util.file import get_hosts_from_csv
     result    = get_hosts_from_csv(self.csv_host_file.name)
     hostnames = [h.get_name() for h in result]
     testvars  = [h.get('test')[0] for h in result]
     self.assertEqual(hostnames, expected_hosts)
     self.assertEqual(testvars, ['blah' for h in result])
Beispiel #2
0
 def testGetHostsFromCsv(self):
     from Exscript.util.file import get_hosts_from_csv
     result = get_hosts_from_csv(self.csv_host_file.name)
     hostnames = [h.get_name() for h in result]
     testvars = [h.get('test')[0] for h in result]
     self.assertEqual(hostnames, expected_hosts)
     self.assertEqual(testvars, ['blah' for h in result])
Beispiel #3
0
    def from_csv_file(service, filename, encoding='utf-8'):
        """
        Creates a new instance by reading the given CSV file.

        @type  service: str
        @param service: The service name.
        @type  filename: str
        @param filename: A file containing a CSV formatted list of hosts.
        @type  encoding: str
        @param encoding: The name of the encoding.
        @rtype:  Order
        @return: A new instance of an order.
        """
        order = Order(service)
        hosts = get_hosts_from_csv(filename, encoding=encoding)
        add_hosts_to_etree(order.xml, hosts)
        return order
Beispiel #4
0
    def from_csv_file(service, filename, encoding = 'utf-8'):
        """
        Creates a new instance by reading the given CSV file.

        @type  service: str
        @param service: The service name.
        @type  filename: str
        @param filename: A file containing a CSV formatted list of hosts.
        @type  encoding: str
        @param encoding: The name of the encoding.
        @rtype:  Order
        @return: A new instance of an order.
        """
        order = Order(service)
        hosts = get_hosts_from_csv(filename, encoding = encoding)
        add_hosts_to_etree(order.xml, hosts)
        return order