 
   printPygments: ( txt, fileName ) ->
     # Try to determine the appropriate lexer
-    exec('pygmentize -N ' + fileName, (error, stdout, sterr) =>
+    exec("#{@pygmentsPath} -N " + fileName, (error, stdout, sterr) =>
       if(error)
         @printPygmentsLexer(txt, "text");
       else

module.exports = Printer =

  printFrameId: '---print-iframe---'

  printContentOnLoad: () ->
    iframe = document.getElementById(@printFrameId)

    @printPage(html)

  checkPygments: () ->
    search = ["pygmentize", path.join("C:\\", "Python27", "Scripts", "pygmentize")]
    found = false
    for exePath in search
      try
        execSync( "#{exePath} -N test.java" )
        found = true
        @pygmentsPath = exePath
      catch err
        # Empty

    return found

  printPygmentsLexer: ( txt, lexer ) ->
    args = atom.config.get('pprint.pygmentsOptions')
    args = "-O #{args} -O full,encoding=utf-8 -f html -l #{lexer}"
    child = exec("#{@pygmentsPath} #{args}", (error, stdout, stderr) =>
      if (error)
        console.error("exec error: #{error}")
        return
