How can I use python to execute files through other programs?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uthalcyon
    New Member
    • Mar 2007
    • 6

    How can I use python to execute files through other programs?

    My objective is a Python program which ultimately creates a PDF.

    Presently, my program takes in a .csv file and creates a .tex file. Using cygwin, I can take a .tex file and convert it to .pdf in this manner:

    $ latex example.tex && dvipdf example.dvi example.pdf

    [LaTEX is an open-source computer typesetting language. The first part of the command generates a .dvi from the .tex. "dvipdf" converts the .dvi to a .pdf]

    So is there a good, simple way of doing this? Thanks.
    ~Jesse, Houston TX
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by uthalcyon
    My objective is a Python program which ultimately creates a PDF.

    Presently, my program takes in a .csv file and creates a .tex file. Using cygwin, I can take a .tex file and convert it to .pdf in this manner:

    $ latex example.tex && dvipdf example.dvi example.pdf

    [LaTEX is an open-source computer typesetting language. The first part of the command generates a .dvi from the .tex. "dvipdf" converts the .dvi to a .pdf]

    So is there a good, simple way of doing this? Thanks.
    ~Jesse, Houston TX
    Hello and welcome to the Python Forum on TheScripts.com.

    LaTex is also available for python. Some documentation is here.

    There is also a cool-looking project called PyTex.

    Hope that gets you pointed in the right direction.

    Comment

    • uthalcyon
      New Member
      • Mar 2007
      • 6

      #3
      Originally posted by bartonc
      Hello and welcome to the Python Forum on TheScripts.com.

      LaTex is also available for python. Some documentation is here.

      There is also a cool-looking project called PyTex.

      Hope that gets you pointed in the right direction.
      Thank you for your promptness, but, as far as I can tell, these are both dead ends. Here's what I found...

      The first link is for assistance in documenting python files, for which process (I'm told) many users often employ LaTEX. Presented here, related to LaTEX, is only a very basic overview of how LaTEX works. A comprehensive understanding of LaTex can be gained from Kopka/Daly's "Guide to LaTEX".

      The second link directs to two projects in the early stages of development: QaTEX and PyTEX. The PyTEX download claims to work for style files but contains only something called 'catalog' which appears to note how to "stay archival and manage change" and which also mentions a few of the ambitions for later versions. I don't even know what to say about QaTEX. If this version does anything, I haven't discovered how. It's newborn though, and surely doesn't do all they'd like it to (Noting that it doesn't work with windows yet and in the qatex.py file there's this handy comment: "# this does not work - need to change def'n of link fn") attempting to use latex to open the provided sample file gave me an error I'd never seen:

      $ qatex nestA.tex
      bash: qatex: command not found
      $ latex nestA.tex
      .
      .
      .
      !Q=qalib.qatex. import,qalib
      !A=
      ^cursor here, waiting for input.

      Comment

      • uthalcyon
        New Member
        • Mar 2007
        • 6

        #4
        I'll try to be more specific... I'm very new to technical forums, so asking the right question is decidedly tricky.

        Do you know of commands or code segments available in python to call up other programs?

        I've successfully used python to create the proper LaTEX file. Now I want it to call LaTEX on it's own to generate the .dvi file, then take that file and convert it to PDF. Surely there's a way.

        Thank you all again for any help you can provide.
        ~Jesse

        Comment

        • bartonc
          Recognized Expert Expert
          • Sep 2006
          • 6478

          #5
          Originally posted by uthalcyon
          I'll try to be more specific... I'm very new to technical forums, so asking the right question is decidedly tricky.

          Do you know of commands or code segments available in python to call up other programs?

          I've successfully used python to create the proper LaTEX file. Now I want it to call LaTEX on it's own to generate the .dvi file, then take that file and convert it to PDF. Surely there's a way.

          Thank you all again for any help you can provide.
          ~Jesse
          On Windows you can
          Code:
          import os
          os.startfile('thefilename.ext')
          If there is a program associated with .ext, Python will start that program with that file.

          Generally, though, you want to automate the process. In order to do that the program must be COM aware and you'll need to learn about win32.comclient .

          Comment

          • uthalcyon
            New Member
            • Mar 2007
            • 6

            #6
            I think I may have found what I needed within the os.system.

            Comment

            • ghostdog74
              Recognized Expert Contributor
              • Apr 2006
              • 511

              #7
              Originally posted by uthalcyon
              I think I may have found what I needed within the os.system.
              for creating pdf files, you can try reportlab.

              Comment

              Working...