OS Error 13 - how to debug to find error

This is the place for queries that don't fit in any of the other categories.

OS Error 13 - how to debug to find error

Postby budgie26 » Thu Jul 11, 2013 5:53 am

I have been given a set of python scripts and when I run them I get the following error:

Code: Select all
 File "make_script.py", line 159, in <module>
    main()
  File "make_script.py", line 51, in main
    tsx.extractImage(raw)
  File ".../make_scripts/Parsers/makeX.py", line 172, in extractImage
    process = subprocess.Popen(commandList)
  File "/usr/local/python-2.7.2/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/local/python-2.7.2/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied


I've tried using the pdb module to find where the error occurs, but no luck. I've also checked all the file permissions and they have 'rwx'. The only thing I haven't checked (and don't have permissions to change) are the /usr/local/python-2.7.2/xxxx directories.

Does anyone have any advice on how I can debug this to find extactly what directory is causing this problem?
Last edited by micseydel on Thu Jul 11, 2013 6:04 am, edited 1 time in total.
Reason: Locked post, added code tags to traceback.
budgie26
 
Posts: 2
Joined: Thu Jul 11, 2013 5:47 am

Re: OS Error 13 - how to debug to find error

Postby micseydel » Thu Jul 11, 2013 6:06 am

You'll have to post some code for us to make comments about the code.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1268
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: OS Error 13 - how to debug to find error

Postby budgie26 » Thu Jul 11, 2013 6:15 am

The make_script.py calls other python scripts, so I'm not sure if I need to include all of them. The script I run is the make_script.py and its code is:

Code: Select all
import os
import sys
import math
import datetime
import subprocess
sys.path.append(sys.path[0].rsplit('/',1)[0])
import Parsers.makeX
import Utils.Doppler

version = "3"

def main():
    if (len(sys.argv)<2):
        print "Usage: make_script.py data.xml"
        return
    xmlFile = sys.argv[1]
   
    # First, read in the 'product.xml' file
    tsx = Parsers.makeX.makeX(xml=xmlFile)
    tsx.parse()
   
    # Create a reasonable prefix for subsequent files
    prefix = tsx.getScene().getSensingStart().strftime('%y%m%d')
    svFile = 'hdr_data_points_' + prefix + '.rsc'
    raw = prefix + '.slc'
    rawRsc = raw + '.rsc'
   
    # Make a state vector file form the ephemeris in the xml file
    makeEphemeris(tsx.getScene(),svFile)

    # Extract the raw data
    tsx.extractImage(raw)

    # Make a resource file from a scene object
    makeRSC(tsx.getScene(),rawRsc,svFile,raw)

def makeRSC(scene,outFile,svFile,rawFile):
    """
        Given a scene object, make a resource file
    """
    first_line_utc = datetimeToSeconds(scene.getSensingStart())
    last_line_utc = datetimeToSeconds(scene.getSensingStop())
    center_line_utc = (first_line_utc + last_line_utc)/2
    centerTime = datetime.datetime(year=scene.getSensingStart().year,month=scene.getSensingStart().month,day=scene.getSensingStart().day)
    centerTime = centerTime + datetime.timedelta(microseconds=int(center_line_utc*1e6))
    scene.setSensingMid(centerTime)

    prf = scene.getInstrument().getPulseRepetitionFrequency()
    starting_range = scene.getStartingRange()
    wavelength = scene.getInstrument().getWavelength()         
    height_dt = scene.calculateHeightDt()
    height = scene.getOrientation().getSpacecraftHeight()
    velocity = scene.calculateVelocity()

    rsc = "FIRST_FRAME\t\t\t%s\n" % scene.getFrameNumber()
    rsc += "FIRST_FRAME_SCENE_CENTER_TIME\t%s\n" % centerTime.strftime('%Y%m%d%H%M%S')
    rsc += "FIRST_FRAME_SCENE_CENTER_LINE\t%s\n"  % int(scene.getNumberOfLines()/2)
    rsc += "DATE\t\t\t\t%s\n" % scene.getSensingStart().strftime('%y%m%d')
    rsc += "FIRST_LINE_YEAR\t\t\t%s\n" % scene.getSensingStart().year
    rsc += "FIRST_LINE_MONTH_OF_YEAR\t%s\n" % scene.getSensingStart().month
    rsc += "FIRST_LINE_DAY_OF_MONTH\t\t%s\n" % scene.getSensingStart().day
    rsc += "FIRST_CENTER_HOUR_OF_DAY\t%s\n" % scene.getSensingStart().hour
    rsc += "FIRST_CENTER_MN_OF_HOUR\t\t%s\n" % scene.getSensingStart().minute
    rsc += "FIRST_CENTER_S_OF_MN\t\t%s\n" % scene.getSensingStart().second
    rsc += "FIRST_CENTER_MS_OF_S\t\t%s\n" % int(scene.getSensingStart().microsecond*1e-3)
    rsc += "PROCESSING_FACILITY\t\t%s\n" % scene.getProcessingFacility()
    rsc += "PROCESSING_SYSTEM\t\t%s\n" % scene.getProcessingSystem()
    rsc += "PROCESSING_VERSION\t\t%s\n" % scene.getProcessingLevel()
    rsc += "PLATFORM\t\t\t%s\n" % scene.getInstrument().getPlatform().getMission()
    rsc += "ORBIT_NUMBER\t\t\t%s\n" % scene.getOrbitNumber()   
    rsc += "STARTING_RANGE\t\t\t%s\n" % starting_range
    rsc += "RANGE_PIXEL_SIZE\t\t%s\n" % scene.getInstrument().getRangePixelSize()
    rsc += "PRF\t\t\t\t%s\n" % prf
    rsc += "ANTENNA_SIDE\t\t\t%s\n" % scene.getInstrument().getAntennaSide()
    rsc += "ANTENNA_LENGTH\t\t\t%s\n" % scene.getInstrument().getAntennaLength()
    rsc += "FILE_LENGTH\t\t\t%s\n" % scene.getNumberOfLines()
    rsc += "XMIN\t\t\t\t%s\n" % 0
    rsc += "XMAX\t\t\t\t%s\n" % (scene.getNumberOfSamples())
    rsc += "WIDTH\t\t\t\t%s\n" % (scene.getNumberOfSamples())
    rsc += "YMIN\t\t\t\t%s\n" % 0
    rsc += "YMAX\t\t\t\t%s\n" % scene.getNumberOfLines()
    rsc += "RANGE_SAMPLING_FREQUENCY\t%s\n" % scene.getInstrument().getRangeSamplingFrequency()
    rsc += "PLANET_GM\t\t\t%s\n" % scene.getInstrument().getPlatform().getPlanet().getGM()
    rsc += "PLANET_SPINRATE\t\t\t%s\n" % scene.getInstrument().getPlatform().getPlanet().getSpinRate()
    rsc += "FIRST_LINE_UTC\t\t\t%s\n" % first_line_utc
    rsc += "CENTER_LINE_UTC\t\t\t%s\n" % center_line_utc
    rsc += "LAST_LINE_UTC\t\t\t%s\n" % last_line_utc
    rsc += "HEIGHT\t\t\t\t%s\n" % height
    rsc += "HEIGHT_DT\t\t\t%s\n" % height_dt
    rsc += "VELOCITY\t\t\t%s\n" % velocity
   rsc += "EQUATORIAL_RADIUS\t\t%s\n" % scene.getInstrument().getPlatform().getPlanet().getSemimajorAxis()
    rsc += "ECCENTRICITY_SQUARED\t\t%s\n" % scene.getInstrument().getPlatform().getPlanet().getEccentricitySquared()
    rsc += "EARTH_RADIUS\t\t\t%s\n" % scene.getInstrument().getPlatform().getPlanet().getSemiminorAxis()
    rsc += "ORBIT_DIRECTION\t\t\t%s\n" % scene.getPassDirection()
    rsc += "FILE_START\t\t\t%s\n" % 1
    rsc += "WAVELENGTH\t\t\t%s\n" % wavelength
    rsc += "PULSE_LENGTH\t\t\t%s\n" % scene.getInstrument().getPulseLength()
    rsc += "CHIRP_SLOPE\t\t\t%s\n" % scene.getInstrument().getChirpSlope()
    rsc += "I_BIAS\t\t\t\t%s\n" % scene.getIBias()
    rsc += "Q_BIAS\t\t\t\t%s\n" % scene.getQBias()
    rsc += "DOPPLER_RANGE0\t\t\t%s\n" % 0.0
    rsc += "DOPPLER_RANGE1\t\t\t%s\n" % 0.0
    rsc += "DOPPLER_RANGE2\t\t\t%s\n" % 0.0
    rsc += "DOPPLER_RANGE3\t\t\t%s\n" % 0.0
    rsc += "SQUINT\t\t\t\t%s\n" % 0.0
    rsc += "ROI_PAC_VERSION\t\t\t%s" % version
   
    fp = open(outFile,'w')
    fp.write(rsc)
    fp.close()     

def makeEphemeris(scene,outFile):
   
    hdr = ""
    for sv in scene.getOrbit():
        t = datetimeToSeconds(sv.getTime())
        pos = sv.getPosition()
        vel = sv.getVelocity()       
        hdr += "%s %s %s %s %s %s %s\n" % (t,pos[0],pos[1],pos[2],vel[0],vel[1],vel[2])
       
    fp = open(outFile,'w')
    fp.write(hdr)
    fp.close()
 
def datetimeToSeconds(dt):
    seconds = (dt.hour*60 + dt.minute)*60 + dt.second + dt.microsecond*1e-6
    return seconds
   
if __name__ == "__main__":
    main()
Last edited by Yoriz on Thu Jul 11, 2013 6:27 am, edited 1 time in total.
Reason: Added code tags
budgie26
 
Posts: 2
Joined: Thu Jul 11, 2013 5:47 am

Re: OS Error 13 - how to debug to find error

Postby micseydel » Thu Jul 11, 2013 6:30 am

You need to read this then read your traceback, which clearly indicates that there is a particular file you need to include for us. It says the exact line in all your code which is raiseing.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1268
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 3 guests