Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/checkVersion.py
blob: 6396e03ec52b89bbb215f8ff159fa133483690dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from ftplib import FTP

stream = open("version.txt", 'r')

def writeline_cb(line):
    stream.writelines(line + "\n")

if __name__ == "__main__":
    
    line1 = stream.readline().replace("\n","")
    stream.close()
    
    try:
        stream3 = open("musicpainter.config", 'r')
        username = stream3.readline().replace("\n","")
        ip = stream3.readline().replace("\n","")
        stream3.close()
    except:
        username = "Guest"
        ip = "musicpainter.media.mit.edu"
            
    ftp = FTP(ip, "musicpainter", "medialab")
    stream2 = open("srv_version.txt",'w')
    ftp.retrlines("RETR src/version.txt", stream2.writelines)
    stream2.close()
    
    stream2 = open("srv_version.txt",'r')
    line2 = stream2.readline().replace("\n","")
    stream2.close()
    
    if line1 == line2:
        print "You're using the latest version!"
    else:
        print "Start downloading the latest version!"
        stream4 = open("blank.sco", 'r')
        log = username + "_update_version.log"
        ftp.storlines("STOR log/" + log, stream4)
        stream4.close()
        
        list = ftp.nlst("src/*.*")
        for i in range(len(list)):
            stream = open(list[i], 'w')
            msg = ftp.retrlines("RETR src/" + list[i], writeline_cb)
            print "Downloading " + list[i] + "...." + msg
            stream.close()
        print "You're using the latest version!"
#    except:
#        print "Ignore update"
    ftp.quit()