Implementing CURL command using libcurl in C/C++

2019-12-13 Thread Karthik Sharma
The `CURL` command that I am using is shown below. curl -F 'file=@/home/karthik/Workspace/downloadfile.out' http://127.0.0.1:5000/file-upload --verbose The response from the server is shown below. * Trying 127.0.0.1... * Connected to 127.0.0.1 (127.0.0.1) por

Transfer a file to httpserver via POST command from curl

2019-12-12 Thread Karthik Sharma
27;message' : 'Allowed file types are txt, pdf, png, jpg, jpeg, gif'}) resp.status_code = 400 return resp if __name__ == "__main__": app.run() I am doing a POST using curl as follows. curl -X POST --data-binary @/home/user/testfile.txt http:// 127.0.0.1:5000/file-u

How to implement semaphores in python?

2016-06-07 Thread karthik jagilinki
Hello All, I need some help with semaphore implementation between two programs in python. I'd be glad if anyone can give me some help. -- https://mail.python.org/mailman/listinfo/python-list

Re: GAPI -- Sharing a post to Social Networking Pages from my App

2016-03-22 Thread Karthik Reddy
On Wednesday, March 23, 2016 at 9:43:21 AM UTC+5:30, Karthik Reddy wrote: > On Tuesday, March 22, 2016 at 4:48:37 PM UTC+5:30, Steven D'Aprano wrote: > > On Tue, 22 Mar 2016 09:37 pm, Karthik Reddy wrote: > > > > > The error I am getting is "Uncaught R

Re: GAPI -- Sharing a post to Social Networking Pages from my App

2016-03-22 Thread Karthik Reddy
On Tuesday, March 22, 2016 at 4:48:37 PM UTC+5:30, Steven D'Aprano wrote: > On Tue, 22 Mar 2016 09:37 pm, Karthik Reddy wrote: > > > The error I am getting is "Uncaught ReferenceError: gapi is not defined" > > > Have you tried googling for it? T

Re: GAPI -- Sharing a post to Social Networking Pages from my App

2016-03-22 Thread Karthik Reddy
On Tuesday, March 22, 2016 at 4:55:40 PM UTC+5:30, Karthik Reddy wrote: > On Tuesday, March 22, 2016 at 4:48:37 PM UTC+5:30, Steven D'Aprano wrote: > > On Tue, 22 Mar 2016 09:37 pm, Karthik Reddy wrote: > > > > > The error I am getting is "Uncaught R

Re: GAPI -- Sharing a post to Social Networking Pages from my App

2016-03-22 Thread Karthik Reddy
On Tuesday, March 22, 2016 at 4:48:37 PM UTC+5:30, Steven D'Aprano wrote: > On Tue, 22 Mar 2016 09:37 pm, Karthik Reddy wrote: > > > The error I am getting is "Uncaught ReferenceError: gapi is not defined" > > > Have you tried googling for it? T

Re: GAPI -- Sharing a post to Social Networking Pages from my App

2016-03-22 Thread Karthik Reddy
On Tuesday, March 22, 2016 at 9:54:53 AM UTC+5:30, Mark Lawrence wrote: > On 22/03/2016 04:14, Karthik Reddy wrote: > > Hi Experts, > > > > I am trying to post on facebook and google plus page from my application. > > I am using facebook-sdk an d I am able to post u

Re: GAPI -- Sharing a post to Social Networking Pages from my App

2016-03-22 Thread Karthik Reddy
On Tuesday, March 22, 2016 at 9:54:53 AM UTC+5:30, Mark Lawrence wrote: > On 22/03/2016 04:14, Karthik Reddy wrote: > > Hi Experts, > > > > I am trying to post on facebook and google plus page from my application. > > I am using facebook-sdk an d I am able to post u

GAPI -- Sharing a post to Social Networking Pages from my App

2016-03-21 Thread Karthik Reddy
Hi Experts, I am trying to post on facebook and google plus page from my application. I am using facebook-sdk an d I am able to post using local machine but I am not able to post from dev server. Can Anyone Please help me on this. Thanks, Karthik -- https://mail.python.org/mailman

Plotting a timeseris graph from pandas dataframe using matplotlib

2015-11-19 Thread Karthik Sharma
I have the following data in a csv file SourceIDBSs hour Type 7208 87 11MAIN 11060 67 11MAIN 3737 88 11MAIN 9683 69 11MAIN 9276 88 11MAIN 7754 62 11MAI

Plotting timeseries from a csv file using matplotlib

2015-11-12 Thread Karthik Sharma
I have some csv data in the following format. Ln Dr Tag Lab 0:01 0:02 0:03 0:04 0:05 0:06 0:07 0:08 0:09 L0 St vT 4R 0 0 00 0 0 00 0 L2 Tx st 4R

Re: Decoding JSON file using python

2015-05-27 Thread Karthik Sharma
x27;message {} \n\n'.format(message['Message'])) I get the following error. Traceback (most recent call last): File "test_json.py", line 23, in print('message {} \n\n'.format(message['Message'])) TypeError: list indices must be intege

Decoding JSON file using python

2015-05-27 Thread Karthik Sharma
I have the JSON structure shown below and the python code shown below to manipulate the JSON structure. import json json_input = { "msgType": "0", "tid": "1", "data": "[{\"Severity\":\"warn\",\"Subject\":\"Reporting \",\"Message\":\"tdetails:{\\\"Product\\\"

Error in processing JSON files in Python

2015-03-30 Thread Karthik Sharma
I have the following python program to read a set of JSON files do some processing on it and dump them back to the same folder. However When I run the below program and then try to see the output of the JSON file using `cat file.json | python -m json.tool` I get the following error `extra data

Python JSON processing - extra data error

2015-03-30 Thread karthik . sharma
I have the following python program to read a set of JSON files do some processing on it and dump them back to the same folder. However When I run the below program and then try to see the output of the JSON file using `cat file.json | python -m json.tool` I get the following error `extra dat

Re: Beginner

2014-11-20 Thread Karthik Reddy
Now Its working Thanks a lot Steven -- https://mail.python.org/mailman/listinfo/python-list

Beginner

2014-11-19 Thread Karthik Reddy
Hi all I am python beginner I am trying the below code and getting incorrect syntax in python (3.3.2) number = 23 running = True while running: guess = int(raw_input('Enter an integer : ')) if guess == number: print ("Congratulations, you guessed it.") running = False # this causes the while lo

ZMQError: Resource temporarily unavailable

2014-10-08 Thread karthik . sharma
I am using zero-mq for IPC between two machines. My zmq function is given below def recieve_messages(self): string = self.sub_socket.recv(flags=zmq.NOBLOCK) print('flow mod messages recieved {}'.format(string)) When I run the program however I get the following err

Re: python

2014-02-26 Thread Karthik Reddy
On Monday, February 24, 2014 2:01:11 PM UTC+5:30, Karthik Reddy wrote: > I worked as a weblogic administrator and now i am changing to development and > i am very much interested in python . please suggest me what are the > things i need to learn more rather than python to g

Re: python

2014-02-25 Thread Karthik Reddy
.. On Tuesday, February 25, 2014 12:58:15 AM UTC+5:30, CM wrote: > On Monday, February 24, 2014 3:31:11 AM UTC-5, Karthik Reddy wrote: > > > I worked as a weblogic administrator and now i am changing to development > > and i am very much interested in python .

python

2014-02-24 Thread Karthik Reddy
I worked as a weblogic administrator and now i am changing to development and i am very much interested in python . please suggest me what are the things i need to learn more rather than python to get an I.T job. I came to know about Django but i am in a confusion please help me ..

Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:37:09 UTC-8, Roy Smith wrote: > In article <8445e47e-7efe-4f37-9b40-db2896d58...@googlegroups.com>, > > Bhanu Karthik wrote: > > > > > data = sock.recv(RECV_BUFFER) > > >

Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:23:08 UTC-8, Chris Angelico wrote: > On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik > > wrote: > > > data = sock.recv(RECV_BUFFER) > > > username = str(sock.getpeername()) > > >

Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:23:08 UTC-8, Chris Angelico wrote: > On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik > > wrote: > > > data = sock.recv(RECV_BUFFER) > > > username = str(sock.getpeername()) > > >

stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
data = sock.recv(RECV_BUFFER) username = str(sock.getpeername()) username = usernames[username] if command == "/quit": print data sock.send("bye"

Re: select.select()

2013-11-22 Thread Bhanu Karthik
On Friday, 22 November 2013 18:15:10 UTC-8, Roy Smith wrote: > In article , > > Bhanu Karthik wrote: > > > > > please help me.. what does the following line do? > > > > > > read_sockets,write_sockets,error_sockets = > > > select.select

Re: select.select()

2013-11-22 Thread Bhanu Karthik
On Friday, 22 November 2013 18:29:12 UTC-8, Steven D'Aprano wrote: > On Fri, 22 Nov 2013 17:42:07 -0800, Bhanu Karthik wrote: > > > > > please help me.. what does the following line do? > > > > > > read_sockets,write_sockets,error_socke

select.select()

2013-11-22 Thread Bhanu Karthik
please help me.. what does the following line do? read_sockets,write_sockets,error_sockets = select.select(CONNECTION_LIST,[],[]) -- https://mail.python.org/mailman/listinfo/python-list

How to parse the starting and ending of a loop statements in python

2013-07-30 Thread karthik sridhar
My objective is to find the line numbers of the start and the end of a loop statement in python. Example scenario #A.py Line1: a=0 Line2: while a<5: Line3:print a Line4:a=a+1 Desired output: Start of a loop Line2 End of a loop Line4 Current p

query from sqlalchemy returns AttributeError: 'NoneType' object

2013-05-02 Thread karthik . sharma
s Linux-3.5.0-23-generic-x86_64-with-Ubuntu-12.04-precise INFO:core:POX 0.1.0 (betta) is up. DEBUG:openflow.of_01:Listening on 0.0.0.0:6633 INFO:openflow.of_01:[00-00-00-00-00-02 1] connected DEBUG:tutorial:Controlling [00-00-00-00-00-02 1] got info from the database ERROR:c

RE : Gnuplot

2013-04-04 Thread Murugesan, Karthik
Hello, I am having a few issues interfacing gnuplot with python. When I try to run the demo.py file I get the following error messages: Traceback (most recent call last): File "C:\Program Files\Common Files\dSPACE\Python25\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310

Re: Packing a ctypes struct containing bitfields.

2009-06-18 Thread Karthik
On Jun 18, 6:29 pm, Nick Craig-Wood wrote: > Karthik wrote: > >  Hello Everybody, > > >  I'm trying to create a packed structure in ctypes (with one 64-bit > >  element that is bitfielded to 48 bits), > >  unsuccessfully: > > > ===

Packing a ctypes struct containing bitfields.

2009-06-18 Thread Karthik
struct foo { unsigned long long bar: 48; }; printf("sizeof(foo) = %d", sizeof(foo)); === So... what am I doing wrong? Thanks, Karthik. -- http://mail.python.org/mailman/listinfo/python-list

SSL Server side Client Certficate Verification in M2Crypto

2009-04-27 Thread Karthik
SWIG 1.33. The M2Crypto I am using is 0.18. I am also using my own CA to sign the certificates. The CA certificates are available with both the server and the client. Please let me know if you require additional information on this. Thanks Karthik import select import socket import sys import

Re: Subprocess module: running an interactive shell

2009-03-14 Thread Karthik Gurusamy
On Mar 14, 3:03 am, Roman Medina-Heigl Hernandez wrote: > Karthik Gurusamy escribió: > > > > > On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez > > wrote: > >> Hi, > > >> I'm experimenting with Python and I need a little help with this. Wh

Re: Subprocess module: running an interactive shell

2009-03-13 Thread Karthik Gurusamy
> Why and how to fix it? Would you suggest a better and more elegant way to > do what I want? As I see it, 'sh' is attempting to read from the keyboard and not from stdin. Karthik > > Thank you. > > -- > > Saludos, > -Roman > > PGP Fingerprint: > 09BB EFCD 21ED 4E79 25FB  29E1 E47F 8A7D EAD5 6742 > [Key ID: 0xEAD56742. Available at KeyServ] -- http://mail.python.org/mailman/listinfo/python-list

Re: Can read() be non-blocking?

2008-11-06 Thread Karthik Gurusamy
uot;" This signal stuff may not work in non unix env """ raise Exception("timeout") signal.signal(signal.SIGALRM, alarm_handler) try: signal.alarm(timeout) # say timeout=60 for a max wait of 1 minute data = proc.stdout.read() except Exception, e

Re: Output of pexpect

2008-09-30 Thread Karthik Gurusamy
d = fout I am not very sure if you can do the logging to two different files at the same time (ie sys.stdout as well as another file-object). I guess that's your question. The above should give you a starting point to explore. [May be give a fake file like object and intercept the write/ flush calls?] Karthik > > Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple processes, private working directories

2008-09-24 Thread Karthik Gurusamy
= cmds['cwd'] . etc other args) runs.append(run) # Now wait for all the processes to finish for run in runs: run.wait() Note that if any of the processes generate lot of stdout/stderr, you will get a deadlock in the above loop. Then you way want to go for threads or use ru

Newbie Question:Please help

2008-09-08 Thread Karthik Krishnan
Hi, I am a newbie to python and I hope this is not a stupid question. I am trying to run a main method from a Python command line using the command shell using the command. python main_test.py I get the following error. File "", line 1 python main_test.py Syntax Error: invalid syntax My ma

Re: Seeking ideas for a cron implementation

2008-09-06 Thread Karthik Gurusamy
On Aug 22, 1:51 pm, Sean DiZazzo <[EMAIL PROTECTED]> wrote: > On Aug 22, 1:30 pm, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > I'm working on acronlike functionality for my application. > > The outer loops runs continuously wakin

Re: Storing Subprocess Results

2008-09-02 Thread Karthik Gurusamy
Probably commands module is a better choice for your problem: >>> import commands >>> commands.getoutput('fortune') "While money can't buy happiness, it certainly lets you choose your own \nform of misery." >>> Karthik  Any help > is appreciated.  Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Seeking ideas for a cron implementation

2008-08-22 Thread Karthik Gurusamy
eneric Cron_Event. Say how do I know the exact time in future that will satisfy a constraint like: month=11, wday=1, hour=3, min=30# At 3:30 AM on a Tuesday in November Thanks for your thoughts. Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: help with list comprehension

2008-05-01 Thread Karthik Gurusamy
nums= [] >for e in l: > colours.append(e['colour']) > nums.append(e['num']) > > #def m3(): > # colours, nums = [ e['colour'], e['num'] for e in l ] > Looks like m1 is the cleanest; if you really want to run list- comprehension once, one possible way: >>> p = [ (e['colour'], e['num']) for e in l ] >>> import operator >>> map(operator.itemgetter(0), p) ['black', 'brown', 'red', 'orange', 'yellow', 'green', 'blue', 'violet', 'grey', 'white'] >>> map(operator.itemgetter(1), p) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> Karthik > -- > Yves.http://www.SollerS.ca -- http://mail.python.org/mailman/listinfo/python-list

Re: ssh

2008-04-30 Thread Karthik Gurusamy
is being used interactively (such as being prompted from password), look into pexpect module. http://www.noah.org/wiki/Pexpect Else try the subprocess module (or even commands module); these are lot simpler to program than the more primitive os.execv/os.read/write. If you have already setup keys, ssh should work passwordless whether it's interactive or not (AFAIK). Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] annoying dictionary problem, non-existing keys

2008-04-24 Thread Karthik
[EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com Is this an acceptable alternative? try: if conf['key1'] == 'something': except KeyError: pass

Re: Setting default version among multiple python installations

2008-04-09 Thread Karthik
Gabriel Genellina wrote: En Wed, 09 Apr 2008 02:45:28 -0300, Karthik <[EMAIL PROTECTED]> escribió: if i type python2.5 i am able to use the latest python, but if i simply type python it taken me to the older version. (it is a minor annoyance, but I want to know how to fix it)

Re: Setting default version among multiple python installations

2008-04-08 Thread Karthik
Gabriel Genellina wrote: En Tue, 08 Apr 2008 06:48:54 -0300, Karthik <[EMAIL PROTECTED]> escribió: I am an absolute linux and python newbie. The linux machine(red hat version 7.2) that i managed to get my hands on had python 1.5(vintage stuff, i guess) in it. I have installed pyth

Setting default version among multiple python installations

2008-04-08 Thread Karthik
. How do i set python2.5 as the default version? -Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: clocking subprocesses

2008-03-03 Thread Karthik Gurusamy
ime, cstime, elapsed_time) Return a tuple of floating point numbers indicating process times. cutime+cstime will give you the total CPU used by child (your simulation). Karthik > > Thanks for the advice. > > Kevin -- http://mail.python.org/mailman/listinfo/python-list

Re: How to identify which numbers in a list are within each others' range

2008-02-01 Thread Karthik Gurusamy
s[1] == 'L': clique.add(node) if s[1] == 'R': # below is O(k) where k is clique size (overlaps per interval) new_edges = [(node, i) for i in clique if i != node] edges += new_edges clique.remove(node) return

Re: read and readline hanging

2008-01-27 Thread Karthik Gurusamy
dule. It solves the exact problem you have. You can give a r.e. for prompt and it will take care to wait until collecting all output. It basically simulates a human typing to an interpreter. Karthik. > > > Unless there is some way to differentiate between the last line > > and al

Re: finding child cpu usage of a running child

2008-01-26 Thread Karthik Gurusamy
On Jan 25, 11:59 pm, Paddy <[EMAIL PROTECTED]> wrote: > On Jan 26, 5:43 am, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > Wondering if there is a way to measure a child process's cpu usage > > (sys and user) when the child is stil

finding child cpu usage of a running child

2008-01-25 Thread Karthik Gurusamy
is on-demand only when the request is made. Thanks, Karthik -- http://mail.python.org/mailman/listinfo/python-list

RE: Replace stop words (remove words from a string)

2008-01-17 Thread Karthik
How about - for s in stoplist: string.replace(mystr, s, "") Hope this should work. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of BerlinBrown Sent: Thursday, January 17, 2008 1:55 PM To: python-list@python.org Subject: Replace stop words (remov

Re: executing newgrp from python in current shell possible?

2008-01-12 Thread Karthik Gurusamy
tup_design.py, do an exec call[1] to fire the user's shell (note that even if you use popen or other ways of forking a new process, things will work just fine) Whatever changes you made to the process environment will get propagated to the new shell. User must explicitly finish the new shell (say typing 'exit' on shell prompt) Karthik [1]. e.g. import os os.execvp(cmd_run[0], cmd_run) # cmd_run is probably ['/bin/bash'] > > -- > Svenn -- http://mail.python.org/mailman/listinfo/python-list

Re: popen question

2008-01-08 Thread Karthik Gurusamy
e in child:" line in the iterator is the culprit. The iterator does something like a child.readlines() underneath (in it's __iter__ call) instead of a more logical single line read. Change your reading to force line-by-line read e.g. While True: line = child.readline() if not line: break print line Karthik > > Thanks, > > robert -- http://mail.python.org/mailman/listinfo/python-list

Re: pexpect ssh login and ls | grep

2008-01-01 Thread Karthik Gurusamy
d the second pattern. You want to use raw strings. r'\$' or else the re sent down is a plain $ which re interprets as end of buffer. Most important here is your prompt doesn't end with a $ (it's something like [EMAIL PROTECTED] ~]). Thus make it, child.expect(r'.*]')

Re: Understanding tempfile.TemporaryFile

2007-12-28 Thread Karthik Gurusamy
g system uses permission bits to indicate whether a file is executable, the file is executable by no one. The file descriptor is not inherited by children of this process. Caller is responsible for deleting the file when done with it. <--- >>> Karthik > > -- > Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pexpect and a Linux Terminal

2007-12-24 Thread Karthik Gurusamy
t de passe :') > child.sendline(pwd+"\r\n") With sendline no need for the trailing "\r\n". Just do child.sendline(pwd) Here you may want to do something like prompt = '.*#' # assumes your shell prompt for root ends in # child.expect(prompt) > child.sendline(

auto-increment operator - why no syntax error?

2007-12-08 Thread Karthik Gurusamy
t silently accepted the expression and it took me a while to debug the problem. Why are the following accepted even without a warning about syntax error? (I would expect the python grammar should catch these kind of syntax errors) >>> n = 1 >>> 2 * + n 2 >>> n +=

Re: simple question on dictionary usage

2007-10-26 Thread Karthik Gurusamy
;E3': '1163'} > > This should be pretty easy, but somehow with all my googling I've > not found a hint. One possible solution (read list-comprehension if you not familiar with it): >>> record={'BAT': '14.4', 'USD': '24', 'DIF': '45', 'OAT': '16', ... 'FF': '3.9', 'C3': '343', 'E4': '1157', 'C1': '339', ... 'E6': '1182', 'RPM': '996', 'C6': '311', 'C5': '300', ... 'C4': '349', 'CLD': '0', 'E5': '1148', 'C2': '329', ... 'MAP': '15', 'OIL': '167', 'HP': '19', 'E1': '1137', ... 'MARK': '', 'E3': '1163', 'TIME': '15:43:54', ... 'E2': '1169'} >>> egt = dict([(k, record[k]) for k in record if k.startswith('E')]) >>> egt {'E5': '1148', 'E4': '1157', 'E6': '1182', 'E1': '1137', 'E3': '1163', 'E2': '1169'} Karthik > > Thanks in advance > > -- > Frank Stutzman -- http://mail.python.org/mailman/listinfo/python-list

Re: Easiest way to get exit code from os.popen()?

2007-10-24 Thread Karthik Gurusamy
exit code; second gives signal info if any >>> In any case, the best approach is to use the os module to interpret it as given in other post (os.WEXITSTATUS(1280)) Karthik > > Thanks, > --Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: negative base raised to fractional exponent

2007-10-16 Thread Karthik Gurusamy
;>> 2.0577473119894969j ** 2 (-4.234324+0j) >>> Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: matching a street address with regular expressions

2007-10-10 Thread Karthik Gurusamy
e like 3120 De la Cruz Boulevard. Any > > > hints? > > Also, that pattern can be easily modified to have any number of words > at the end: > patt = "\d+ (\w+){1,}" > This would take care of 3120 De la Cruz Boulevard. \w doesn't take care of white-space. Following will work. patt = r"\d+ (\w+\s*){1,}" BTW {1,} is same as +. So patt = r"\d+ (\w+\s*)+" will work as well. Note that using raw-string for re pattern is safer in most uses. Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: A question about subprocess

2007-10-03 Thread Karthik Gurusamy
y A ssh machine-B run_jobs.py B ssh machine-B run_jobs.py C ... You may want to fire all these at once so that they all execute in parallel. Karthik > > Thanks, > > JD -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about 'positive lookbehind assertion'

2007-09-25 Thread Karthik Gurusamy
>>> m2 = r.search('bcdefff') > >>> m2 == None > True > > So, it matches 'def' but only if it is immediately preceded by 'abc'. Any idea what this positive lookbehind achieves which can't be done without it. I remember cases where posit

Re: subprocess -popen - reading stdout from child - hangs

2007-09-24 Thread Karthik Gurusamy
On Sep 24, 2:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Sep 23, 2:58 am, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > > > On Sep 22, 8:28 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > wrote: > > > > Let's s

Re: shutil.copy2 error

2007-09-24 Thread Karthik Gurusamy
other process, while you are looping here copying one-by-one the files. So a file 'x' could be present at the time you enter loop, but gone by the time you try the shutil.copy2. Again this is just a guess... Yet another possibility is 'x' is not a r

Re: subprocess -popen - reading stdout from child - hangs

2007-09-23 Thread Karthik Gurusamy
> >>> proc.stdout.read() > > But it just hangs at read() > > proc.communicate() also just hangs. What am I doing wrong? Please > advise. Since your loop.py is still alive and hasn't closed its stdout, the caller continues to wait for EOF (it doesn't know if loop.py is done generating all its output) Karthik > > Thanks, > > Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Sets in Python

2007-09-19 Thread Karthik Gurusamy
On Sep 19, 7:17 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 19 Sep 2007 20:58:03 +, Karthik Gurusamy wrote: > > While it's easy to explain the behavior, I think the decision to dis- > > allow mutable items as keys is a bit

Re: Sets in Python

2007-09-19 Thread Karthik Gurusamy
On Sep 19, 3:06 pm, Paddy <[EMAIL PROTECTED]> wrote: > On Sep 19, 9:58 pm, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > > > Since we know hashing is used, all that is needed is, a well-defined > > way to construct a hash out of a mutable. "Given a sequence, ho

Re: Sets in Python

2007-09-19 Thread Karthik Gurusamy
line's a?.. so why not allow similar behavior with lists/other sequence/even other collections. As long as two objects compare equal the hash-result must be the same. I guess this takes us to defining the equality operation for lists-- which I think has a very obvious definition (i

Re: Removing objects in a list via a wild card

2007-09-19 Thread Karthik Gurusamy
gt; > You can also use fnmatch: > > from fnmatch import fnmatch > files = [file for file in os.listdir(os.getcwd()) if not fnmatch(file, > '*.py') and not fnmatch(file, '*.pyc')] Another option is to use glob. import glob p1 = glob.glob('*.py&#

Re: How can I know how much to read from a subprocess

2007-09-18 Thread Karthik Gurusamy
p session (where the stdin depends on process's prior stdout), the only viable solution is to simulate a human (e.g. pexpect module) Karthik > > Thanks, > Noam -- http://mail.python.org/mailman/listinfo/python-list

Re: How to insert in a string @ a index

2007-09-11 Thread Karthik Gurusamy
Yet another solution using re >>> t1 = 'hello world hello. hello. \nwhy world hello' >>> import re >>> l1 = re.split('hello', t1) >>> l1[0] = 'XYZ' + l1[0] >>> l1[-2] += 'XYZ' >>> 'hello'.joi

Re: concise code (beginner)

2007-09-06 Thread Karthik Gurusamy
On Sep 5, 1:37 pm, James Stroud <[EMAIL PROTECTED]> wrote: > Karthik Gurusamy wrote: > > On Sep 5, 11:17 am, James Stroud <[EMAIL PROTECTED]> wrote: > > >> for i in xrange(number_of_reads): > >>for dev in devs: > >> try: > >>

Re: concise code (beginner)

2007-09-05 Thread Karthik Gurusamy
the devs sequence/ iterator is being modified while iterating. I know it is not defined for interation over dictionary keys. Are they defined for other collections like lists? Karthik > > James > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

How do i record and invert a sound wave in real time using Tkinter, tkSnack and wave modules?

2007-09-04 Thread Karthik
Hi, I want to record a sound wave from a mic and at the same time invert it and play the inverted wave.My code goes as follows, however nothing is written into the E:\inverted.wav file.Thanks in advance for any help. from Tkinter import * root = Tk() import tkSnack tkSnack.initializeSnack(root) t=

Re: how can I find out the process ids with a process name

2007-09-04 Thread Karthik Gurusamy
lot simpler for simple shell like tasks. >>> import commands >>> commands.getoutput("ps -ef | grep emacs | awk '{print $2}'") '21739\n15937\n15287\n5097\n14797\n31777\n8779\n2973\n5413\n13024\n13026' >>> Your script can then use the output as its input. Karthik > Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Chaining programs with pipe

2007-08-21 Thread Karthik Gurusamy
On Aug 21, 8:33 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2007-08-22, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > > > Not sure on non-unix platforms, but in unix like platforms it's best > > to reuse shell's power. > > >>&

Re: Chaining programs with pipe

2007-08-21 Thread Karthik Gurusamy
t; I tie them together? Is there a solution that works equally on all > platforms? Not sure on non-unix platforms, but in unix like platforms it's best to reuse shell's power. >>> import commands >>> commands.getoutput('ls | wc') ' 4

Re: split a string of space separated substrings - elegant solution?

2007-08-01 Thread Karthik Gurusamy
//pexpect.sourceforge.net/pexpect.html But I am surprised to see there is a standard module already doing this (shlex) Karthik > > -- > Helmut Jarausch > > Lehrstuhl fuer Numerische Mathematik > RWTH - Aachen University > D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: a=0100; print a ; 64 how to reverse this?

2007-07-17 Thread Karthik Gurusamy
ing to know we can go from binary to int, the OP wanted the other way. I think it will be a nice enhancement to add to % operator (like %x, something for binary, %b or %t say) or something like a.__bin__ as suggested by the OP. FWIW, gdb has a /t format to print in binary. (gdb) p 100 $28 = 100 (gdb) p /x 100 $29 = 0x64 (gdb) p /t 100 $30 = 1100100 (gdb) --Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: In a dynamic language, why % operator asks user for type info?

2007-07-16 Thread Karthik Gurusamy
On Jul 16, 5:18 pm, Dan Bishop <[EMAIL PROTECTED]> wrote: > On Jul 16, 7:10 pm, Karthik Gurusamy <[EMAIL PROTECTED]> wrote:> Hi, > > > The string format operator, %, provides a functionality similar to the > > snprintf function in C. In C, the function does not

In a dynamic language, why % operator asks user for type info?

2007-07-16 Thread Karthik Gurusamy
efinition is string formatting, the operator should be able to infer how to convert each of the argument into strings. If the above is the case, we could've avoided all those exceptions that happen when a %d is specified but say a string is passed. Thanks, Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: using subprocess for non-terminating command

2007-07-04 Thread Karthik Gurusamy
ng subprocess, instead of os.system because > at anypoint in time, I need access to stdout and stderr of execution. > Using subprocess is good. Just ensure your child stops data generation at some point. For ping, you can use '-c ' or some other application, you can try closing it's stdin (e.g. cat, bc, gdb) Thanks, Karthik > Thanks, > Senthil -- http://mail.python.org/mailman/listinfo/python-list

Re: object references/memory access

2007-07-03 Thread Karthik Gurusamy
. But if the data is large and several processes are involved, I am fairly sure the overhead of context-switching is very significant (not negligible) in the final throughput. Thanks, Karthik > > Regards, > Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: object references/memory access

2007-07-03 Thread Karthik Gurusamy
a, we allow P to run a lot bigger time-slice. Assuming huge file-system buffering, it's very much possible P gets one-go on the CPU and finishes it's job of data generation. Note that all these become invalid, if you have a more than one core and the scheduler can keep both P and C usin

Re: object references/memory access

2007-07-02 Thread Karthik Gurusamy
On Jul 2, 6:32 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Karthik Gurusamy wrote: > > On Jul 2, 3:01 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > >> Karthik Gurusamy wrote: > >>> On Jul 1, 12:38 pm, dlomsak <[EMAIL PROTECTED]> wrote: > >&g

Re: object references/memory access

2007-07-02 Thread Karthik Gurusamy
On Jul 2, 3:01 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Karthik Gurusamy wrote: > > On Jul 1, 12:38 pm, dlomsak <[EMAIL PROTECTED]> wrote: > [...] > > > I have found the stop-and-go between two processes on the same machine > > leads to very poor

Re: object references/memory access

2007-07-02 Thread Karthik Gurusamy
porary file for IPC. This is not as efficient as real shared memory -- but it does avoid the IPC stop-n-go. The producer can generate the multi-mega byte file at one go and inform the consumer. The file-systems have gone thru' decades of performance tuning that this job is done really efficie

multiple python versions of a 3rd party application/libarary

2007-06-25 Thread Karthik Krishnamurthy
hi, I maintain applications/libraries which I upgrade often at a different location. For example if I maintain mercurial at /opt/sfw/mercurial/0.9.3 I have PYTHONPATH set to /opt/sfw/mercurial/0.9.3/lib/python2.4/site-packages. How can I get python to look into python2.4 and python2.4/site-packa

Re: Newbie question regarding string.split()

2007-04-21 Thread Karthik Gurusamy
don't get leading/trailing empty list items. So just add input = input.strip('2') after the input assignment (BTW someone had pointed input is a reserved identifier). Note this solution will work for splitting on any sequence of chars..just strip them first. Note we still get empty element

Re: Compare regular expressions

2007-04-16 Thread Karthik Gurusamy
hts. If you know already R2 >= R1 (that is you precompute and remember), then it's a trivial to skip checking for R1 if R2 turned up negative. You can even arrange all the Rs in a binary tree like fashion and skip checking a whole subtree if the sub-tree's root node gave negative for r.e. match. Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: optparse -- anyway to find if the user entered an option?

2007-04-14 Thread Karthik Gurusamy
On Apr 14, 7:54 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 14 Apr 2007 16:49:22 -0700, Karthik Gurusamy wrote: > > I'm wondering if there is a cleaner approach -- something like > > parser.opt_seen("-i") > > What do dir(parser) a

optparse -- anyway to find if the user entered an option?

2007-04-14 Thread Karthik Gurusamy
er can ever enter a None value, I can be sure that the user didn't provide -i. I'm wondering if there is a cleaner approach -- something like parser.opt_seen("-i") Thanks, Karthik -- http://mail.python.org/mailman/listinfo/python-list

Re: Running long script in the background

2007-02-07 Thread Karthik Gurusamy
a trick. Make your script write it's output unbuffered to a file. Since the file is mounted and available on both the machines.. start reading the file from this main python script (note that you may need a thread to do it, as your script will anyway be stuck waiting for the ssh to complete).

Re: Memory leak in Python

2006-05-09 Thread Karthik Gurusamy
ssing your implementation; but from what you say (peer-to-peer), I feel there is a O(N^2) requirements. Also try experimenting with small N (100 nodes say). Thanks, Karthik > Thanks > > > bruno at modulix wrote: > > [EMAIL PROTECTED] wrote: > > > I have a python code w

  1   2   >