Ticket #1775: ta-view-source-support.py

File ta-view-source-support.py, 1.1 KB (added by rgs, 14 years ago)
Line 
1    def get_document_path(self, async_cb, async_err_cb):
2        logo_code_path = self._dump_logo_code()
3        async_cb(logo_code_path)
4
5    def _dump_logo_code(self):
6        # work-around Rainbow which doesn't seem to like tempfile.mkstemp                                                                                   
7        try:
8            tmppath = os.path.join(activity.get_activity_root(), "instance")
9        except:
10            # Early versions of Sugar (e.g., 656) didn't support                                                                                             
11            # get_activity_root()                                                                                                                           
12            tmppath = os.path.join( \
13                os.environ['HOME'], \
14                ".sugar/default/org.laptop.TurtleArtActivity/instance")
15        tafile = os.path.join(tmppath,"tmpfile.ta")
16        try:
17            code = save_logo(self, self.tw)
18            f = file(tafile, "w")
19            f.write(code)
20            f.close()
21        except Exception, e:
22            print("couldn't dump code to view source: " + str(e))
23        return tafile
24