示例#1
0
文件: svc.py 项目: fwin-dev/py.OS
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)
示例#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
示例#3
0
文件: svc.py 项目: fwin-dev/py.OS
def remove(serviceName):
    if pkg.isAptOS():
        _OS.runCMD("sudo update-rc.d -f %s remove", serviceName)
    elif pkg.isYumOS():
        raise NotImplemented	# TODO
示例#4
0
文件: svc.py 项目: fwin-dev/py.OS
def changeCurrentState(serviceName, action):
    assert action in ["start", "stop", "restart"]
    _OS.runCMD("sudo /etc/init.d/%s %s", (serviceName, action))