Ejemplo n.º 1
0
def test_gki_prow_to_different_devices():  # rename to disable for now
    """Test 2 prow calls, each to different devices - one .ps written.

    10 May 2012 - rename to disable for now - is sending nightly prints
    to hpc84.
    It seems that the cups system takes the print to hp_dev_null and
    changes that to an existing printer, knowing it is wrong ...
    When there is time, look into a way to start this test up again without any
    danger of prints going to an actual printer.
    """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # use a fake printer name so we don't waste a sheet of paper with each test
    os.environ['LPDEST'] = "hp_dev_null"
    os.environ['PRINTER'] = "hp_dev_null"
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot (no .ps file yet)
    # plot to fake printer, should flush
    iraf.prow("dev$pix", row=333, dev="lw")
    # last plot, and should warn @ fake
    # get output postscript temp file name
    psOut = getNewTmpPskFile(flistBef, "prow_to_different_devices")
    # diff
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_256.ps"))
    # NOW flush - should do nothing
    flistBef = findAllTmpPskFiles()
    iraf.gflush()
    flistAft = findAllTmpPskFiles()
    assert flistBef == flistAft, "Extra tmp .ps file written? "+str(flistAft)
Ejemplo n.º 2
0
def gki_2_prows_no_append_test():
   """ Test 2 prow calls with no append (2 dev$pix rows) to 2 .ps's """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot
   iraf.prow("dev$pix", row=250, dev=PSDEV) # plot again (flushes 1st)
   # get output postscript temp file name
   prf = None
   if os.uname()[0] == 'SunOS': prf = '.eps' # Solaris can leave extras here
   psOut = getNewTmpPskFile(flistBef, "2_prows_no_append - A", preferred=prf)
   # diff
   # NOTE - this seems to get 0-len files when (not stdin.isatty()) for psdump
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256.ps")
   # NOW flush second
   flistBef = findAllTmpPskFiles()
   iraf.gflush()
   # get output postscript temp file name
   prf = None
   if os.uname()[0] == 'SunOS': prf = '.eps' # Solaris can leave extras here
   psOut = getNewTmpPskFile(flistBef, "2_prows_no_append - B", preferred=prf)
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_250.ps")
Ejemplo n.º 3
0
def test_gki_2_prows_no_append():
    """ Test 2 prow calls with no append (2 dev$pix rows) to 2 .ps's """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot
    iraf.prow("dev$pix", row=250, dev=PSDEV)  # plot again (flushes 1st)
    # get output postscript temp file name
    prf = None
    if os.uname()[0] == 'SunOS':
        prf = '.eps'  # Solaris can leave extras here
    psOut = getNewTmpPskFile(flistBef, "2_prows_no_append - A", preferred=prf)
    # diff
    # NOTE - this seems to get 0-len files when (not stdin.isatty()) for psdump
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_256.ps"))
    # NOW flush second
    flistBef = findAllTmpPskFiles()
    iraf.gflush()
    # get output postscript temp file name
    prf = None
    if os.uname()[0] == 'SunOS':
        prf = '.eps'  # Solaris can leave extras here
    psOut = getNewTmpPskFile(flistBef, "2_prows_no_append - B", preferred=prf)
    # diff
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_250.ps"))
Ejemplo n.º 4
0
def test_gkidecode(tmpdir):
    iraf.plot(_doprint=0)
    prow_stdout = str(tmpdir.join('test_prow_256.gki'))
    gki_stdout = str(tmpdir.join('gkidecode_stdout.txt'))
    gki_stderr = str(tmpdir.join('gkidecode_stderr.txt'))

    iraf.prow("dev$pix", row=256, StdoutG=prow_stdout)
    iraf.gkidecode(prow_stdout, Stdout=gki_stdout, Stderr=gki_stderr)
    assert 'close_workstation' in open(gki_stdout).readlines()[-1]
    assert not open(gki_stderr).readlines()
Ejemplo n.º 5
0
def test_gki_single_prow():
    """ Test a prow-plot of a single row from dev$pix to .ps """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot
    iraf.gflush()
    # get output postscript temp file name
    psOut = getNewTmpPskFile(flistBef, "single_prow")
    # diff
    diffit(EXP2IGNORE, psOut, os.path.join(DATA_DIR, PSDEV + "_prow_256.ps"))
Ejemplo n.º 6
0
def gki_prow_1_append_test():
   """ Test a prow-plot with 1 append (2 rows total, dev$pix) to .ps """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot
   iraf.prow("dev$pix", row=250, dev=PSDEV, append=True) # append #1
   iraf.gflush()
   # get output postscript temp file name
   psOut = getNewTmpPskFile(flistBef, "prow_1_append")
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256_250.ps")
Ejemplo n.º 7
0
def test_plot_prow(marker, graphics):
    os.environ['PYRAFGRAPHICS'] = graphics
    apd = False
    for row in range(150, 331, 90):
        if marker is None:
            iraf.prow('dev$pix', row, wy2=400, append=apd, pointmode=False)
        else:
            iraf.prow('dev$pix',
                      row,
                      wy2=400,
                      append=apd,
                      pointmode=True,
                      marker=marker)
        apd = True
Ejemplo n.º 8
0
def test_gki_prow_1_append():
    """ Test a prow-plot with 1 append (2 rows total, dev$pix) to .ps """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot
    iraf.prow("dev$pix", row=250, dev=PSDEV, append=True)  # append #1
    iraf.gflush()
    # get output postscript temp file name
    psOut = getNewTmpPskFile(flistBef, "prow_1_append")
    # diff
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_256_250.ps"))
Ejemplo n.º 9
0
def manyPoints(task, pkind):
    """ Plot a bunch of points, return the time it took (s). """

    assert task in ('prow','graph','surface','contour'), \
           "Unexpected task: "+str(task)
    assert pkind in (None, 'point','box','plus','cross','circle'), \
           'Unknown: '+str(pkind)

    # plot 10 rows.  in dev$pix this is 5120 pts
    start = time.time()

    if task == 'prow':
        apd = False
        for row in range(150, 331, 20):
            if pkind == None:
                iraf.prow('dev$pix', row, wy2=400, append=apd, pointmode=False)
            else:
                iraf.prow('dev$pix',
                          row,
                          wy2=400,
                          append=apd,
                          pointmode=True,
                          marker=pkind)
            apd = True
    elif task == 'graph':
        tstr = ''
        for row in range(150, 331, 20):
            tstr += 'dev$pix[*,' + str(row) + '],'
        tstr = tstr[:-1]  # rm final comma
        if pkind == None:
            iraf.graph(tstr, wy2=400, pointmode=False, ltypes='1')
        else:
            iraf.graph(tstr, wy2=400, pointmode=True, marker=pkind)
    elif task == 'contour':
        iraf.contour("dev$pix", Stdout='/dev/null')
    elif task == 'surface':
        iraf.surface("dev$pix", Stdout='/dev/null')
    else:
        raise Exception("How did we get here?")

    delay = time.time() - start

    # clear out kernel memory explicitly
    time.sleep(2)
    gki.kernel.clear()
    return delay
Ejemplo n.º 10
0
def manyPoints(task, pkind):
   """ Plot a bunch of points, return the time it took (s). """

   assert task in ('prow','graph','surface','contour'), \
          "Unexpected task: "+str(task)
   assert pkind in (None, 'point','box','plus','cross','circle'), \
          'Unknown: '+str(pkind)

   # plot 10 rows.  in dev$pix this is 5120 pts
   start = time.time()

   if task == 'prow':
      apd = False
      for row in range(150, 331, 20):
         if pkind == None:
            iraf.prow('dev$pix', row, wy2=400, append=apd, pointmode=False)
         else:
            iraf.prow('dev$pix', row, wy2=400, append=apd, pointmode=True, marker=pkind)
         apd = True
   elif task == 'graph':
      tstr = ''
      for row in range(150, 331, 20):
         tstr += 'dev$pix[*,'+str(row)+'],'
      tstr = tstr[:-1] # rm final comma
      if pkind == None:
         iraf.graph(tstr, wy2=400, pointmode=False, ltypes='1')
      else:
         iraf.graph(tstr, wy2=400, pointmode=True, marker=pkind)
   elif task == 'contour':
         iraf.contour("dev$pix", Stdout='/dev/null')
   elif task == 'surface':
         iraf.surface("dev$pix", Stdout='/dev/null')
   else:
       raise Exception("How did we get here?")

   delay = time.time() - start

   # clear out kernel memory explicitly
   time.sleep(2)
   gki.kernel.clear()
   return delay
Ejemplo n.º 11
0
def gki_prow_to_different_devices_tst(): # rename to disable for now
   """ Test 2 prow calls, each to different devices - one .ps written """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # use a fake printer name so we don't waste a sheet of paper with each test
   os.environ['LPDEST'] = "hp_dev_null"
   os.environ['PRINTER'] = "hp_dev_null"
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot (no .ps file yet)
   iraf.prow("dev$pix", row=333, dev="lw") # plot to fake printer, should flush
                                           # last plot, and should warn @ fake
   # get output postscript temp file name
   psOut = getNewTmpPskFile(flistBef, "prow_to_different_devices")
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256.ps")
   # NOW flush - should do nothing
   flistBef = findAllTmpPskFiles()
   iraf.gflush()
   flistAft = findAllTmpPskFiles()
   assert flistBef==flistAft, "Extra tmp .ps file written? "+str(flistAft)
Ejemplo n.º 12
0
def gki_prow_to_different_devices_tst(): # rename to disable for now
   """ Test 2 prow calls, each to different devices - one .ps written """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # use a fake printer name so we don't waste a sheet of paper with each test
   os.environ['LPDEST'] = "hp_dev_null"
   os.environ['PRINTER'] = "hp_dev_null"
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot (no .ps file yet)
   iraf.prow("dev$pix", row=333, dev="lw") # plot to fake printer, should flush
                                           # last plot, and should warn @ fake
   # get output postscript temp file name
   psOut = getNewTmpPskFile(flistBef, "prow_to_different_devices")
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256.ps")
   # NOW flush - should do nothing
   flistBef = findAllTmpPskFiles()
   iraf.gflush()
   flistAft = findAllTmpPskFiles()
   assert flistBef==flistAft, "Extra tmp .ps file written? "+str(flistAft)
Ejemplo n.º 13
0
def test_gki_prow_2_appends():
    """ Test a prow-plot with 2 appends (3 rows total, dev$pix) to .ps """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot
    iraf.prow("dev$pix", row=250, dev=PSDEV, append=True)  # append #1
    iraf.prow("dev$pix", row=200, dev=PSDEV, append=True)  # append #2
    iraf.gflush()
    # get output postscript temp file name
    psOut = getNewTmpPskFile(flistBef, "prow_2_appends")
    # diff
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_256_250_200.ps"))
Ejemplo n.º 14
0
def gki_prow_2_appends_test():
   """ Test a prow-plot with 2 appends (3 rows total, dev$pix) to .ps """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot
   iraf.prow("dev$pix", row=250, dev=PSDEV, append=True) # append #1
   iraf.prow("dev$pix", row=200, dev=PSDEV, append=True) # append #2
   iraf.gflush()
   # get output postscript temp file name
   psOut = getNewTmpPskFile(flistBef, "prow_2_appends")
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256_250_200.ps")