A newbie question on ftplib. 
Author Message
 A newbie question on ftplib.

Hello,

When I execute the following statement under Linux it uploads the binary
file properly, but under Windows NT it creates only 512 bytes file at the
ftp server.

ftp.storbinary('STOR ' + xyz, open(xyz), 1024)

I tried various values (1, 128, 256, 515) for the "number of blocks"
parameter.

I am using python 2.0 on both Windows NT (Windows NT 4.0 / SP6a), and on
Linux. (Linux 2.2.x and 2.4.x)

Can I someone help me correcting if I am doing something wrong?

Advance thanks,
--
Hari.



Mon, 15 Sep 2003 19:47:05 GMT  
 A newbie question on ftplib.

Quote:

> When I execute the following statement under Linux it uploads the binary
> file properly, but under Windows NT it creates only 512 bytes file at the
> ftp server.

> ftp.storbinary('STOR ' + xyz, open(xyz), 1024)

> I tried various values (1, 128, 256, 515) for the "number of blocks"
> parameter.

did you try reading from the file?

to make sure you get all data from a binary file, you
need to open it in binary mode.  try this:

    ftp.storbinary('STOR ' + xyz, open(xyz, 'rb'), 1024)

see the "builtin functions" section in the library reference for
more info on open.

Cheers /F



Mon, 15 Sep 2003 19:21:01 GMT  
 A newbie question on ftplib.

Caution, confused braindump follows.

I'm trying to wrap the coils of my puny little mind around XML-RPC,
specifically Kalle Svensson's CGI XML-RPC server:

        http://mail.python.org/pipermail/python-announce-list/2001-March/0006...

(interesting enough, according to Google there seems to be also Jeff's

        http://starship.python.net/crew/jjkunce/python/xmlrpccgi.tgz

advertised as "A XML-RPC "server" that is accessed via a web server
through CGI calls (as opposed to a long-running XML-RPC server that
monitors a dedicated port).", which seems 1) entirely unrelated to 2) much
smaller than Kalle's code 3) designed for Winders).

To reiterate, I'm trying to be able to trap URI's looking like

        http://blah.net:666/cgi/boo.cgi?hiss=aargh#boom

or parameters POSTed via HTML like

<FORM TARGET="result">
<INPUT TYPE=button VALUE="Start search now!" onClick="jsCopyFormData();return (0);">
</FORM>
<FORM name=submitform METHOD=post TARGET="result" ACTION="">
<INPUT TYPE=hidden NAME="smi"     VALUE="">
<INPUT TYPE=hidden NAME="jme"     VALUE="">
<INPUT TYPE=hidden NAME="stype"   VALUE="">
<INPUT TYPE=hidden NAME="sstype"  VALUE="">
<INPUT TYPE=hidden NAME="checkin" VALUE="$cwkey">
<INPUT TYPE=hidden NAME="usr" VALUE="$user">
</FORM>

to some piece of code called boo.cgi, using above arguments as parameters.
Lacking that, I don't mind going the usual route with CGI

import cgi
results=cgi.FieldStorage()
etc.

To make things more difficult, I also might have to process parameters
passed via GET, which current (ick, feh) Perl bit does thusly:

sub get_params {
        if ($ENV{'REQUEST_METHOD'} eq 'GET') {

        } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
                read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});

        } else {
#               &error('request');
        }

                local($name, $value) = split(/=/, $pair);
                $name =~ tr/+/ /;
                $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
                $value =~ tr/+/ /;
                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
                $value =~ s/<!--(.|\n)-->//g;
                $form{$name} = $value;
#               last;
        }
        return(%form);

Quote:
}

1;                

Anyway, as above xmlrpccgi demo doesn't seem to work without input, and I
can't generate input without knowing what it does I'd appreciate any
pointers to simple demo code which I could put into cgi-bin and test
drive a bit.

I guess I could also use a regexp looking for a cgi-bin/boo.cgi pattern in
the code below instead of a specific reference, and then parse the
self.path string by hand, but that looks unnecessary ugly. I might have to
go that route, though, if I can't figure any better way to process
arguments. Anyway, comments welcome.

import StringIO
import SimpleHTTPServer

BaseClass = SimpleHTTPServer.SimpleHTTPRequestHandler

CounterTemplate = """ <H1>Server
Statistics</H1>

This <A HREF=./>server</A> has been accessed
<b>%d</b> times.  """

count = 0

class MyRequestHandler(BaseClass):

    def do_GET(self):
        global count
        count = count + 1
        BaseClass.do_GET(self)

    def send_head(self):
        if self.path == "/counter.html":
            return self.send_counter()
        else:
            return BaseClass.send_head(self)

    def send_counter(self):
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        text = CounterTemplate % count
        return StringIO.StringIO(text)

def test():
    SimpleHTTPServer.test(MyRequestHandler)

test()  



Mon, 15 Sep 2003 20:32:39 GMT  
 A newbie question on ftplib.

Quote:

> I'm trying to wrap the coils of my puny little mind around XML-RPC,
> specifically Kalle Svensson's CGI XML-RPC server:

> http://mail.python.org/pipermail/python-announce-list/2001-March/0006...

> (interesting enough, according to Google there seems to be also Jeff's

> http://starship.python.net/crew/jjkunce/python/xmlrpccgi.tgz

> advertised as "A XML-RPC "server" that is accessed via a web server
> through CGI calls (as opposed to a long-running XML-RPC server that
> monitors a dedicated port).", which seems 1) entirely unrelated to 2) much
> smaller than Kalle's code 3) designed for Winders).

> To reiterate, I'm trying to be able to trap URI's looking like

> http://blah.net:666/cgi/boo.cgi?hiss=aargh#boom

> or parameters POSTed via HTML like

> <FORM TARGET="result">
> <INPUT TYPE=button VALUE="Start search now!" onClick="jsCopyFormData();return (0);">
> </FORM>
> <FORM name=submitform METHOD=post TARGET="result" ACTION="">
> <INPUT TYPE=hidden NAME="smi"     VALUE="">
> <INPUT TYPE=hidden NAME="jme"     VALUE="">
> <INPUT TYPE=hidden NAME="stype"   VALUE="">
> <INPUT TYPE=hidden NAME="sstype"  VALUE="">
> <INPUT TYPE=hidden NAME="checkin" VALUE="$cwkey">
> <INPUT TYPE=hidden NAME="usr" VALUE="$user">
> </FORM>

sorry, it looks like I misread your original question -- I thought
you were looking for a way to pass arguments (i.e. do RPC calls)
to a server process via HTTP and CGI, not that you had to use
a certain syntax.

under XML-RPC, you send XML-RPC requests, not FORMs.  see
http://www.xmlrpc.com for more info.

Cheers /F



Mon, 15 Sep 2003 21:23:57 GMT  
 A newbie question on ftplib.

Quote:

> sorry, it looks like I misread your original question -- I thought
> you were looking for a way to pass arguments (i.e. do RPC calls)
> to a server process via HTTP and CGI, not that you had to use
> a certain syntax.

Oh, I can use XML-RPC just fine, as my (apparently quite
buzzword-compliant) company wants to give their products in future a SOAPy
flavour (they kept mishearing me saying SOAP when I was saying Zope ;). I
just thought that CGI XML-RPC would also handle parsing POST/GET
parameters -- well, it would have been too easy then. Sigh.

I guess I'll have to parse the parameters by hand, and using XML-RPC
at a later stage of the processing pipeline.

Quote:
> under XML-RPC, you send XML-RPC requests, not FORMs.  see
> http://www.xmlrpc.com for more info.

Thanks, have been there (though got no T-shirt yet).

You as others been very helpful. Now if somebody could tell me where I can
get Bobo for Medusa...



Mon, 15 Sep 2003 22:07:24 GMT  
 A newbie question on ftplib.
Isn't Bobo the older name for Zope? Perhaps something named bobo is in
an older zope distribution?

Regards,

Dave LeBlanc

On Thu, 29 Mar 2001 16:07:24 +0200 (MET DST), Eugene Leitl

Quote:


>> sorry, it looks like I misread your original question -- I thought
>> you were looking for a way to pass arguments (i.e. do RPC calls)
>> to a server process via HTTP and CGI, not that you had to use
>> a certain syntax.

>Oh, I can use XML-RPC just fine, as my (apparently quite
>buzzword-compliant) company wants to give their products in future a SOAPy
>flavour (they kept mishearing me saying SOAP when I was saying Zope ;). I
>just thought that CGI XML-RPC would also handle parsing POST/GET
>parameters -- well, it would have been too easy then. Sigh.

>I guess I'll have to parse the parameters by hand, and using XML-RPC
>at a later stage of the processing pipeline.

>> under XML-RPC, you send XML-RPC requests, not FORMs.  see
>> http://www.xmlrpc.com for more info.

>Thanks, have been there (though got no T-shirt yet).

>You as others been very helpful. Now if somebody could tell me where I can
>get Bobo for Medusa...



Tue, 16 Sep 2003 04:33:51 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Newbie Question (Was: Newbie Question...)

2. ftplib question

3. ftplib and zipfile question

4. ftplib problem/question

5. ftplib question

6. ftplib question

7. ftplib question

8. Not a newbie, but a newbie question...

9. Trivial Newbie Question (Newbie)

10. Newbie Question: Realbasic Question

11. Yet another question on system calls(newbie question)

12. question on event-generated errors (was Re: newbie TkCon question)

 

 
Powered by phpBB® Forum Software