root/ossiedev/trunk/tools/wavedash/src/NodeBooterUtils.py @ 10473

Revision 10473, 3.7 KB (checked in by Snyder.Jason, 3 years ago)

added methods to check and see if the naming service is running and start it if necessary

RevLine 
[10405]1## Copyright 2005, 2006, 2007, 2008, 2009 Virginia Polytechnic Institute and State University
2##
3## This file is part of the OSSIE ALF Waveform Application Visualization Environment
4##
5## ALF is free software; you can redistribute it and/or modify
6## it under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 2 of the License, or
8## (at your option) any later version.
9##
10## ALF is distributed in the hope that it will be useful, but WITHOUT ANY
11## WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with OSSIE Waveform Developer; if not, write to the Free Software
17## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19import os
20import subprocess
21import shlex
[10413]22import time
[10422]23import ConfigParser
[10473]24import wx
[10405]25
[10433]26DEFAULT_DOMAIN_MANAGER = 'dom/domain/DomainManager.dmd.xml'
27DEFAULT_DEVICE_MANAGER = 'dev/nodes/default_GPP_node/DeviceManager.dcd.xml'
[10405]28
29class NodeBooterUtils:
[10433]30    def __init__(self, controller):
31        self.controller = controller
[10405]32   
33    def nodeBooterIsRunning(self):
34        processes = os.popen('ps x | grep nodeBooter').read()
35        processes = processes.split()
36        return ('/usr/local/bin/nodeBooter' in processes or '/usr/bin/nodeBooter' in processes)
37
[10433]38    def startNodeBooter(self):
39        if self.controller.OSSIEPropertyFileExists():
[10448]40            domainManager = self.controller.getOSSIEProperty('ossie', 'default.domain.manager')
41            deviceManager = self.controller.getOSSIEProperty('ossie', 'default.device.manager')
[10433]42        if domainManager == None:
43            domainManager = DEFAULT_DOMAIN_MANAGER
44        if deviceManager == None:
45            deviceManager = DEFAULT_DEVICE_MANAGER
46       
[10422]47        command = '/usr/local/bin/nodeBooter -D ' + domainManager + ' -d ' + deviceManager
[10405]48        args = shlex.split(command)
[10448]49        print "NodeBooter not running. Starting now with command: " + command
[10405]50        nodeBooterProcess = subprocess.Popen(args, cwd='/sdr')
[10413]51        time.sleep(2)
[10405]52        return nodeBooterProcess
[10473]53   
54    def namingServiceIsRunning(self):
55        namecltResult = os.popen('nameclt list').read()
56        if namecltResult.startswith('DomainName'):
57            return True
58        return False;
59   
60    def startNamingService(self):
61        nsCommand = self.controller.getOSSIEProperty('ossie', 'naming.service.start.command')
62        if not nsCommand == None:
63            if nsCommand.startswith('sudo'):
64                dialog = wx.TextEntryDialog(None, 'Please enter your root password to restart the naming service:', 'Restart Naming Service', '', style = wx.TE_PASSWORD | wx.OK | wx.CANCEL)
65                if dialog.ShowModal() == wx.ID_OK:
66                    password = dialog.GetValue()
67                    command = 'echo ' + '\"' + password + '\"' + ' | sudo -kS ' + nsCommand[5:]
68                    subprocess.Popen(command, shell=True)
69                    time.sleep(2)
70            else:
71                subprocess.Popen(nsCommand, shell=True)
72        else:
73            #default case
74            nsCommand = 'sudo service omniorb4-nameserver restart'
75            dialog = wx.TextEntryDialog(None, 'Please enter your root password to restart the naming service:', 'Restart Naming Service', '', style = wx.TE_PASSWORD | wx.OK | wx.CANCEL)
76            if dialog.ShowModal() == wx.ID_OK:
77                password = dialog.GetValue()
78                command = 'echo ' + '\"' + password + '\"' + ' | sudo -kS ' + nsCommand[5:]
79                subprocess.Popen(command, shell=True)
80                time.sleep(2)
[10405]81           
Note: See TracBrowser for help on using the browser.