View Single Post
It was here first
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default It was here first - 06-05-2010, 06:06 PM

This thread is by zonedabone, the FIRST person to write file access programs in Alice using Jython. (Tell me if you want to argue.)

Ok. I've been on hiatus working on this and that IRL. I decided today that I'd work on multiplayer through ftp. Anyway, I'm working on a set of routines that will let you easily upload files to ftp servers, and then download and read them from any computer. I've set aside a section of my IP for testing. The details, which will bring you to a folder of happyness, limited to 1 MB will be given to those who give me a reason for experiments.

Anyway, here's the code for the ftp currently. It's pretty mcuh done, minus a few extra methods that I added in the demo.
PHP Code:
connected false
from ftplib import FTP
def connect
(host,username,password):
        global 
ftp
        
global connected
        
if connected == false:
                
ftp FTP(host,username,password)
                
connected true
def upload
(filename,name):
        global 
ftp
        
global connected
        
if connected == true:
                
test open(filename'r')
                
ftp.storbinary('STOR ' nametest)
                
test.close()
def download(filename,path):
        global 
ftp
        
global connected
        
if connected == true:
                
dir open(path'w')
                
file ftp.retrbinary('RETR ' filenamedir.write)
                
dir.close()
def close():
        global 
ftp
        
global connected
        
if connected == true:
                
ftp.quit()
                 
connected false
def getwelcome
():
        global 
ftp
        
global connected
        
if connected == true:
                
world.output ftp.getwelcome()
def rename(oldfile,newfile):
        global 
ftp
        
global connected
        
if connected == true:
                
ftp.rename(oldfile,newfile)
def delete(file):
        global 
ftp
        
global connected
        
if connected == true:
                
ftp.delete(file)
def setdir(dir):
        global 
ftp
        
global connected
        
if connected == true:
                
ftp.cwd(dir)
def makedir(dir):
        global 
ftp
        
global connected
        
if connected == true:
                
mkd(dir)
def deldir(dir):
        global 
ftp
        
global connected
        
if connected == true:
                
ftp.rmd(dir
With this code, I created a world that allows two computers to communicate. In fact, all computers usng this program will see what others are saying. Enjoy! Pressing U lets you add your message to it. Now with history thanks to Dameria's suggstion! New features! C = change user! D = disconnect.
intercom.a2w

If you don't have an account and can't download the file, it is also available on wikisend:
intercom.a2w


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.

Last edited by zonedabone; 06-06-2010 at 01:24 PM.
   
Reply With Quote