Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4535722
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:26:29+00:00 2026-05-21T14:26:29+00:00

def make_pdf(self): self.get_filez() self.get_client() file_name = self.client_id+_+self.client_name+_+self.batch_num style = libxslt.parseStylesheetDoc(self.xsl_file) transformation = style.applyStylesheet(self.xml_file,None) style.saveResultToFilename(tmp/+file_name+.fo,transformation,0)

  • 0
def make_pdf(self):
        self.get_filez()
        self.get_client()
        file_name = self.client_id+"_"+self.client_name+"_"+self.batch_num
        style = libxslt.parseStylesheetDoc(self.xsl_file)   
        transformation = style.applyStylesheet(self.xml_file,None)
        style.saveResultToFilename("tmp/"+file_name+".fo",transformation,0)
        style.freeStylesheet()
        self.xml_file.freeDoc()
        transformation.freeDoc()
        fop_cmd = "/usr/bin/xmlgraphics-fop"
        #file_name = self.tpa+"_"+self.be+"_"+self.batch_num
        cmd = [fop_cmd,"-fo","tmp/"+file_name+".fo","-pdf","tmp/"+file_name+".pdf"]
        #fop_transform = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
        #fop_log = "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
        #fop_log = fop_log + time.strftime('%Y-%m-%d %R:%S')+"\n"
        #fop_log = fop_log + file_name+".fo" + "\n"
        #fop_log =  fop_transform.communicate()[0]+"\n"
        #f = open("/tmp/error_log","a")
        #f.write(fop_log)
        #f.close()

OK If I comment out the cmd variable declaration the code runs and makes an fo file correctly. With is uncommented like it is above, I get a NameError on file_name is not defined (which it is in the top). If I uncomment the second declaration of file_name right above the cmd declaratioin, it thows a NameError on self. ‘.’ In the past when this sort of thing happens, it is a syntax error. I am missing it, please helpz!

When the second declaration of file_name is commented out:

Traceback (most recent call last):
  File "make_pdfs.py", line 11, in ?
    from MakePdfs import MakePdfs
  File "/home/khouser/removed/removed/MakePdfs.py", line 16, in ?
    class MakePdfs:
  File "/home/khouser/removed/removed/MakePdfs.py", line 39, in MakePdfs
    cmd = [fop_cmd,"-fo","tmp/"+file_name+".fo","-pdf","tmp/"+file_name+".pdf"]
NameError: name 'file_name' is not defined

When the second declaration of file_name is uncommented:

Traceback (most recent call last):
  File "make_pdfs.py", line 11, in ?
    from MakePdfs import MakePdfs
  File "/home/khouser/removed/removed/MakePdfs.py", line 16, in ?
    class MakePdfs:
  File "/home/khouser/removed/removed/MakePdfs.py", line 38, in MakePdfs
    file_name = self.tpa+"_"+self.be+"_"+self.batch_num
NameError: name 'self' is not defined
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:26:30+00:00Added an answer on May 21, 2026 at 2:26 pm

    Mysterious NameErrors may arise from your file containing invisible control characters. On unix machines, you can spot these errors by looking at the output of

    cat -A filename.py
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I make this code work? class Meta @array = [:a,:b] def self.method_missing(name,
def self.get(server) return unless server server = server.to_s if klass = @handlers[server] obj =
I have something like this: class Vehicle def self.set_color(input) if %w{blue red green}.include?(input) input
I create a custom db.Property subclass: class PropertyFoo(db.StringProperty): def validate(self, value): # Yes this
Say I have models: class Animal(models.Model): type = models.CharField(max_length=255) class Dog(Animal): def make_sound(self): print
Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document()
Let's say I want to make a little wrapper along the lines of: def
def foo (): x = re.compile('^abc') foo2(x) def foo2(x): How do I get x
def update @album = Album.find(params[:id]) if @album.update_attributes(params[:album]) redirect_to(:action=>'list') else render(:action=>'edit') end end A Rails
def partial(template, *args) options = args.extract_options! options.merge!(:layout => false) if collection = options.delete(:collection) then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.