summaryrefslogtreecommitdiff
path: root/buildscripts/s3del.py
blob: c06f18e5f11dc3e920343f03fcc8625c2940c83e (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
50
51
52
53
54
55

import os
import sys
import time

sys.path.append( "." )
sys.path.append( ".." )
sys.path.append( "../../" )
sys.path.append( "../../../" )

import simples3
import settings
import subprocess

# check s3 for md5 hashes

def check_dir( bucket , prefix , todel ):
    
    deleteAll = False

    for ( key , modify , etag , size ) in bucket.listdir( prefix=prefix ):
        if key.find( todel ) < 0:
            continue
        print( key )

        if not deleteAll:

            val = raw_input( "Delete (Y,y,n,N):" ).strip()

            if val == "n":
                print( "skipping this one" )
                continue
            elif val == "N":
                break

            if val == "Y":
                val = "y"
                deleteAll = True
                
            if val != "y":
                raise Exception( "invalid input :(" )

        bucket.delete( key )

def clean( todel ):


    bucket = simples3.S3Bucket( settings.bucket , settings.id , settings.key )
    
    for x in [ "osx" , "linux" , "win32" , "sunos5" , "src" ]:
        check_dir( bucket , x , todel )
    

if __name__ == "__main__":
    clean( sys.argv[1] )