title: Calling a python script within another one
body: <p>I have seen a couple of question related to my issue but haven't been able to get an answer.</p>
  
  <p>In my program I have a .txt file that needs to be converted to PDF.
  I came across this script that does the same, <a href="https://code.activestate.com/recipes/189858-python-text-to-pdf-converter/" rel="nofollow">https://code.activestate.com/recipes/189858-python-text-to-pdf-converter/</a></p>
  
  <p>I have imported this into my program, but I am not sure how to call and pass my txt file so that it converts it to PDF.</p>
  
  <p>.txt to .pdf converter script name is txttopdf.py i have imported it as import txttopdf and it is present in the same directory</p>
  
  <p>Last part of my program is trying to convert the .txt to .pdf but it gives me a Syntax error.
  Below is my program
          import sqlite3 
          import platform
          import sys
          import os
          import re
          import time
          import smtplib
          import mimetypes
          import txttopdf
          from datetime import datetime
          from email.mime.multipart import MIMEMultipart
          from email import encoders
          from email.message import Message</p>
  
  <pre><code>    from email.mime.text import MIMEText
      ipstr = "unknown"
      errorstr = "unknown"
      gtstr = "unknown"
  
      print "reading the file"
  
      linuxpath = raw_input("Enter the path")
  
      txt_file = open(linuxpath,"r")   
      countlines = 0
      if os.stat("lastline.txt").st_size == 0:
      for line in open(linuxpath):                                        
        pattern = re.compile('(([2][5][0-5]\.)|([2][0-4][0-9]\.)|([0-1]?[0-9]?[0-9]\.)){3}'+'(([2][5][0-5])|([2][0-4][0-9])|([0-1]?[0-9]?[0-9]))|[\d.]+|\:\:\d|[\w\.]+')
     #([\d.]+)[\s-]+\s+"([A-Z]+)\s+(.+?)"\s+([\s\d]+)')\[([\d\/A-Za-z: -]+)\]
     iprgex = pattern.search(line)
     #print "hi"
     countlines = countlines + 1
     if iprgex:
        ips = iprgex.start()
        ipe = iprgex.end()
        ipstr = line[ips:ipe]
        #print "hi again"
        #print ipstr
  
     pattern = re.compile('[\d]+\/[A-Za-z]+\/[\d]+')
     #('\[([\d\/A-Za-z: -]+)\]')
     datergex = pattern.search(line)
     #print "hi"
     if datergex:
        dates = datergex.start()
        datee = datergex.end()
        datestr = line[dates:datee]
        #countlines = countlines + 1
        #print "hi again"
        #print datestr
        monthstr = datestr[3:6]
        #print monthstr
        if monthstr == "Jan":
           date_chnge = datestr.replace("Jan","01")
        elif monthstr == "Feb":
           date_chnge = datestr.replace("Feb","02")
        elif monthstr == "Mar":
           date_chnge = datestr.replace("Mar","03")
           #print "am here"
          #print datestr
    elif monthstr == "Apr":
           date_chnge = datestr.replace("Apr","04")
    elif monthstr == "May":
           date_chnge = datestr.replace("May","05")
    elif monthstr == "Jun":
           date_chnge = datestr.replace("Jun","06")
    elif monthstr == "Jul":
           date_chnge = datestr.replace("Jul","07")
    elif monthstr == "Aug":
           date_chnge = datestr.replace("Aug","08")
    elif monthstr == "Sep":
           date_chnge = datestr.replace("Sep","09")
    elif monthstr == "Oct":
           date_chnge = datestr.replace("Oct","10")
    elif monthstr == "Nov":
           date_chnge = datestr.replace("Nov","11")
    elif monthstr == "Dec":
           date_chnge = datestr.replace("Dec","12")
  
     #print date_chnge
     dt_day = date_chnge[0:2]
     dt_month = date_chnge[3:5]
     dt_year = date_chnge[6:]
  
     new_date = dt_year + '-' + dt_month + '-' + dt_day
  
     pattern = re.compile('\:[\d]+\:[\d]+\:[\d]+')
     #('\[([\d\/A-Za-z: -]+)\]')
     timergex = pattern.search(line)
     #print "hi"
     if timergex:
        times = timergex.start()
        timee = timergex.end()
        timestr = line[times:timee]
        #countlines = countlines + 1
        #print "hi again"
        #print timestr
     extract_time = timestr[1:]
     datestring = new_date + ' ' + extract_time
     dt = datetime.strptime(datestring, '%Y-%m-%d %H:%M:%S')
     #print dt.year, dt.month, dt.day
  
     pattern = re.compile('"([A-Z]+)\s+(.+?)"|"\-"')
     getrgex = pattern.search(line)
     #print line
     if getrgex:
        gts = getrgex.start()
        gte = getrgex.end()
        gtstr = line[gts:gte]
        #countlines = countlines + 1
        #print "hi again"
        #print gtstr
  
     pattern = re.compile('200|401|403|404|412|500|302')
     errorrgex = pattern.search(line)
     #print "hi"
     if errorrgex:
        errors = errorrgex.start()
        errore = errorrgex.end()
        errorstr = line[errors:errore]
        #countlines = countlines + 1
        #print "hi again"
        #print errorstr
  
     file = open('parse1.txt','a')
     file.write(ipstr + datestr +timestr + gtstr + errorstr + "\n")
      #Analysing the get request
     print countlines
     #print ipstr,dt,gtstr,errorstr
     with open('ALLINONE.txt','r') as f:
          for cheatsheetline in f:
      indexvalue = gtstr.strip().find(cheatsheetline.strip())
      #print gtstr
      if indexvalue &gt; 0:
          #print indexvalue
          file = open('CAUTION.txt','a')
              file.write(ipstr + datestr +timestr + gtstr + errorstr + "\n")
      #break
      file.close()    
  
     lastlinefile = open('lastline.txt','w+')
     lastlinefile.write(line)
     #this part should convert the txt file CAUTION.txt to PDF
     #txttopdf.main()
     txttopdf CAUTION.txt  
  </code></pre>