fredreichbier / genie

A Python module to access Genie engine (Age of Empires, ...) files
BSD 2-Clause "Simplified" License
19 stars 5 forks source link

Give error message instead of exiting dirty. #12

Open phrohdoh opened 9 years ago

phrohdoh commented 9 years ago
genie> drs
We're current browsing graphics.drs
genie> show 1154.slp
Now showing '1154.slp'. Keys:
        q       return to prompt
        +/-     zoom
        a       show the frame hotspot
        arrow keys      to cycle between frames

Traceback (most recent call last):
  File "browse_slp.py", line 307, in do_show
    self.loader.show_filename(name)
  File "browse_slp.py", line 59, in show_filename
    self.show_resource(resource_id)
  File "browse_slp.py", line 83, in show_resource
    frames = self.get_frames(resource_id)
  File "browse_slp.py", line 73, in get_frames
    slp_file = self.env.get_slp(self.drs_filename, resource_id, PygletAdapter, self.palette)
  File "/Users/thill/projects/genie/genie/environment.py", line 49, in get_slp
    self.get_palette(palette_id),
  File "/Users/thill/projects/genie/genie/environment.py", line 38, in get_palette
    drs = self.get_drs(INTERFAC_DRS)
  File "/Users/thill/projects/genie/genie/environment.py", line 29, in get_drs
    stream = self.cabinet.get_file(filename)
  File "/Users/thill/projects/genie/genie/cabinet.py", line 26, in get_file
    self._load_file(filename)
  File "/Users/thill/projects/genie/genie/cabinet.py", line 33, in _load_file
    self._files[filename] = open(filename, 'rb')
IOError: [Errno 2] No such file or directory: '/Users/thill/projects/python/pygenie/interfac.drs'

I'll work on this and submit a patch when I can.

Edit: After a bit of a review I've concluded that cleanly giving an error message here will require a rewrite of these operations and I don't have the time that would require this weekend.