~manuq/hypernucleus/manuq

« back to all changes in this revision

Viewing changes to src/ModuleInstaller.py

  • Committer: Manuel Quiñones
  • Date: 2008-08-25 04:13:38 UTC
  • Revision ID: manuel.por.aca@gmail.com-20080825041338-d2ntxdllmxigbqeo
Progress dialog for the downloads.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import tarfile
7
7
import shutil
8
8
 
9
 
class ModuleTypeException(Exception):
 
9
class ModuleTypeError(Exception):
 
10
    pass
 
11
 
 
12
class DownloadError(Exception):
10
13
    pass
11
14
 
12
15
class HeadRequest(urllib2.Request):
29
32
        elif self.moduletype is 'game':
30
33
            self.extract_path = self.path.games
31
34
        else:
32
 
            raise ModuleTypeException()
 
35
            raise ModuleTypeError()
33
36
 
34
37
        self._get_file_info()
35
38
    
42
45
        
43
46
        # Get content length header
44
47
        req = HeadRequest(self.moduledata['archiveurl'])
45
 
        header_archive = urllib2.urlopen(req)
 
48
        try:
 
49
            header_archive = urllib2.urlopen(req)
 
50
        except urllib2.HTTPError, e:
 
51
            raise DownloadError()
46
52
        headers = dict(header_archive.headers)
47
53
        self.filesize = headers.get('content-length', -1)
48
54
        header_archive.close()
107
113
    elif moduletype is 'game':
108
114
        extract_path = path.games
109
115
    else:
110
 
        raise ModuleTypeException()
 
116
        raise ModuleTypeError()
111
117
 
112
118
    path_to_module = join(extract_path, modulename)
113
119
    shutil.rmtree(path_to_module, ignore_errors=True)