* David Rock <da...@graniteweb.com> [2017-03-13 11:28:57 -0500]: > > On Mar 13, 2017, at 10:54, Toni Fuente via Tutor <tutor@python.org> wrote: > > > > Hi, > > > > I've got this script that goes through an httpd conf file, and gets the > > related bits of it for a site, and writes a new config with values that > > I am interested. The problem is that it finds the first chunk and > > returns it, but I need to go to the end of all chunks list, because > > there are also some chunks related to the same site that I need to > > collect (virtualhost *:80 and virtualhost:443). I was > > > > I was thinking in a while loop in the find_chunk function that will go > > through > > all chunks and return the chunks that site is on, but I don't know how to > > construct it. > > You just need to make a list or a dict to store the information for each > site, and add the results to it. If you use a list, it would be > list.append(), for example. > > I don’t really follow what you expect the output to be, though. > What do you want the results of running the script to look like?
At the moment I am writing to a file: with open("/tmp/afm/etc/httpd/conf.d/vhosts.inc/%s.conf" % site, "a") as cfile: cfile.write("".join(new_config)) and whenever finds the first chunck in total_configs.txt writes to it, and doesn't carry on searching for other chunks that contain "site", foo.com, so it won't find the site in port 80. It just writes this: <VirtualHost *:443> ServerAlias www.foo.com ServerAdmin hostmas...@foo.com ErrorLog /websites/katz/logs/1cfl.com/error_ssl_log ScriptAlias /cgi-bin/ /websites/katz/cgi-bin/1cfl.com/ </VirtualHost> what I want to write is both: <VirtualHost *:443> ServerAlias www.foo.com ServerAdmin hostmas...@foo.com ErrorLog /websites/katz/logs/1cfl.com/error_ssl_log ScriptAlias /cgi-bin/ /websites/katz/cgi-bin/1cfl.com/ </VirtualHost> <VirtualHost *:80> ServerAlias www.foo.com ServerAdmin hostmas...@foo.com ErrorLog /websites/katz/logs/1cfl.com/error_ssl_log ScriptAlias /cgi-bin/ /websites/katz/cgi-bin/1cfl.com/ </VirtualHost> _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor