Tried to run it from the top node, the one with @auto-rst... Then I get: NameError: name 'os' is not defined -------------------- line 5: _prochead = _cnode.headString().split()[1] * line 6: _thispath = os.path.dirname(c.fileName())+"/" +_prochead line 7: _runstring = "rst2pdf "+ _thispath + " -o " + _thispath + ".pdf" line 8: print _runstring
-William S. 2009/9/9 Erik Southworth <[email protected]> > > > On Wed, Sep 9, 2009 at 8:17 AM, William Strømsvold < > [email protected]> wrote: > >> This code doesn't seem to work on Windows.. Any ideas? >> >> exception executing script >> IndexError: list index out of range >> -------------------- >> line 4: _cnode = c.currentPosition() >> * line 5: _prochead = _cnode.headString().split()[1] >> line 6: _thispath = os.path.dirname(c.fileName())+"/" +_prochead >> line 7: _runstring = "rst2pdf "+ _thispath + " -o " + _thispath + >> ".pdf" >> >> -William S. >> > > If I remember right, when I tried the code, it only worked on nodes at the > top/root of the tree. > > >> 2009/8/19 rhh <[email protected]> >> >> >>> The following is a clean-up of the code I gave above. It creates an >>> rst file and a pdf of the rst file using the headline name. >>> >>> ### >>> c.k.simulateCommand('write-restructured-text') >>> _cnode = c.currentPosition() >>> _prochead = _cnode.headString().split()[1] >>> _thispath = os.path.dirname(c.fileName())+"/" +_prochead >>> _runstring = "rst2pdf "+ _thispath + " -o " + _thispath + ".pdf" >>> print _runstring >>> os.system(_runstring) >>> pid = subprocess.Popen([_pdfreader_path,_thispath+".pdf"]).pid >>> ### >>> >>> >>> On Aug 18, 10:12 pm, Vicent <[email protected]> wrote: >>> > Hi, >>> > >>> > On 18 Ago, 16:04, rhh <[email protected]> wrote: >>> > >>> > > I use the module rst2pdf (which uses reportlab) and the following >>> > > button script (use Toolbar Manager plugin). The last line >>> > > automatically opens the pdf file in a reader (variables need to be >>> > > set). >>> > > ... >>> > >>> > I use a similar approach (rst2X command + leo button) with my >>> > @auto-rst trees, but don't use the toolbar manager plugin, simply >>> > os.system() calls. Basically something like: >>> > >>> > if os.system('rst2X %s .%s %s' % (args, input, output)) == 0: >>> > g.es('rst2lX successful.', color='turquoise4') >>> > else: >>> > g.es('rst2X failed.', color='red') >>> > >>> > Vicent >>> >>> >> >> >> > > > -- > -Erik S > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en -~----------~----~----~----~------~----~------~--~---
