[BangPypers] Plzzz help me!!!!!!!!!
Anand Balachandran Pillai
abpillai at gmail.com
Mon Jan 18 08:46:15 CET 2010
On Mon, Jan 18, 2010 at 11:37 AM, Smrutilekha Swain
<smrutilekha at gmail.com>wrote:
> hi...this is my code...but...it is not working...in this programme i want
> the pdf will be copied from source to destination after it is generated....
>
> ##############################################
>
> import os
> import shutil
>
> src = os.getcwd()
> dest = "E:\home\smruti\Python\PostMissionAnalysis\presentation"
>
> #################################################################
>
> def file_moved(filename):
> #filename = 'newfile.pdf'
> file_list = os.listdir(os.curdir)
> for eachfile in file_list:
> if (eachfile == filename):
> shutil.copy(src,dest)
> print "The File is moved"
>
> ##################################################################
>
> preamble = """\\documentclass{beamer}
> \\usepackage{ifpdf}
> \\usetheme{Warsaw}
> %\\usepackage(times)
> \\title{A Sample Of Beamer}
> \\author{Smruti}
> \\date{\\today}
>
> \\begin{document}
>
> \\begin{frame}[t,plain]
> \\titlepage
> \\end{frame}
> """
>
> newfile = open('newfile.tex','w')
> newfile.write(preamble)
>
>
> screenshotlist = glob.glob('*.png')
> newfile.write("""\section{screenshot}""")
>
> for figure in screenshotlist:
> includestring = """\\includegraphics[center]{""" + figure + """}"""
> newfile.write("""\\begin{frame}
> \\frametitle{""")
> newfile.write("""}
> \\begin{center}""")
> newfile.write(includestring)
> newfile.write("""
> \\end{center}
> \\end{frame}
> """)
>
> newfile.write("""\section{document}""")
> newfile.write("""\end{document}""")
>
> #os.read(newfile,1)
> newfile.close()
> os.system('pdflatex newfile.tex')
> pdf_file = open('newfile.pdf', 'r')
> #pdf_file = 'newfile.pdf'
> file_moved(pdf_file)
> pdf_file.close()
>
I see a problem here. file_moved is expecting a filename,
but you are passing it a file object ?
Also the file comparision (eachfile == filename) is not good.
Not sure what you are trying to do here, if you are trying to
compare the data, you should instead say,
eachfile_data = open(eachfile, 'r').read()
if eachfile_data == filename_data:
...
But again, you are not passing file data, but file object
to the function.
Please re-analyze your logic, and post the new code
correcting such obvious errors to somewhere like pastebin.ca
and post the URL here.
>
> ####################################################################
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
--
--Anand
More information about the BangPypers
mailing list