×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Apr 2005
    Location
    Robin Hood County
    Posts
    22

    Question File transfer to remote server. No Bluetooth.

    Hi all,

    how could I possibly send a larger textfile (around 100kB, possibly ZIP packed) from the phone to a remote server?

    I found that Python for Series 60 allows sending SMS or file trasnfers over Bluetooth. Both solutions do not fit my needs since I need to periodically transfer data from the phone to a server. The phones could be everywhere at that time.

    Since I can start a commandline tool from Python, I thought there might be a commandline based ftp-client which could be automated.

    Any ideas are greatly appreciated. Thanks for reading.

    Leif

  2. #2
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643
    Could you use httplib and do an HTTP PUT? Of course if you want to use ftp, you could simply use ftplib. You don't need to start another tool, since the Python standard library already has support for these.

    ftplib is not included by default, and we haven't tested if it works. If you are interested, then by all means get ftplib from the standard Python 2.2.2 distribution, test it and tell us how it worked.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    7
    Well ftplib isn't included in the default installation so I tried it. It does import ok, and on my phone asked for a connection profile so you may have some luck.

    Detailled in the API: http://www.python.org/doc/2.3.3/lib/ftp-objects.html

    It would be good for the whole project if you could try this and document it - certainly a useful feature to have available.

    You should confirm that you can actually *use* ftp on your operator network by using some other S60 ftp client.
    Last edited by layzee; 2005-07-11 at 16:15.

  4. #4
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643
    Originally posted by layzee
    [B]Detailled in the API: http://www.python.org/doc/2.3.3/lib/ftp-objects.html
    That documentation is for the wrong version. The Python version we use is 2.2.2:

    http://www.python.org/doc/2.2.2/lib/module-ftplib.html

    Also, be sure not to mix libraries from different Python versions or you may run into strange problems.
    Last edited by jplauril; 2005-07-12 at 14:19.

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    34
    Originally posted by jplauril
    That documentation is for the wrong version. The Python version we use is 2.2.2:

    http://www.python.org/doc/2.2.2/lib/module-ftplib.html

    Also, be sure not to mix libraries from different Python versions or you may run into strange problem.
    Well, I had a look into 2.4.1 ftplib.py (and at the differences between the file of 2.3.3 that raises an error in the emulator when I import it..)
    It seems to me compatible and actually it works.

    Code:
    ffrom ftplib import FTP
    
    try:
        ftp = FTP('www.dataprocess.it')
    except:
        print 'host not found'
    
    try:
        print ftp.login()
    except:
        print 'Login fail'
        
    try:
        print ftp.retrlines('LIST')     # list directory contents
    except:
        print 'A strange error'
    
    print 'Downloading...'
    fdl=open('C:\\filedl','wb')
    
    try:
        print ftp.retrbinary('RETR nozomi.ini', fdl.write)
    except:
        print 'Download error'
    
    print ftp.quit()
    Pietro
    Last edited by pimol; 2005-07-12 at 15:09.

  6. #6
    Registered User
    Join Date
    Apr 2005
    Location
    Robin Hood County
    Posts
    22
    Thanks guys! I am almost there.

    I am testing via the Bluetooth console and have been able to upload from my phone to an FTP server.

    I am using Python 1.1.5 and ftplib.py (from 2.4.1).

    BUT: the important commands do not finish. They just loop forever after they have done their major work.
    E.g. ftp.retrlines('LIST') prints the list and then stalls.
    E.g. ftp.storbinary("STOR "+savename, open(path+savename, "r")) send the data and then stalls.

    Any ideas?

  7. #7
    Registered User
    Join Date
    Apr 2005
    Location
    Robin Hood County
    Posts
    22
    Switching versions solved the problem for me.

    I can now confirm that FTP work for me (on a Nokia 6600) using the SIS from "PreAlpha_SDK_1stEd_FP1_Python_v1.1.0.zip"
    and the ftplib.py from "Python-2.2.2.tgz"

    Newer versions of ftplib.py might or might not work. I suspect that the error lurked in 1.1.5 Python but I haven't tested towards that assumption.

    Thanks for a great tool! I am becoming a Python fan.

  8. #8
    Registered User
    Join Date
    Apr 2005
    Location
    Robin Hood County
    Posts
    22

    Re: File transfer to remote server. No Bluetooth.

    Half a year later (see my previous post from 2005) and the bug is back again. Oh no! ;(

    I had to transfer files via FTP again so I crammed out my old source and was expecting it to work straight away. Guess what, it didn't! Luckily I saved a copy of the old Python SIS files that I used back then so I could compare between versions. I wrote a small program for that purpose.

    The following code is known to work on old Pys60 (details in the comments of the code) and on Windows Python 2.3.3. Unfortunately is doesn not work on any of the "1.2 final" releases of Python.

    Code:
    """
    lxo, 1.3.2006
    ---
    minimalftp.py works on these configurations (they are all obsolete!):
    Windows (2.3.3 #51)
    1)6600,PythonForSeries60_pre_SDK20.SIS (from 1.1.0?), ftplib.py (from 2.2.2), tested 07/2005
    2)3230,PythonForSeries60_pre_SDK20.SIS (from 1.1.0?), ftplib.py (from 2.2.2), tested 03/2006
    5)3230,PythonForSeries60_pre_SDK20.SIS (from 1.1.0?), ftplib.py (shipped version), tested 03/2006
    ---
    doesn't work here (these are current releases):
    *)3230,PythonForSeries60_for_2ndEd_SIS (from Python for 2nd Ed Feature Pack 1), ftplib.py (shipped version)
    3)3230,PythonForSeries60_for_2ndEd_SIS (from Python for 2nd Ed Feature Pack 1), ftplib.py (from 2.2.2)
    4)3230,PythonForSeries60_1stEd.SIS (from PythonForSeries60_for_1stEd_FP1_SIS), ftplib.py (shipped version)
    ---
    *this made me make this test as it is the platform that i am currently using
    """
    print "Testing FTP"
    import ftplib
    from ftplib import FTP
    ftp=FTP("ftp.scene.org","anonymous","test")
    ftp.retrlines('LIST')
    ftp.quit()
    print "FTP okay!"
    Could people please test it on their phones and post to this thread if they can
    a) reach the "FTP okay!" message
    b) get stuck on the last lines of the retrlines output ("[..]welcome.msg")

    Unfortunately I cannot just revert back to the old Python version as the rest of the code requires the newer version.

    Any ideas?
    Leif

  9. #9
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: File transfer to remote server. No Bluetooth.

    How about the new 1.3.1 from SourceForge? Does your code work with that?

  10. #10
    Registered User
    Join Date
    Jan 2006
    Posts
    3

    Re: File transfer to remote server. No Bluetooth.

    I found a very simple way to transfer text files to a remote server using the excellent simple tutorial of Jurgen Scheible at the address:
    ex_upload_file_to_url.htm.
    It is enough to have a php on the server and your code have to pass the file as a POST object to the script. It works like a charm!

    Mauro

  11. #11
    Registered User
    Join Date
    Apr 2005
    Location
    Robin Hood County
    Posts
    22

    Re: File transfer to remote server. No Bluetooth.

    @jplauril: it works with the sourceforge version 1.3.1. just tested it on the weekend. thank you. i also found out that the 1.2.final did not crash but waited about 6 minutes before returning from ftp.retrlines('LIST').

    will also try the http post. thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •