dbrtools/dbr/dbrutils.py
branchDBRToolsDev
changeset 285 6a928cf9e181
parent 284 0792141abac7
equal deleted inserted replaced
284:0792141abac7 285:6a928cf9e181
    17 import os
    17 import os
    18 import sys
    18 import sys
    19 import string
    19 import string
    20 import shutil
    20 import shutil
    21 import time
    21 import time
       
    22 import urllib
       
    23 from urlparse import urljoin
       
    24 
    22 from os.path import join, isfile, stat
    25 from os.path import join, isfile, stat
    23 from stat import *
    26 from stat import *
    24 
    27 
    25 import glob # temporary (I hope) used for grabbing stuf from zip files...
    28 import glob # temporary (I hope) used for grabbing stuf from zip files...
    26 import tempfile
    29 import tempfile
    97       os.unlink(file)
   100       os.unlink(file)
    98             
   101             
    99 
   102 
   100 def getzippedDB(location):
   103 def getzippedDB(location):
   101     db = dict()
   104     db = dict()
       
   105     temp_dir = tempfile.mkdtemp()
   102     md5zip = os.path.join(location,'build_md5.zip')
   106     md5zip = os.path.join(location,'build_md5.zip')
       
   107     if(re.match('^http',location, re.IGNORECASE)):
       
   108       md5zip = os.path.join(temp_dir,'build_md5.zip')
       
   109       url = '%s%s' % (location,'build_md5.zip')
       
   110       res = urllib.urlretrieve(url,md5zip) 
   103     print md5zip 
   111     print md5zip 
   104     temp_dir = tempfile.mkdtemp()
       
   105     print temp_dir 
   112     print temp_dir 
   106     if(os.path.exists(md5zip)):
   113     if(os.path.exists(md5zip)):
   107       files = set();
   114       files = set();
   108       files.add('*')
   115       files.add('*')
   109       extractfromzip(files,md5zip,temp_dir)
   116       extractfromzip(files,md5zip,temp_dir)
   110       globsearch = os.path.join(temp_dir, os.path.join(patch_path_internal(),'*.md5'))
   117       globsearch = os.path.join(temp_dir, os.path.join(patch_path_internal(),'*.md5'))
   111       print globsearch 
   118 #      print globsearch 
   112       hashes = glob.glob(globsearch)
   119       hashes = glob.glob(globsearch)
   113       for file in hashes:
   120       for file in hashes:
   114 #          print 'Reading: %s\n' % file
   121 #          print 'Reading: %s\n' % file
   115           gethashes(db, file, True)
   122           gethashes(db, file, True)
   116     shutil.rmtree(temp_dir)            
   123     shutil.rmtree(temp_dir)