Ejemplo n.º 1
0
	def test_setServiceStartupType_ALG(self):
		self.assertTrue(winUtility.setServiceStartupType('ALG', 'LocalHost', 'auto'))
		self.assertFalse(winUtility.setServiceStartupType('ALG', 'LocalHost', 'junk'))
		self.assertEqual(winUtility.getServiceStartupType('ALG', 'LocalHost'), 'AUTO_START (DELAYED)')
		self.assertTrue(winUtility.setServiceStartupType('ALG', 'LocalHost', 'manual'))
		self.assertEqual(winUtility.getServiceStartupType('ALG', 'LocalHost'), 'DEMAND_START')
		self.assertTrue(winUtility.setServiceStartupType('ALG', 'LocalHost', 'disabled'))
		self.assertEqual(winUtility.getServiceStartupType('ALG', 'LocalHost'), 'DISABLED')
		self.assertTrue(winUtility.setServiceStartupType('ALG', 'LocalHost', 'automatic'))
		self.assertEqual(winUtility.getServiceStartupType('ALG', 'LocalHost'), 'AUTO_START (DELAYED)')
		self.assertTrue(winUtility.setServiceStartupType('ALG', 'LocalHost', 'manual'))
Ejemplo n.º 2
0
	def test_getServiceStartupType_namedInstance(self):
		self.assertEqual(winUtility.getServiceStartupType('MSSQL$SQLEXPRESS', 'LocalHost').upper(), 'AUTO_START')
Ejemplo n.º 3
0
	def test_getServiceStartupType_dhcp(self):
		self.assertEqual(winUtility.getServiceStartupType('Dhcp', 'LocalHost'), 'AUTO_START')
Ejemplo n.º 4
0
	def test_getServiceStartupType_junk(self):
		self.assertEqual(winUtility.getServiceStartupType('junk', 'LocalHost'), None)
import argparse
from winUtility import getServiceStartupType

parser = argparse.ArgumentParser(description='Get service status')
parser.add_argument('-f', '--fileInput', help='The presence of this parameter indicates server names come from a file',  action='store_true', default=False, dest='fileInput')
parser.add_argument('-i', '--input', help='When -f is present, please provide the name of the file that contains a list of servers, each on its own line. Otherwise, please type a list of servers, separated by comma.',  required=True, dest='iInput')
parser.add_argument('-s', '--service', help='Please provide the name of the service',  required = True, dest='sService')

argList = parser.parse_args()

if argList.fileInput:
	text_file = open("%s" % argList.iInput, "r")
	serverList = text_file.readlines()
else:
	serverList = argList.iInput.split(',')

startupType = {}
for server in serverList:
	startupType[server.strip()] = getServiceStartupType(argList.sService, server.strip())

print startupType