All pastes #99279 Raw Edit

Mine

public text v1 · immutable
#99279 ·published 2006-07-25 05:21 UTC
rendered paste body
#!/usr/bin/env python
import os,sys,time,subprocess, shutil

class Check:
	
	def __init__(self):
		os.system("clear")
		if not self.is_root():
			sys.exit("You have to be root to execute this program")
		if not self.compatible_distro():
			sys.exit("Your distribution has not been tested and may not be compatible")

	def is_root(self):
		if os.getuid() != 0:
			return False
		return True
	
	def compatible_distro(self):
		compatible_distros = ["Ubuntu 6.06 LTS"]
		this_distro = self.open_pipe(["cat", "/etc/issue"])
		for distro in compatible_distros:
			if distro in this_distro:
				return True
		return False
	
	def open_pipe(self, command):
		dataobject = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
		out, err = dataobject.communicate()
		if out: return out
		if err: return err	
	
c = Check()