Re: Convert tuples into string

2012-11-25 Thread Smaran Harihar
I was able to solve it using the following loop,

conn=psycopg2.connect(connstr)
cursor=conn.cursor()
cursor.execute("SELECT tablename FROM pg_tables where tablename like '%"+
inp +"%'")
 records = cursor.fetchall()
str=""
for rec in records:
 if str == "":
str="".join(rec)
else:
 m="".join(rec)
str=str+","+m

Thanks,
Smaran

On Sun, Nov 25, 2012 at 7:09 PM, Smaran Harihar wrote:

> Hi Guys,
>
> I am connecting to postgres database and fetching the table names but it
> seems that they are being returned in 
>
> How can I convert them to string?
>
> --
> Thanks & Regards
> Smaran Harihar
>
>


-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Convert tuples into string

2012-11-25 Thread Smaran Harihar
Hi Guys,

I am connecting to postgres database and fetching the table names but it
seems that they are being returned in 

How can I convert them to string?

-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Running a curl command within py script

2012-11-14 Thread Smaran Harihar
Hi Guys,

i found pycurl to execute python curl command but not sure how I can
execute the curl command using the pycurl.

curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' -d
'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp'
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/Quercus_iltisii/external.shp
?

This is the curl command.

-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Zipping files

2012-11-13 Thread Smaran Harihar
Hi Guys,

I am trying to create a script which will zip a bunch of files that I have
obtained using the 'glob'

So I have a bunch of files,

glob.glob("shp/file1*)

And I want to zip all the files which are returned by the above command.
How can I do that? Is there a zip library in python?

-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Read number of CSV files

2012-11-12 Thread Smaran Harihar
Oh that is great.

[apology on sending the mail directly]

Thanks,
Smaran

On Mon, Nov 12, 2012 at 10:50 AM, Peter Otten <__pete...@web.de> wrote:

> Peter Otten wrote:
>
> [please don't email me directly]
>
> > How is using glob different from os.listdir() Peter?
>
> glob retains the path and allows you to filter the files. Compare:
>
> >>> import os, glob
> >>> os.listdir("alpha")
> ['one.py', 'two.py', 'one.txt', 'three.py', 'three.txt', 'two.txt']
> >>> glob.glob("alpha/*")
> ['alpha/one.py', 'alpha/two.py', 'alpha/one.txt', 'alpha/three.py',
> 'alpha/three.txt', 'alpha/two.txt']
> >>> glob.glob("alpha/*.py")
> ['alpha/one.py', 'alpha/two.py', 'alpha/three.py']
>
> See the documentation for more.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Invalid syntax

2012-11-07 Thread Smaran Harihar
Thanks a lot guys. Seriously when u get stuck on such issues it really
drives u nuts and that is when this awesome comes to the rescue.

This python mailing list rocks.

On Wed, Nov 7, 2012 at 4:31 PM, Roy Smith  wrote:

> In article ,
>  Demian Brecht  wrote:
>
> > On 2012-11-07, at 3:17 PM, Smaran Harihar 
> wrote:
> > > Any idea where am I going wrong?
> >
> > Looks like you're missing a closing parenthesis:
>
> What I find is useful in situations like this is to just let emacs
> auto-indent the code.  When it starts indenting (or coloring)
> differently than I would have expected, that's a clue that I've messed
> up some punctuation somewhere.
>
> This doesn't only work in emacs.  Vim, eclipse, etc, all have similar
> syntax-coloring and auto-indenting features.  The same idea works with
> any of them.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Invalid syntax

2012-11-07 Thread Smaran Harihar
Hi guys,

I am stuck in one of those non identifiable error location in the code. The
code keeps giving invalid syntax. This is my code<http://dpaste.com/826792/>
.

I am using the same code for another code and not sure why this is not
working. This is the traceback <http://dpaste.com/826793/> that I am
getting.

Any idea where am I going wrong?

-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Read number of CSV files

2012-11-07 Thread Smaran Harihar
Hi Guys,

I am able to read through a CSV File and fetch the data inside the CSV file
but I have a really big list of CSV files and I wish to do the same
particular code in all the CSV files.

Is there some way that I can loops through all these files, which are in a
single folder, and get my code to read the files?

-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unable to execute the script

2012-08-10 Thread Smaran Harihar
Hi Tim,

this is the output for the ls -lsF filename

8 -rwxr-xr-x 1 root root 5227 Jul 30 13:54 iplantgeo_cgi.py*

On Fri, Aug 10, 2012 at 12:20 PM, Tim Chase
wrote:

> On 08/10/12 14:14, Smaran Harihar wrote:
> > If you mean chmod +x 
> >
> > then yes it has been set.
>
> I'm not sure how Ubuntu defaults if you don't specify *who* should
> receive those +x permissions.  I'd make sure they've been set for
> everybody:
>
>   $ chmod ugo+x myfile.py
>
> You can check this by doing an "ls -lsF myfile.py" and you should
> see 3 "x"s in the permission column, something like
>
>
>  123 rwxr-xr-x 1 smaran smaran 31415 Apr 27 2012 myfile.py
>^  ^  ^
>
> If those are set properly, then Dave's suggestions are the next to try.
>
> -tkc
>
>
>
>


-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unable to execute the script

2012-08-10 Thread Smaran Harihar
The file is on Ubuntu Server 12.04 and not sure how to set the executable
bits?

If you mean chmod +x 

then yes it has been set.

On Fri, Aug 10, 2012 at 12:10 PM, Tim Chase
wrote:

> On 08/10/12 13:38, Dave Angel wrote:
> > On 08/10/2012 01:14 PM, Smaran Harihar wrote:
> >> Hi,
> >>
> >> I have set executable permissions for my py script (cgi-script) but for
> >> some reason rather than executing it, the browser simply downloads the
> py
> >> script.
> >>
> >> Here is the link<
> http://128.196.142.94/geo/iplantgeo_cgi.py?get=env&from=latlon&lat=42,45,54&lon=-123,-65,-100
> >.
> >> Before it was working on another server. I migrated it to this new
> domain
> >> and it is having this issue. Where am I going wrong?
> >>
> >>
> > Lots of possibilities, though I can't think of any relating to Python.
> > So I didn't try to read your source file.
> >
> > Is the location of this script acceptable to your web host?  Some hosts
> > deliberately restrict scripts to be in certain places (like /cgi-bin) in
> > order to thwart a certain type of cracker.
> >
> > Next question, is the python installation actually at the place where
> > your shebang points?
>
> And, if the file is on a *nix-like machine (Linux, BSD, Mac,
> Solaris, etc), have the executable bits been set?
>
> -tkc
>
>
>
>


-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trying to create simple py script

2012-08-10 Thread Smaran Harihar
Sorry forgot to update. I did change the port to 8000 and now server is
running but I am getting a 404 page.

http://128.196.142.94:8000/bottle/hello.py

I have the server up right now you can see.

Thanks,
Smaran

On Fri, Aug 10, 2012 at 11:35 AM, Smaran Harihar
wrote:

> Hi Lutz,
>
> Sorry forgot to update. I did change the port to 8000 and now server is
> running but I am getting a 404 page.
>
> http://128.196.142.94:8000/bottle/hello.py
>
> I have the server up right now you can see.
>
> Thanks,
> Smaran
>
>
> On Fri, Aug 10, 2012 at 11:28 AM, Lutz Horn  wrote:
>
>> Hi,
>>
>> Am 10.08.2012 um 19:10 schrieb Smaran Harihar:
>> > python hello.py but I got this traceback error.
>>
>> Use a different port in this line:
>>
>> > run(host='localhost', port=8080)
>>
>> For example 8090 or 8081 or …
>>
>> Lutz
>
>
>
>
> --
> Thanks & Regards
> Smaran Harihar
>
>


-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


trying to create simple py script

2012-08-09 Thread Smaran Harihar
Hi Guys,

I am trying to create a simple cgi-script to receive a Ajax
call, manipulate the string received and send it back as JSON.
Most of the people I have spoken to, seemed to be against using the cgi
script, but most of the documentation and tutorials seem to point to cgi
for AJAX calls. They said, it makes more sense to use django or bottle
which are python web framework.

So I am confused and wanted some guidance as to which should I chose?
Should I go with cgi or django/bottle?

-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: unable to get simple html file up

2012-08-03 Thread Smaran Harihar
guys i m still waiting for a reply

-- Forwarded message --
From: Smaran Harihar 
Date: Thu, Aug 2, 2012 at 12:26 PM
Subject: unable to get simple html file up
To: python-list@python.org


Hi,

I am following this
tutorial<http://pointlessprogramming.wordpress.com/2011/02/13/python-cgi-tutorial-2/>
and
i am not able to get the link.py <http://dpaste.de/wJQ0d/> up and running.
I should be looking at Html file with link directing to the cgi script.

But strangely i can't even see the page itself. Any idea why it is like
this? I have made link.py executable. Here is the
server.py<http://dpaste.de/iEPTk/>
.

-- 
Thanks & Regards
Smaran Harihar




-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


unable to get simple html file up

2012-08-02 Thread Smaran Harihar
Hi,

I am following this
tutorial<http://pointlessprogramming.wordpress.com/2011/02/13/python-cgi-tutorial-2/>
and
i am not able to get the link.py <http://dpaste.de/wJQ0d/> up and running.
I should be looking at Html file with link directing to the cgi script.

But strangely i can't even see the page itself. Any idea why it is like
this? I have made link.py executable. Here is the
server.py<http://dpaste.de/iEPTk/>
.

-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a simple CGI Script

2012-08-02 Thread Smaran Harihar
Thanks a lot Xavier, that was exactly what was needed.

On Thu, Aug 2, 2012 at 11:44 AM, Xavier Combelle wrote:

>  In server.py you made a mistake in the declaration of the cgi directory
> it should be
> handler.cgi_directories = ["/"]
>
>
> Le 02/08/2012 20:20, Smaran Harihar a écrit :
>
> Hi,
>
>  I am trying to create a simple CGI Script and following this 
> tutorials<http://pointlessprogramming.wordpress.com/2011/02/13/python-cgi-tutorial-1/>but
>  unfortunately my output is only printing the cgi file as it is on the
> browser.
>
>  I have already provided the py scripts with the executable functions.
>
>  This is my server.py <http://dpaste.de/iEPTk/> and this is my 
> test_cgi.py<http://dpaste.de/7SsAj/>
>
>  --
> Thanks & Regards
> Smaran Harihar
>
>
>
> This body part will be downloaded on demand.
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Creating a simple CGI Script

2012-08-02 Thread Smaran Harihar
Hi,

I am trying to create a simple CGI Script and following this
tutorials<http://pointlessprogramming.wordpress.com/2011/02/13/python-cgi-tutorial-1/>but
unfortunately my output is only printing the cgi file as it is on the
browser.

I have already provided the py scripts with the executable functions.

This is my server.py <http://dpaste.de/iEPTk/> and this is my
test_cgi.py<http://dpaste.de/7SsAj/>

-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list