ncurses programming
hi, i want to use ncurses library in python i`ve found proper library for that, PyNcurses. then i searched for some documentation about ncurses programming, i only found that web site ; http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/ this howto is nice but seems to me, this is for experienced ncurses programmers who have just migrated to python so i dont understand anything from examples and howto. what should i do ? firstly should i learn ncurses programmin on C then migrate to python? thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: ncurses programming
thank you very much for your suggestions and links, also slang got my attention. thanks. -- http://mail.python.org/mailman/listinfo/python-list
button design in curses library
hi, im using curses library in my program, i need a button. but i cannot find anything about it. should i do the button via newwin function with bold characters ? any help will be appreciated thanks. -- http://mail.python.org/mailman/listinfo/python-list
taking x-window screen shot
hi i have some python practice and want to develop tiny prgramme that takes screen shots from command line, im using gnome now but my programme should support the others especially pure X - window. also i want to learn some more about inside when taking screen shots. thanks. -- http://mail.python.org/mailman/listinfo/python-list
get just one character
hello everybody, how can i just get 1 character ? i`ve done a search but just found getch() for windows, i need same for unix and raw_input has any option that is not documented ? thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: get just one character
Paul Watson wrote: >Sinan Nalkaya wrote: > > >>hello everybody, >>how can i just get 1 character ? i`ve done a search but just found >>getch() for windows, i need same for unix and raw_input has any option >>that is not documented ? >>thanks. >> >> > >Please use Google. > >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892 > > thanks , i found something in http://the.taoofmac.com/static/grimoire.html also works but i thought that there is short way for doing it. -- http://mail.python.org/mailman/listinfo/python-list
need help about time.sleep, timer
hello, i need a function like that, wait 5 seconds: (during wait) do the function but function waits for keyboard input so if you dont enter any it waits forever. i tried time.sleep() but when i used time.sleep in while, the function in while never executed. then i found something about Timer but couldnt realize any algorithm in my mind. i`ll use the function like remote controller. as you know in remote controllers, tv waits you for second number input. if you dont press any, executes the first number that you have entered. thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: need help about time.sleep, timer
Dennis Lee Bieber wrote: >On Fri, 18 Nov 2005 22:45:37 -0500, Peter Hansen <[EMAIL PROTECTED]> >declaimed the following in comp.lang.python: > > > >>It's quite unclear whether the last part, above, is one of your >>*requirements*, or a description of a problem you are having with your >>current approach. Do you *want* it to wait forever if you don't enter >>anthing? >> >> >> > As I understand it, he (?) wants to accumulate characters to be >passed to a certain function -- but the function is not to be invoked >until after a time period has expired; the time period resetting on each >character entered. > > Something I'd do with threads, queues, and sleep... > >PSEUDOCODE > >thread1: > while not Shutdown: > ch = getChar() > q.put(ch) > > >thread2: #or main > while not Shutdown: > chars = [] > while True: > sleep(max_interval) > if q.empty(): break #no input since start of sleep > while not q.empty():#collect all input from sleep > chars.append(q.get()) > inp = "".join(chars) > function(inp) > > > > > i appreciate your comments and ideas. Dennis told exactly what i tried to say :), code seems to be fine but during sleep action i think the above code does not execute if q.empty(): break #no input since start of sleep while not q.empty(): chars.append(q.get()) i need something, while sleeping, executes the function that waits for input from keyboard. i imagined something like that, i have a queu, it both stores the keys that pressed and pressing times of these keys, then i`ll proccess these times. here is scenario input : 5 after 10 seconds later input 5 is being proccessed return back to main function input : 1 after 5 seconds , other input 5 after 5 more seconds , 15 is being proccessed Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: termios.tcgetattr(fd) error: (22, 'Invalid argument')
Petr Jakes wrote: >To provide some feedback: >As Grant Edwards posted in this list, I was running my code inside of >IDE that replaces sys.stdin with some other. While running the program >from a shell prompt, everything goes fine. >Petr Jakes > > > have you tried it with root account ? -- http://mail.python.org/mailman/listinfo/python-list
Re: need help about time.sleep, timer
Bengt Richter wrote: >On Mon, 21 Nov 2005 10:35:20 +0200, Sinan Nalkaya <[EMAIL PROTECTED]> wrote: > > > >>Dennis Lee Bieber wrote: >> >> >> >>>On Fri, 18 Nov 2005 22:45:37 -0500, Peter Hansen <[EMAIL PROTECTED]> >>>declaimed the following in comp.lang.python: >>> >>> >>> >>> >>> >>>>It's quite unclear whether the last part, above, is one of your >>>>*requirements*, or a description of a problem you are having with your >>>>current approach. Do you *want* it to wait forever if you don't enter >>>>anthing? >>>> >>>> >>>> >>>> >>>> >>> As I understand it, he (?) wants to accumulate characters to be >>>passed to a certain function -- but the function is not to be invoked >>>until after a time period has expired; the time period resetting on each >>>character entered. >>> >>> Something I'd do with threads, queues, and sleep... >>> >>>PSEUDOCODE >>> >>>thread1: >>> while not Shutdown: >>> ch = getChar() >>> q.put(ch) >>> >>> >>>thread2: #or main >>> while not Shutdown: >>> chars = [] >>> while True: >>> sleep(max_interval) >>> if q.empty(): break #no input since start of sleep >>> while not q.empty():#collect all input from sleep >>> chars.append(q.get()) >>> inp = "".join(chars) >>> function(inp) >>> >>> >>> >>> >>> >>> >>> >>i appreciate your comments and ideas. Dennis told exactly what i tried >>to say :), code seems to be fine but during sleep action i think the >>above code does not execute >> >>if q.empty(): break #no input since start of sleep >> while not q.empty(): >> chars.append(q.get()) >> >>i need something, while sleeping, executes the function that waits for >>input from keyboard. >>i imagined something like that, i have a queu, it both stores the keys >>that pressed and pressing times of these keys, then i`ll proccess these >>times. here is scenario >>input : 5 >>after 10 seconds later input 5 is being proccessed >>return back to main function >>input : 1 >>after 5 seconds , other input 5 >>after 5 more seconds , 15 is being proccessed >>Thanks. >> >> > >If I understand, you really don't want to sleep, you want to wait a max time >of 5 seconds >for a character. You can get that from a queue.get(True,5) hence, you could >try the >following as a start (untested, and I don't have much experience with python >threading, >so will wait for bug reports ;-) > >Note that it uses getch for input, which doesn't echo. (Change to getche if >you want echo) >You can run this from the command line with one arg: the number of seconds you >want to >have the test continue. At the end of that time it will set the Shutdown >event, and >thread2 should empty the queue and wait 5 seconds and then do its last >function call and >see the shutdown event. > >< tqinp.py >>--- ># tqinp.py -- test queued input of unechoed character input until a 5-second >delay >import threading >import Queue >import msvcrt >queue = Queue.Queue(10) # 2 is prob enough for this thing >Shutdown = threading.Event() > >def getChar(): return msvcrt.getch() # blocks >def function(s): print 'function(%r)'%s > >def thread1(q): >while not Shutdown.isSet(): >ch = getChar() >q.put(ch) > >def thread2(q): #or main >while not Shutdown.isSet(): >chars = '' >try: >while True: chars += q.get(True, 5) >except Queue.Empty, e: >print 'No input for 5 seconds. Using %r'%chars >function(chars) > >import time >def test(trial_time): >thr1 = threading.Thread(target=thread1, args=(queue,)) >thr1.start() >thr2 = threading.Thread(target=thread2, args=(queue,)) >thr2.start() >t0 = time.clock() >time.sleep(trial_time) >print 'Ending trial after %s seconds' % (time.clock()-t0) >Shutdown.set() > >if __name__ == '__main__':
re and escape character
i re-format incoming messages like this, command = re.findall("^\002(.{2})\|.*\003$", response)[0] it works well but when response comes with escape characters , my command variable crashes, i cannot parse if response variable is like , response = '\002AB|TIasdasdasd asdasdasd xzczxc qwewer werwer|\003' ps:there must be \002 at the start and \003 at the end. thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: re and escape character
Thomas Guettler wrote: >Am Thu, 15 Sep 2005 14:36:38 +0300 schrieb Sinan Nalkaya: > > > >>i re-format incoming messages like this, >>command = re.findall("^\002(.{2})\|.*\003$", response)[0] >>it works well but when response comes with escape characters , my >>command variable crashes, >>i cannot parse if response variable is like , >>response = '\002AB|TIasdasdasd >>asdasdasd >>xzczxc >>qwewer >>werwer|\003' >> >>ps:there must be \002 at the start and \003 at the end. >>thanks. >> >> > >Hi, > >I don't know what you mean with "escape characters". >The dot does not match a newline. You have to use the >re.DOTALL option if you want this. > > HTH, > Thomas > > > thats exactly what i want, how can i use DOTALL, by doing re.compile ? thanks -- http://mail.python.org/mailman/listinfo/python-list
make a video from xwd output
hi i want to write a program that makes a video of my desktop, i think that can be via return or output xwd functions in X11 lib then through to the mpeg video encoding codes, hmm is there an easier solution to this via python? thanks for your attention. -- http://mail.python.org/mailman/listinfo/python-list
Re: make a video from xwd output
On Monday 12 December 2005 03:34 pm, Fredrik Lundh wrote: > Sinan Nalkaya wrote: > > hi i want to write a program that makes a video of my desktop, i think > > that can be via return or output xwd functions in X11 lib then through to > > the mpeg video encoding codes, hmm is there an easier solution to this > > via python? > > http://www.unixuser.org/~euske/vnc2swf/ > > ? > > i didnt try that but it seems ,just makes swf to me. thanks. -- http://mail.python.org/mailman/listinfo/python-list
popen and password entry
hello, i want to use rsync for remote file transfer via popen, but couldnt pass the Password yet. here`s what i did cmd = 'rsync -av config [EMAIL PROTECTED]:/tmp/.' f = os.popen(cmd,'w') f.write('1234') #not worked f.write('1234\n') #not worked every time i see "Password:" line, then i tried popen2 st_out, st_in = popen2.popen2(cmd) st_in.write('1234') #not worked st_in.write('1234\n') #not worked again i got bored to see "Password:" line every time and did st_out.close() to not to see stdout messages from rsync, but even this did not work. also i tried popen3() function same way. what should i do? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
popen and password entry
hello, i want to use rsync for remote file transfer via popen, but couldnt pass the Password yet. here`s what i did cmd = 'rsync -av config [EMAIL PROTECTED]:/tmp/.' f = os.popen(cmd,'w') f.write('1234') #not worked f.write('1234\n') #not worked every time i see "Password:" line, then i tried popen2 st_out, st_in = popen2.popen2(cmd) st_in.write('1234') #not worked st_in.write('1234\n') #not worked again i got bored to see "Password:" line every time and did st_out.close() to not to see stdout messages from rsync, but even this did not work. also i tried popen3() function same way. what should i do? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: popen and password entry
hi,i have found expect method for this purpose. i`m trying to use pexpect but following code gives me an something strange as a result.# The CODEimport pexpectcmd = '/usr/bin/rsync config [EMAIL PROTECTED]:/tmp/.' #cmd = 'ssh [EMAIL PROTECTED]'child = pexpect.spawn(cmd)passwd = 'qwe123'try: i = child.expect(['Password:','Password: ',pexpect.EOF,pexpect.TIMEOUT]) if i == 0: child.sendline(passwd) elif i == 1: print 1 elif i == 2: print 2 elif i == 3: print 3except EOF: print 'EOF'except TIMEOUT: print 'TIMEOUT'print 'finished' # The resultfinishedException pexpect.ExceptionPexpect: in > ignored -- http://mail.python.org/mailman/listinfo/python-list
Re: popen and password entry
thanks for reply, i add the line you suggested, thats what i get [EMAIL PROTECTED]:~/tmp/multi_server$ python deneme.py Password: qwe123 finished Exception pexpect.ExceptionPexpect: in > ignored does rsync may cause a problem while trying to fork-exec ssh ? > Add "child.logfile = sys.stdout" here and check what's going on. > > Ganesan > > -- > Ganesan Rajagopal -- http://mail.python.org/mailman/listinfo/python-list
Re: popen and password entry
i put while True: before top of line, i=child.expect() . it worked, the file has gone but also it goes into loop with many EOF result, i tried the os.waitpid() function with child.pid but didnt help me. still couldn`t get the problem. thanks for help On Thursday 15 June 2006 12:04, Ganesan Rajagopal wrote: > Ah, got it. You didn't wait for the rsync process to complete. Put the body > of the "try:" in a while loop. > > Ganesan > > -- > Ganesan Rajagopal -- http://mail.python.org/mailman/listinfo/python-list
Re: popen and password entry
finally following code works, import pexpect, sys cmd = '/usr/bin/rsync config [EMAIL PROTECTED]:/tmp/.' #cmd = 'ssh [EMAIL PROTECTED]' child = pexpect.spawn(cmd) child.logfile = sys.stdout passwd = 'qwe123' i = 0 try: while i == 0: i = child.expect(['Password:','Password: ',pexpect.EOF,pexpect.TIMEOUT]) if i == 0: child.sendline(passwd) elif i == 1:print 1 elif i == 2:print 2 elif i == 3:print 3 except EOF: print 'EOF' except TIMEOUT: print 'TIMEOUT' -- http://mail.python.org/mailman/listinfo/python-list
about spawn flag
hi, i am using os.spawn function, it works well but i need a flag that allows function return the process id with exit/error code, is there any or how can i do it, i can replace spawn with fork/exec if necessary. thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: about spawn flag
thank you but also i need a pid.also react like an os.P_NOWAIT. if i summarize, child proccess immediately returns the pid, if child exits also returns the exit/error code :) -- http://mail.python.org/mailman/listinfo/python-list
pop line from file
hello all, i searched and google long long time but couldnt find any result, i want pop the first line from file, i dont want to read all file contents because file is being updated from another proccess. even i couldnt realize its algorithm, thanks for any suggestion -- http://mail.python.org/mailman/listinfo/python-list
Re: pop line from file
i am unix platform, now searching for the mkfifo topics. thank you all. -- http://mail.python.org/mailman/listinfo/python-list