~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/sys_mgmt/system_management.py

updating

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        self.cur_os = os.uname()[0]
70
70
        self.cur_user = getpass.getuser()
71
71
        self.workdir = os.path.abspath(variables['workdir'])
 
72
        self.testdir = os.path.abspath(variables['testdir'])
72
73
        self.datadir = os.path.abspath(os.path.join(variables['testdir'],'dbqp_data'))
73
74
        self.top_srcdir = os.path.abspath(variables['topsrcdir'])
74
75
        self.top_builddir = os.path.abspath(variables['topbuilddir'])
76
77
        self.valgrind = variables['valgrind']
77
78
        self.gdb = variables['gdb']
78
79
        self.manual_gdb = variables['manualgdb']
 
80
        self.randgen_path = variables['randgenpath']
79
81
 
80
82
        # we use this to preface commands in order to run valgrind and such
81
83
        self.cmd_prefix = '' 
232
234
                self.logging.info("Using --start-dirty, not attempting to touch directories")
233
235
                return
234
236
            else:
 
237
                self.cleanup() # We crawl / try to kill any server pids we find
235
238
                self.remove_dir(self.workdir)
236
239
        self.allocate_workdir()
237
240
    
551
554
            self.append_env_var("LD_LIBRARY_PATH", debug_path, suffix=1)
552
555
            self.append_env_var("DYLD_LIBRARY_PATH", debug_path, suffix=1)
553
556
 
 
557
 
 
558
    def cleanup(self, exit=False):
 
559
        """ We try to kill any servers whose pid files
 
560
            we detect lurking about
 
561
 
 
562
        """
 
563
        
 
564
        self.pid_hunt_and_kill(exit)
 
565
 
 
566
    def pid_hunt_and_kill(self, exit):
 
567
        """ Crawl our workdir and look for server.pid files
 
568
            We read 'em and kill 'em if we find 'em
 
569
 
 
570
        """
 
571
 
 
572
        for root, dirs, files in os.walk(self.workdir):
 
573
            #print root, dirs, files
 
574
            for found_file in files:
 
575
                if found_file.endswith('.pid'):
 
576
                    file_path = os.path.join(root, found_file)
 
577
                    pid_file = open(file_path,'r')
 
578
                    pid = pid_file.readline().strip()
 
579
                    pid_file.close()
 
580
                    self.logging.info("Killing pid %s from %s" %( pid
 
581
                                                                , file_path
 
582
                                                                ))
 
583
                    self.execute_cmd("kill -9 %s" %pid, must_pass=0)
 
584
        if exit:
 
585
            sys.exit(0)
 
586
 
554
587
   
555
588
    
556
589