2 # -*- coding: UTF-8 -*-
5 # graphical user interface for pdf2swf
7 # Part of the swftools package.
9 # Copyright (c) 2008,2009 Matthias Kramm <kramm@quiss.org>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
28 from wx.lib.pubsub import Publisher
29 from subprocess import Popen, PIPE
32 def before_render(self):
35 def before_save(self, page):
38 def after_save(self, page):
41 def _swap_extension(self, filename, newext, flashversion=""):
42 name, ext = os.path.splitext(filename)
43 return u"%s%s.%s" % (name, flashversion, newext)
45 def __find_swfcombine(self):
47 prog = "swfcombine.exe" if "wxMSW" in wx.PlatformInfo else "swfcombine"
48 basedir = os.path.dirname(__file__)
51 locations = [opj(basedir, prog)]
52 if "wxMSW" in wx.PlatformInfo:
54 opj("c:", "swftools", prog),
55 opj("c:", "Program Files", "SWFTools", prog)
59 opj(os.sep, "usr", "local", "bin", prog),
60 opj(os.sep, "usr", "bin", prog),
71 def swfcombine(self, *args):
73 self.__swfcombine(*args)
75 wx.CallAfter(Publisher.sendMessage,
76 "SWF_COMBINE_ERROR", unicode(e))
79 def __swfcombine(self, *args):
80 exe, found = self.__find_swfcombine()
81 # uncoment to test a failed swfcombine find
85 raise Exception(u"Could not execute %s: %s not found" % (exe, exe))
87 # Create a command line
91 output = Popen(cmd, stdout=PIPE).communicate()[0]
93 # Check the process output
95 raise Exception(u"Error executing %s:%s%s" %
96 (u" ".join(cmd), os.linesep, output))