
import os
import string
import stat
import sys
sys.path.append("lib")
sys.path.append("../lib")

import glideinMonitor

def createCatMonitorFile(monitor_file_name,monitor_control_relname,
                         argv,condor_status):
    fd=open(monitor_file_name,"w")
    try:
        fd.write("#!/bin/sh\n")
        fd.write("outdir=`ls -lt .. | tail -1 | awk '{print $9}'`\n")
        fd.write("(cd ../$outdir; if [ $? -eq 0 ]; then cat %s; else echo Internal error; fi)\n"%(string.join(argv)))
        fd.write("echo Done > %s\n"%monitor_control_relname)
    finally:
        fd.close()

    os.chmod(monitor_file_name,stat.S_IRWXU)


args=glideinMonitor.parseArgs(sys.argv[1:])

glideinMonitor.monitor(args['jid'],args['schedd_name'],args['pool_name'],
                       args['timeout'],
                       createCatMonitorFile,args['argv'])


import sys,os.path
sys.path.append(os.path.join(sys.path[0],"lib"))
sys.path.append(os.path.join(sys.path[0],"../lib"))

import glideinCmd

glideinCmd.exe_cmd(lambda argv:(['cat']+argv))

Change rel paths into abspaths and use helper module
Change rel paths into abspaths and use helper module

  
+ import sys,os.path
+ sys.path.append(os.path.join(sys.path[0],"lib"))
+ sys.path.append(os.path.join(sys.path[0],"../lib"))
- import os
- import string
- import stat
- import sys
- sys.path.append("lib")
- sys.path.append("../lib")
  
- import glideinMonitor
+ import glideinCmd
  
+ glideinCmd.exe_cmd(lambda argv:(['cat']+argv))
- def createCatMonitorFile(monitor_file_name,monitor_control_relname,
-                          argv,condor_status):
-     fd=open(monitor_file_name,"w")
-     try:
-         fd.write("#!/bin/sh\n")
-         fd.write("outdir=`ls -lt .. | tail -1 | awk '{print $9}'`\n")
-         fd.write("(cd ../$outdir; if [ $? -eq 0 ]; then cat %s; else echo Internal error; fi)\n"%(string.join(argv)))
-         fd.write("echo Done > %s\n"%monitor_control_relname)
-     finally:
-         fd.close()
  
-     os.chmod(monitor_file_name,stat.S_IRWXU)
- 
- 
- args=glideinMonitor.parseArgs(sys.argv[1:])
- 
- glideinMonitor.monitor(args['jid'],args['schedd_name'],args['pool_name'],
-                        args['timeout'],
-                        createCatMonitorFile,args['argv'])
- 
Change rel paths into abspaths and use helper module
## Code Before:

import os
import string
import stat
import sys
sys.path.append("lib")
sys.path.append("../lib")

import glideinMonitor

def createCatMonitorFile(monitor_file_name,monitor_control_relname,
                         argv,condor_status):
    fd=open(monitor_file_name,"w")
    try:
        fd.write("#!/bin/sh\n")
        fd.write("outdir=`ls -lt .. | tail -1 | awk '{print $9}'`\n")
        fd.write("(cd ../$outdir; if [ $? -eq 0 ]; then cat %s; else echo Internal error; fi)\n"%(string.join(argv)))
        fd.write("echo Done > %s\n"%monitor_control_relname)
    finally:
        fd.close()

    os.chmod(monitor_file_name,stat.S_IRWXU)


args=glideinMonitor.parseArgs(sys.argv[1:])

glideinMonitor.monitor(args['jid'],args['schedd_name'],args['pool_name'],
                       args['timeout'],
                       createCatMonitorFile,args['argv'])

## Instruction:
Change rel paths into abspaths and use helper module
## Code After:

import sys,os.path
sys.path.append(os.path.join(sys.path[0],"lib"))
sys.path.append(os.path.join(sys.path[0],"../lib"))

import glideinCmd

glideinCmd.exe_cmd(lambda argv:(['cat']+argv))
