Пример #1
0
def pre_install(package_name, download_url):
    #pre install - using smart.fetcher module to download package
    print '\n***Downloding WinLibre package...***'
    try:
        fetcher = Fetcher()
        fetcher.reset()
        info = {}#{'uncomp': True}
        item = fetcher.enqueue(download_url, **info)
        if (fetcher.run(what=False) is False):
            print 'Using cached download'
    except:
        print 'Download error occoured'
    
    #extracting the package to temp using 7Z CLI
    print '\n***Now extracting the package contents...***'
    temp_dir = os.getenv('temp')
    download_name = temp_dir + '\\' + pkg_name(download_url)
    #extract arg is temprorary and system dependent
    #appending $PATH to have 7za.exe will remove absolute path neccessity
    extract_arg = 'C:\wpc\wpc2\winlibre1.0\wpkg\\7za.exe'+' e ' + '-o'+temp_dir+' -y '+ download_name 
    try:
        p = Popen([extract_arg], stdout=PIPE, shell = True)
        op = p.communicate()[0]
        print 'Output : ' , op
    except Exception, e:
        print 'Errors occoured during extract', e
        op = -3 #Error code
Пример #2
0
 def downloader(self, URL):
 #using smart.fetcher() to download the package
     try:
         fetcher = Fetcher()
         fetcher.reset()
         info = {}#{'uncomp': True}
         item = fetcher.enqueue(URL, **info)
         if (fetcher.run(what=False) is False):
             print 'Using cached download'
     except:
         print 'Download error occoured'