~openerp/openobject-client/4.2

« back to all changes in this revision

Viewing changes to bin/printer/printer.py

  • Committer: husen daudi
  • Date: 2009-02-19 11:28:29 UTC
  • Revision ID: hda@hda-20090219112829-chr9fcyv5dwwt0ia
added sxw and odt opener in printer

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
                        'html': self._findHTMLOpener,
49
49
                        'doc': self._findHTMLOpener,
50
50
                        'xls': self._findHTMLOpener,
 
51
            'sxw': self._findSXWOpener,
 
52
            'odt': self._findSXWOpener,
51
53
                }
52
54
 
53
55
        def _findInPath(self, progs):
60
62
                        for prog in progs[:]:
61
63
                                if prog in content:
62
64
                                        return os.path.join(dir, prog)#prog
63
 
                                        
 
65
 
64
66
                                        progs.remove(prog)
65
67
                                        found[prog] = os.path.join(dir, prog)
66
68
                for prog in lstprogs:
111
113
                        else:
112
114
                                return lambda fn: print_linux_filename(fn)
113
115
 
 
116
        def _findSXWOpener(self):
 
117
                if os.name == 'nt':
 
118
                        return lambda fn: os.startfile(fn)
 
119
                else:
 
120
                        if options.options['printer.softpath_html'] == 'none':
 
121
                                prog = self._findInPath(['ooffice', 'ooffice2', 'openoffice', 'soffice'])
 
122
                                def opener(fn):
 
123
                                        pid = os.fork()
 
124
                                        if not pid:
 
125
                                                pid = os.fork()
 
126
                                                if not pid:
 
127
                                                        os.execv(prog, (os.path.basename(prog),fn))
 
128
                                                time.sleep(0.1)
 
129
                                                sys.exit(0)
 
130
                                        os.waitpid(pid, 0)
 
131
                                return opener
 
132
                        else:
 
133
                                def opener(fn):
 
134
                                        pid = os.fork()
 
135
                                        if not pid:
 
136
                                                pid = os.fork()
 
137
                                                if not pid:
 
138
                                                        os.execv(options.options['printer.softpath_html'], (os.path.basename(options.options['printer.softpath_html']),fn))
 
139
                                                time.sleep(0.1)
 
140
                                                sys.exit(0)
 
141
                                        os.waitpid(pid, 0)
 
142
                                return opener
 
143
 
114
144
        def print_file(self, fname, ftype, preview=False):
115
145
                app_to_run = None
116
146
                try:
130
160
                            subprocess.Popen(cmd)
131
161
 
132
162
                        open_file( app_to_run, fname )
133
 
                        
 
163
 
134
164
                else:
135
165
                        finderfunc = self.openers.get(ftype)
136
166
                        if not finderfunc and sys.platform in ['win32', 'nt']: