Changeset 2469


Ignore:
Timestamp:
02/15/09 23:13:04 (4 years ago)
Author:
nahuel
Message:

Manage the deletion of an application instance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • alternc-apps/trunk/bin/update_apps.py

    r2468 r2469  
    3434        os.chown(dir,33,-1) 
    3535 
     36def removeRecursiveDir(dir): 
     37    if os.path.exists(dir): 
     38        try: 
     39            os.rmdir(dir) 
     40        except OSError: 
     41            for directory in os.listdir(dir): 
     42                removeRecursiveDir(os.path.normpath(dir + "/" + directory)) 
     43 
     44            removeRecursiveDir(dir) 
     45 
    3646def installFile(fromfile, tofile): 
    3747    if not os.path.exists(tofile): 
     
    5868    fromfiles = generateFileList(alterncapps + "/" + application) 
    5969    tofiles = generateFileList(path) 
    60     print tofiles 
     70 
    6171    for dir in files['dirs']: 
    6272        createDirIfNotExist(path + dir) 
     
    7787        updateFiles(files, tofiles, os.path.normpath(alterncapps + "/" + appname), row[2]) 
    7888 
     89def uninstallApplication(appname, path): 
     90    installFiles = generateFileList(alterncapps + "/" + appname) 
     91 
     92    for file in installFiles['files']: 
     93        if os.path.exists(os.path.normpath(path + "/" + file)): 
     94            os.unlink(os.path.normpath(path + "/" + file)) 
     95 
     96    for dir in installFiles['dirs']: 
     97        removeRecursiveDir(os.path.normpath(path + "/" + dir)) 
    7998 
    8099def runCron(): 
    81100    conn = adodb.NewADOConnection('mysql') 
    82101    conn.Connect(host, username, password,database); 
     102 
     103    for row in conn.Execute('SELECT uid, application, path FROM applications WHERE installed = 2'): 
     104        uid         = row[0] 
     105        application = row[1] 
     106        path        = row[2] 
     107        uninstallApplication(application, path) 
     108        conn.Execute('DELETE FROM applications WHERE uid = %s AND application = %s AND path = %s',(uid,application,path)) 
    83109 
    84110    for row in conn.Execute('SELECT uid, application, path FROM applications WHERE installed = 0'): 
Note: See TracChangeset for help on using the changeset viewer.