#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    13
    Rep Power
    0

    Printing file from python


    I have a buffer within python that I write to a external file.

    I want to print either the buffer of the external file from within my python prog.

    Any ideas?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,843
    Rep Power
    480
    how about
    open(filename,'w').write(buffer)

    And then you could stick it in a context.
    See the with statement.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    139
    Rep Power
    3

    how about


    import os
    os.system(r'print printername filename')

    Comments on this post

    • b49P23TIvg agrees : Ha ha, a hard file! One for the file drawer.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    13
    Rep Power
    0
    Originally Posted by WynnDeezl
    import os
    os.system(r'print printername filename')
    I setup as follows:

    file = path/filename

    This is what I entered:
    import os
    os.system('print Brother HL-2280DW Printer file')

    the screen (on laptop) flashed but never printed. LIke it wants to print but no cigar.

    To get the printer name I went to 'Devices and Printers' and then just entered the default printer name. Is there someway that I can send something to the printer to verify it's the correct printer name?
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,843
    Rep Power
    480
    Oh you really did mean "print". What's your operating system? I usually create a LaTeX file, compile it to pdf (pdflatex) then print from evince.
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    139
    Rep Power
    3

    Try printer name with no spaces


    Change the printer name?
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    480
    Rep Power
    33
    I use subprocess to run
    lpr file_name
    and it always works. See "man lpr" for more info.

IMN logo majestic logo threadwatch logo seochat tools logo