Beispiel #1
0
def changeBootState(serviceName, shouldStartAtBoot):
    if pkg.isAptOS():   # debian
        cmd = "sudo update-rc.d %s"
        if shouldStartAtBoot:   cmd += " defaults"
        else:                   cmd += " remove"
    elif pkg.isYumOS():
        cmd = "sudo chkconfig %s"
        if shouldStartAtBoot:   cmd += " on"
        else:                   cmd += " off"
    else:
        raise NotImplemented
    
    _OS.runCMD(cmd, serviceName)
Beispiel #2
0
def checkSuitablePyExe(ver=platform.python_version_tuple[:2], assertExists=True):
	"""
	Returns the executable name or path of the wanted python version which can be executed from the terminal.
	
	This function can be used to ensure compatibility between different versions.
	
	@param ver			tuple:	The wanted version, ex. (2,6)
	@param assertExists	bool:	If True, raises an exception if a suitable version isn't installed
	@return				string:	A compatible python executable name or path, or None
	"""
	currentVer = platform.python_version_tuple[:2]
	if currentVer < ver or currentVer[0] > ver[0]:
		# incompatible, so check for a differently installed python version
		exe = "python" + str(ver[0]) + "." + str(ver[1])
		if _OS.runCMD(exe + " -V", assertSuccess=False).returnCode != 0:
			if assertExists:
				raise Exception("Your python version is incompatible. Please install python " + ".".join(ver) + " and run this application using that version.")
			return None
		else:
			return exe
	else:
		return sys.executable
Beispiel #3
0
def remove(serviceName):
    if pkg.isAptOS():
        _OS.runCMD("sudo update-rc.d -f %s remove", serviceName)
    elif pkg.isYumOS():
        raise NotImplemented	# TODO
Beispiel #4
0
def changeCurrentState(serviceName, action):
    assert action in ["start", "stop", "restart"]
    _OS.runCMD("sudo /etc/init.d/%s %s", (serviceName, action))