strftime in python 2.2

2007-08-13 Thread Flyzone
I'm trying to make work this code in python 2.2.3: check=datetime.datetime.today().strftime(%H%M) but datetime is not supported in that version but just in the later. I can't upgrade python, too many dependencies in a critical system. How can i convert that string to have the same result? Hope

Re: problem on waiting exit thread and write on file

2007-06-15 Thread Flyzone
Marc 'BlackJack' Rintsch ha scritto: for thread in threads: thread.join() Much shorter, isn't it!? :-) If i do like you tell, all thread will run together right? So i'll get troubles! I have a list of hostname, i run a network program and then i need to write some of the output

problem on waiting exit thread and write on file

2007-06-13 Thread Flyzone
I have a list of parameters. I need to run in thread a command, one thread for one parameter. So i made a for loop, creating 5 threads and waiting their stop with: for parameter in parameters Thread{ write on BW2 } Main { open file BW2 for write . (creating list

popen e pclose on python 2.3 question

2007-06-12 Thread Flyzone
I need to run a network program and return output in a variable name without use temporany file. So i tought to use popen (i'm using python 2.3, i can't upgrade). RESULT = os.popen('command'+HOST, 'r') I have a problem about it: i need to kill the child if the program take more than 300 ms, but i

Re: popen e pclose on python 2.3 question

2007-06-12 Thread Flyzone
i need to kill the child if the program take more than 300 ms, but i need also to wait this 300 ms to have the reply. I reply by myself: from popen2 import Popen3 cmd = Popen3('command','r') waiting=0 while (cmd.poll()==-1): time.sleep(0.1) waiting+=1 if (waiting3):

checking if hour is between two hours

2007-05-11 Thread Flyzone
Hi all, i'm again working on my script of parsing logfiles :) I putted a new function to disable the rule of error between a certain hours, cause i want to use it as a monitoring script that run every 5 minutes and to disable error in hours of maintenance. But i have some problems to check it. In

Re: regexp match string with word1 and not word2

2007-05-02 Thread Flyzone
On 30 Apr, 20:00, Steven Bethard [EMAIL PROTECTED] wrote: Well then it seems like you might want to rethink this rule-file approach since your problem is clearly not amenable to regular expressions. [cut] That said, here's a regexp that might work:: ((?!two:).)*one((?!two:).)* That makes

regexp match string with word1 and not word2

2007-04-30 Thread Flyzone
Hello, i have again problem with regexp :-P I need to match all lines that contain one word but not contain another. Like to do grep one | grep -v two: The syntax of the string is: (any printable char)two:(any printable char)one(any printable char) Example: Apr 30 00:00:09 v890neg0 two: [ID 702911

Re: regexp match string with word1 and not word2

2007-04-30 Thread Flyzone
James Stroud ha scritto: The P.S: suggests homework, but this can't be homework because python regex won't do this, so your teacher gets an F if its homework. You Not a homework, but a workwork :-) I'm writing a script to parse logfiles, and I have began to study python for this (bash was too

Re: regexp match string with word1 and not word2

2007-04-30 Thread Flyzone
On 30 Apr, 17:11, Steven Bethard [EMAIL PROTECTED] wrote: You don't need a regexp:; I need a regexp.i'm parsing a file with a rule-file that contains also regexp and strings too Read my post to James Stroud. -- http://mail.python.org/mailman/listinfo/python-list

Re: freeze and problem with static libraries

2007-04-26 Thread Flyzone
On 24 Apr, 17:23, Flyzone [EMAIL PROTECTED] wrote: I get this warning on freezing my source: I use the command: ./Python-2.3.6/Tools/freeze/freeze.py /path/to/my/file.py -- http://mail.python.org/mailman/listinfo/python-list

freeze and problem with static libraries

2007-04-24 Thread Flyzone
Hi, i need to compile a python source (2.3.6) to make it standalone on Solaris 9. I get this warning on freezing my source: Warning: unknown modules remain: _locale _random _socket array binascii cStringIO datetime fcntl math pwd select strop termios time in the source i have: import os, stat,

exception just to avoid output error (newbie)

2007-04-18 Thread Flyzone
Hi I'm trying to delete some files, but i get an exception error if the file don't exist. I can use an {if fileexist(file) then delete}, but it will get cpu time. So i catch the exception with: try: os.remove(filename) except EnvironmentError: error=1 If i just want to avoid the

split and regexp on textfile

2007-04-13 Thread Flyzone
Hi, i have a problem with the split function and regexp. I have a file that i want to split using the date as token. Here a sample: - Mon Apr 9 22:30:18 2007 text text Mon Apr 9 22:31:10 2007 text text I'm trying to put all the lines in a one string and then to separate it (could be

Re: split and regexp on textfile

2007-04-13 Thread Flyzone
On 13 Apr, 10:40, [EMAIL PROTECTED] wrote: you trying to match the date part right? if re is what you desire, here's one example: Amm..not! I need to get the text-block between the two data, not the data! :) -- http://mail.python.org/mailman/listinfo/python-list

Re: split and regexp on textfile

2007-04-13 Thread Flyzone
On 13 Apr, 11:14, [EMAIL PROTECTED] wrote: change to pat.split(data) then. next what i have tried originally..but is not working, my result is here: [Mon Feb 26 11:25:04 2007\ntext\n text\ntext\nMon Feb 26 11:25:16 2007\ntext\n text\n text\nMon Feb 26 17:06:41 2007\ntext] all together :( --

Re: split and regexp on textfile

2007-04-13 Thread Flyzone
On 13 Apr, 11:30, Flyzone [EMAIL PROTECTED] wrote: all together :( Damn was wrong mine regexp: pat = re.compile([A-Z][a-z][a-z][ ][A-Z][a-z][a-z][ ][0-9| ][0-9][ ] [0-9][0-9][:][0-9][0-9],re.M|re.DOTALL) now is working! :) Great! really thanks for the helps! A little question: the pat.split

parsing text in blocks and line too

2007-04-12 Thread flyzone
Goodmorning people :) I have just started to learn this language and i have a logical problem. I need to write a program to parse various file of text. Here two sample: --- trial text bla bla bla bla error bla bla bla bla bla bla bla bla on more lines trial text bla bla