Re: str.find for multiple strings

From: Josef Meile (jmeile_at_hotmail.com)
Date: 02/12/04


Date: Thu, 12 Feb 2004 17:18:13 +0100

Hi,

looking at your code is obvious that what you want to do
is to look for servers on the "ath_ips.txt" file and then
comment the line where they appear. I think this search
and replace function can be done with regular expressions
(see the re module). The servers belong to the same
network, and only the two left digits are different.

Regards,
Josef

"Bart Nessux" <bart_nessux@hotmail.com> wrote in message
news:c0e0u6$p8g$1@solaris.cc.vt.edu...
> Peter Hansen wrote:
> > Bart Nessux wrote:
> >
> >>x = str.find(temp, '120.50')
> >>
> >>I am looking for '120.50' '120.51' '122.78' etc. How can I do this with
> >>just one str.find... I can use re if I must, but I'd like to avoid it if
> >>possible.
> >
> >
> > In addition to Fecundo's questions, here's another. What does "temp"
> > contain? A single temperature string, or a temperature embedded in
> > a bunch of other stuff, or a whole series of temperatures, or what?
> >
> > -Peter
>
> Here's what I'm doing
>
> def exclude():
> import os
> os.chdir('/home/rbt/scripts')
> inputFile = file('ath_ips.txt', 'r')
> data = inputFile.read()
> inputFile.close()
> comment = '#'
> net0 = '128.173.120.'
> net1 = '128.173.122.'
> host0 = ['50','51','52','53','54','55']
> host1 = ['17','25','49','50','55','58','70']
> for h0 in host0:
> h0 = net0+h0
> rep0 = comment+h0
> sea0 = str.find(data, h0)
> if sea0 >=0:
> data = data.replace(h0, rep0)
> for h1 in host1:
> h1 = net1+h1
> rep1 = comment+h1
> sea1 = str.find(data, h1)
> if sea1 >=0:
> data = data.replace(h1, rep1)
> outputFile = file('ath_ips.txt', 'w')
> outputFile.write(data)
> outputFile.close()



Relevant Pages

  • Re: Server Cooling
    ... For a client with a similar situation, where the building air conditioning is out of their control, I installed a network management card in their ACP 1500 UPS. ... The management card includes a temperature sensor and the APC software can be setup to shut down the server when the temperature exceeds your designated limit. ... Dell's 2900 servers are rated to run in an ambient up to 95 degrees F. As others have said, as you get anywhere near that temperature the 6-7 cooling fans ramp up to full speed and it sounds like a jet engine. ...
    (microsoft.public.windows.server.sbs)
  • Re: server temperature - whats optimal
    ... when things get too hot for the server so make sure your physical settings ... temperature is at the maximum to keep cool. ... and the number of servers. ... My philosophy is that as long as my servers are on the air conditioners ...
    (microsoft.public.windows.server.general)
  • Re: server temperature - whats optimal
    ... Maybe that's why her boss doesn't want air conditioning in there... ... My philosophy is that as long as my servers are on the air conditioners ... You usually see a max operating temperature in the ...
    (microsoft.public.windows.server.general)
  • Re: server temperature - whats optimal
    ... My philosophy is that as long as my servers are on the air conditioners need ... You usually see a max operating temperature in the manuals ...
    (microsoft.public.windows.server.general)
  • Re: Soundproofing an enclosure
    ... disk at about 2W and a lot quieter. ... Don't focus too hard on temperature as an indicator of drive ... Also servers are prone to more noise since most of them are dual/ ... CPU shouldn't be over 60C at LOAD, ...
    (rec.audio.pro)