All pastes #772802 Raw Edit

Unnamed

public python v1 · immutable
·published 2007-11-14 02:02 UTC
rendered paste body
import xchat,os,copy# About this plugin__module_name__ = "aVirtualInferno"__module_version__ = "5.15.2 (Anoikis)"__module_description__ = "Mac system info and media output"## This script was created by Illuminati @ DSLExtreme IRC, and is based on # M[OSX]S. It was written in TCL for 10.4 compatibility, then converted to # Python for OSx86 compatibility.# # Feel free to modify this code, but please give credit to the authors!## Compatibility note: The /macinfo command is compatible with 10.4 and above## Weather information courtesy Weather Underground## Usage: /macinfo displays your system information#			 Arguments (do not include quotes)#					'silent' will print the resulting output just locally#					'#' will output the info in the MIRC color of your choice#					'nocolor' will strip any color and formatting from output#					'full' will output the info from the flags below#					'cpu' will include the CPU count and CPU type#					'speed' will include the CPU(s) speed#					'temp' will include the CPU and GPU temp (if possible)#					'bat' will include the battery information (if applicable)#					'ram' will include the RAM usage information#					'hd' will include storage capacity information#					'res' will include the display resolution for all displays#					'os' will include operating system version information#					'process' will include the running process count#					'uptime' will include the system uptime#        /mactunes <args> will display iTunes (default) or RealPlayer info#            Arguments (do not include quotes)#					'silent' will print the resulting output just locally#                   '#' will output the info in the MIRC color of your choice#					'nocolor' will strip any color and formatting from output#					'real' will output RealPlayer information instead#                   'full' will output the info from the flags below#                   'bitrate' will include the bit rate info#                   'count' will include the number of times song was played#                   'rating' will include the star-rating for the song#                   'time' will include the time elapsed in the song#					'length' will include just the length of the song#                   'year' will include the year of the current item#					'url' will include the URL if listening to a stream#        /macmovie <args> will display the foremost movie info from QuickTime#           Arguments (do not include quotes)#					'silent' will print the resulting output just locally#                   '#' will output the info in the color of your choice#					'nocolor' will strip any color and formatting from output#                   'full' will output the info from the flags below#                   'resolution' will include the resolution of the movie#                   'time' will include the time elapsed in the movie#		/macweather <postal code or city> <args> display weather for a city#			Arguments (do not include quotes)#					'silent' will print the resulting output just locally#					'nocolor' will strip any color and formatting from output#					'full' will output the info from the flags below#					'humidity' will include the humidity information#					'pressure' will include atmospheric pressure information#					'wind' will include windspeed and direction information# Global Variablesxchatdir = xchat.get_info("xchatdir")includeColor = 0# DO NOT EDIT THESE VARIABLESmodehook = Nonecreationhook = Nonechanlist = [""]chancolor = [0]def getinfo (args):	global includeColor	showDefault = 0	goFull = 0	includeOS = 0	includeCPU = 0	includeCPUSpeed = 0	includeTemp = 0 # Set to 1 if you wish to include the CPU temperature	includeMemory = 0	includeCache = 0	includeHD = 0 # Set to 1 to always include hard drive information	includeProcessCount = 0	includeUptime = 0	includeResolution = 0	includeBattery = 0	silentMode = 0	isCharged = "No"	isCharging = "No"	goBat = "No"	cpucount = 0	isIntel = 0	output = ""	dataTypes = "SPHardwareDataType"	noColor = 0	coloredText = ""		arglength = len(args)	if arglength > 1:		i = 1		while i < arglength:			temp = args[i]			if temp == "os" or temp == "full":				includeOS = 1			if temp == "hd" or temp == "full":				includeHD = 1			if temp == "cpu" or temp == "full":				includeCPU = 1			if temp == "speed" or temp == "full":				includeCPUSpeed = 1			if temp == "temp" or temp == "full":				includeTemp = 1			if temp == "ram" or temp == "full":				includeMemory = 1			if temp == "process" or temp == "full":				includeProcessCount = 1			if temp == "uptime" or temp == "full":				includeUptime = 1			if temp == "res" or temp == "full":				includeResolution = 1			if temp == "bat" or temp == "full":				includeBattery = 1			if temp == "cache" or temp == "full":				includeCache = 1			if temp == "nocolor":				noColor = 1			if temp == "silent":				silentMode = 1			i = i + 1		if includeOS == 0:			if includeHD == 0:				if includeCPU == 0:					if includeCPUSpeed == 0:						if includeTemp == 0:							if includeMemory == 0:								if includeProcessCount == 0:									if includeUptime == 0:										if includeResolution == 0:											if includeBattery == 0:												if includeCache == 0:													showDefault = 1	else:		showDefault = 1			if showDefault == 1:		includeOS = 1		includeCPU = 1		includeCPUSpeed = 1		includeMemory = 1		includeHD = 1		includeProcessCount = 1		includeUptime = 1			temp = os.popen('sysctl hw.model')	temp = temp.readline()	compmodel = stripit(temp)	cmd = "cat /System/Library/SystemProfiler/SPPlatformReporter.spreporter/Contents/Resources/SPMachineTypes.plist | grep -A 1 \"" + compmodel + "\""	temp = os.popen(cmd)	junkline = temp.readline()	temp = temp.readline()	if len(temp) < 1:				temp = refMachineType(compmodel)	else:			temp = temp.split('>')		temp = temp[1]		temp = temp.split('<')		temp = temp[0]	machine = refModel(temp)	if noColor == 0:		coloredText = ""	output =  "I'm on a " + coloredText + machine	temp = os.popen('sysctl hw.ncpu')	line = temp.readline()	cpucount = stripit(line)	temp = os.popen('sysctl hw.cputype')	temp = temp.readline()	cputype = stripit(temp)	if cputype == "7":		isIntel = 1		temp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 BatteryInstalled')		goBat = linevalue(temp)		if goBat == "Yes":			temp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 MaxCapacity')			batMaxCapacity = float(linevalue(temp))			temp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 FullyCharged')			fullyCharged = linevalue(temp)			temp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 ExternalChargeCapable')			pluggedIn = linevalue(temp)			if fullyCharged == "Yes":				if pluggedIn == "Yes":					isCharged = "Yes"			if isCharged == "No":				temp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 CurrentCapacity')				batCurrent = float(linevalue(temp))				batPercent = (batCurrent / batMaxCapacity) * 100				batPercent = int(round(batPercent,0))				batstate = str(batPercent) + "%"			else:				batstate = "Charged"	else:		battemp = os.popen('ioreg -n battery -w 0 | grep -m 1 IOBatteryInfo')		batline = battemp.readline()		batlines = battemp.readlines()		if len(batline) > 0:			battime = ""			goBat = "Yes"			batlist = batline.split(',')			for x in batlist:				temp = x.split('=')				if len(temp) > 2:					batpropertyvalue = temp[2]					temp = temp[1].split('{')					batpropertyname = temp[1]				else:					batpropertyname = temp[0]					temp2 = temp[1].split('}')					if len(temp2) > 1:						batpropertyvalue = temp2[0]					else:						batpropertyvalue = temp[1]				if batpropertyname == "\"Capacity\"":					batMaxCapacity = float(batpropertyvalue)				elif batpropertyname == "\"Current\"":					current = float(batpropertyvalue)				elif batpropertyname == "\"Flags\"":					flag = int(batpropertyvalue)				elif batpropertyname == "\"AbsoluteMaxCapacity\"":					designCapacity = int(batpropertyvalue)			batpercent = (current / batMaxCapacity) * 100			batpercent = int(round(batpercent,0))			if (flag % 5) == 0:				isCharged = "Yes"				batstate = "Charged"			else:				chargeText = ""				if len(batlines) > 0:					for line in batlines:						if line.find("TimeRemaining") != -1:							temp = line.split('=')							temp = temp[1].strip()							timeremaining = int(temp)							timeremaining = convertTime(timeremaining,1)							battime = " (" + timeremaining + " left)"				if (flag % 7) == 0:					chargeText = " [Charging]"				batstate = str(batpercent) + "%" + battime + chargeText	if includeCPU == 1:		cmd = "sysctl hw.cpusubtype"		if isIntel == 1:			cmd = cmd + " machdep.cpu.cores_per_package"		temp = os.popen(cmd)		line = temp.readline()		cpusubtype = stripit(line)		cpuname = refCPU(cputype, cpusubtype)		if isIntel == 1:			if cpusubtype == "4":				line = temp.readline()				numcore = stripit(line)				cpucount = int(cpucount) / int(numcore)				cpucount = str(cpucount)		if noColor == 0:			coloredText = ""		output = output + " - CPU: " + coloredText + cpucount + " x " + cpuname	if includeCPUSpeed == 1:		temp = os.popen('sysctl hw.cpufrequency')		line = temp.readline()		line = line.split(':')		cpuspeed = trim(line[1])		cpuspeed = float(cpuspeed) / 1000000		if cpuspeed >= 1000:			cpuspeed = cpuspeed / 1000			if cpuspeed >= 1000:				cpuspeed = cpuspeed / 1000				cpuspeedprefix = "T"			else:				cpuspeedprefix = "G"			cpuspeed = round(cpuspeed, 2)		else:			cpuspeedprefix = "M"			cpuspeed = int(cpuspeed)		if noColor == 0:			coloredText = ""		output = output + " - Speed: " + coloredText + str(cpuspeed) + " " + cpuspeedprefix + "Hz"	if includeTemp == 1:		if noColor == 0:			coloredText = ""		if isIntel == 0:			if int(cpucount) < 2:				temp = os.popen('ioreg -n IOHWSensor | awk \'/location/ || /current-value/ || /\"type\"/\' | sed -e \'s/[^"]*\"//\' -e \'s/\" =//\' -e \'s/location//\' -e \'s/type//\' -e \'s/\"//g\' | awk \'{ d=($2/65536); if ($1==\"current-value\") print substr(d,1,7) \"\t\" ; if ($1!=\"current-value\") print $0 }\' | sed -e \'s/temperature/Celsius/\' -e \'s/voltage/volts/\' -e \'s/fanspeed/fan RPM/\' -e \'s/current/Amps/\' -e \'s/^temp$//\' -e \'s/ //\' | awk \'{ if ((NR % 3) == 0) print $0; else printf $0 \" \" }\' | grep CPU | grep Celsius')				temp = temp.readline()				temp = trim(temp)				if len(temp) > 1:					tempList = temp.split()					cpuTemp = tempList[0]					output = output + " - CPU Temp: " + coloredText + cpuTemp + "C"			else:				templist = os.popen('ioreg -n IOHWSensor | grep -B 3 AD1 | grep -o current-value.*')				cpunum = 1				templist = templist.readlines()				for x in templist:					if len(x) > 1:						temp = x.split(' = ')						temp = temp[1].strip()						cpuTemp = float(temp) / 10						cpuTemp = round(cpuTemp, 1)						output = output + " - CPU" + str(cpunum) + " Temp: " + coloredText+ str(cpuTemp) + "C"						cpunum = cpunum + 1			temp = os.popen('ioreg -n IOHWSensor | awk \'/location/ || /current-value/ || /\"type\"/\' | sed -e \'s/[^"]*\"//\' -e \'s/\" =//\' -e \'s/location//\' -e \'s/type//\' -e \'s/\"//g\' | awk \'{ d=($2/65536); if ($1==\"current-value\") print substr(d,1,7) \"\t\" ; if ($1!=\"current-value\") print $0 }\' | sed -e \'s/temperature/Celsius/\' -e \'s/voltage/volts/\' -e \'s/fanspeed/fan RPM/\' -e \'s/current/Amps/\' -e \'s/^temp$//\' -e \'s/ //\' | awk \'{ if ((NR % 3) == 0) print $0; else printf $0 \" \" }\' | grep GPU | grep Celsius')			temp = temp.readline()			temp = trim(temp)			if len(temp) > 1:				tempList = temp.split()				gpuTemp = float(tempList[0])				gpuTemp = round(gpuTemp,1)				output = output + " - GPU Temp: " + coloredText+ str(gpuTemp) + "C"		else:			temp = os.popen('sysctl kern.cpu_temp')			temp = temp.readline()			if len(temp) > 1:				cpuTemp = stripit(temp)				output = output + " - CPU Temp: " + coloredText + cpuTemp + "C"	if includeBattery == 1:		chargestate = ""		degtext = ""		timetext = ""		if noColor == 0:			coloredText = ""		if goBat == "Yes":			if isIntel != 1:				temp = batlist[6]				temp = temp.split('=')				temp = temp[1].split('}')				designCapacity = float(temp[0])			else:				temp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 DesignCapacity')				designCapacity = float(linevalue(temp))				if isCharged == "No":					temp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 IsCharging')					isCharging = linevalue(temp)					if isCharging == "Yes":						timetemp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 AvgTimeToFull')						chargestate = ""						timeTillWhat = "until full"					else:						timetemp = os.popen('ioreg -w 0 -n AppleSmartBattery | grep -m 1 AvgTimeToEmpty')						timeTillWhat = "Left"					temp = linevalue(timetemp)					timeRemaining = convertTime(temp,1)					timetext = "(" + timeRemaining + " " + timeTillWhat + ")"			if designCapacity != 0:				degredation = (designCapacity - batMaxCapacity) / designCapacity * 100				degredation = int(round(degredation,0))				degtext = "(" + str(degredation) + "% degraded)"			output = output + " - Battery: " + coloredText + batstate + " " + chargestate + timetext + " " + degtext		else:			output = output + " - Battery: " + coloredText+ "none"	else:		if goBat == "Yes":			if showDefault == 1:				output = output + " - Battery: " + coloredText + batstate	if includeMemory == 1:		temp = os.popen('vm_stat | grep -m 1 free | grep -o \:.*')		line = temp.readline()		tempf = trim(line)		tempf = int(tempf.strip('.'))		temp = os.popen('vm_stat | grep -m 1 active | grep -o \:.*')		line = temp.readline()		tempa = trim(line)		tempa = int(tempa.strip('.'))		temp = os.popen('vm_stat | grep -m 1 inactive | grep -o \:.*')		line = temp.readline()		tempi = trim(line)		tempi = int(tempi.strip('.'))		temp = os.popen('vm_stat | grep -m 1 wired | grep -o \:.*')		line = temp.readline()		tempw = trim(line)		tempw = int(tempw.strip('.'))		temp = os.popen('sysctl hw.memsize')		temp = temp.readline()		memnumber = float(stripit(temp))		if memnumber >= 1024:			memnumber = memnumber / 1024			if memnumber >= 1024:				memnumber = memnumber / 1024				if memnumber >= 1024:					memnumber = memnumber / 1024					if memnumber >= 1024:						memnumber = memnumber / 1024						if memnumber >= 1024:							memnumber = memnumber / 1024							memnumunit = "PB"						else:							memnumunit = "TB"					else:						memnumunit = "GB"				else:					memnumunit = "MB"			else:				memnumunit = "KB"		else:			memnumunit = "B"		memtotal = float(tempf + tempa + tempi + tempw) * 4096 / 1048576		freemem = float(tempf + tempi) * 4096 / 1048576		usedmem = memtotal - freemem		mempercent = (usedmem * 100) / memtotal		freebar = int(mempercent) / 10		if noColor != 0:			membar = "["		else:			membar = "[04"		barchar = "|"		for i in range(10):			if i == freebar:				if noColor == 0:					membar = membar + "14"				else:					barchar = "-"			membar = membar + barchar		membar = membar + "" + coloredText + "]"		if usedmem >= 1024:			usedmem = float(usedmem) / 1024			freeunit = "GB"			usedmem = round(usedmem,1)		else:			freeunit = "MB"			usedmem = int(round(usedmem,0))		memnumber = str(round(memnumber,2))		temp = memnumber.split('.')		if int(temp[1]) == 0:			memnumber = temp[0]		if noColor == 0:			coloredText = ""		output = output + " - RAM Usage: " + coloredText + str(usedmem) + " " + freeunit + " / " + str(memnumber) + " " + memnumunit + " " + membar	if includeHD == 1:		if noColor == 0:			coloredText = ""		temp = os.popen('df -lm | awk \'BEGIN {getline; while (getline temp > 0) { split(temp,a," "); total1 += a[4]; total2 += a[2] } }END {print total1,total2}\'')		line = temp.readline()		line = trim(line)		hdlist = line.split(' ')		hdfree = int(hdlist[0])		hdcapacity = int(hdlist[1])		if hdfree > 1048576:			hdfree = float(hdfree) / 1048576			hdfreeunit = "TB"		elif hdfree > 1024:			hdfree = float(hdfree) / 1024			hdfreeunit = "GB"		else:			hdfreeunit = "MB" 		hdfree = round(hdfree, 2)		if hdcapacity > 1048576:			hdcapacity = float(hdcapacity) / 1048576			hdcapacityunit = "TB"		elif hdcapacity > 1024:			hdcapacity = float(hdcapacity) / 1024			hdcapacityunit = "GB"		else:			hdcapacityunit = "MB"		hdcapacity = round(hdcapacity, 2)		output = output + " - Disk Space: " + coloredText + str(hdcapacity) + " " + hdcapacityunit + " with " + str(hdfree) + " " + hdfreeunit + " Free"	if includeResolution == 1:		temp = os.popen("system_profiler SPDisplaysDataType | grep Resolution")		templist = temp.readlines()		monitortotal = len(templist)		monitorindex = 1		for x in templist:			res = x.split(": ")			res = res[1]			res = res.split(" x ")			width = res[0]			height = res[1].strip()			if monitortotal > 1:				monitorcount = " " + str(monitorindex)				monitorindex = monitorindex + 1			else:				monitorcount = ""			if noColor == 0:				coloredText = ""			output = output + " - Resolution" + monitorcount + ": " + coloredText + width + "x" + height	if includeOS == 1:		if noColor == 0:			coloredText = ""		temp = os.popen('sw_vers')		line = temp.readline()		osname = line.split(':')		osname = trim(osname[1])		line = temp.readline()		osversion = line.split(':')		osversion = trim(osversion[1])		line = temp.readline()		osbuild = line.split(':')		osbuild = trim(osbuild[1])		output = output + " - Running: " + coloredText + osname + " " + osversion + " (" + osbuild + ")"	if includeProcessCount == 1:		if noColor == 0:			coloredText = ""		temp = os.popen('ps -ax | wc -l')		line = temp.readline()		processCount = trim(line)		output = output + " - Processes: " + coloredText + str(processCount)	if includeUptime == 1:		temp = os.popen('uptime | grep up')		uptime = temp.readline()		uptime = trim(uptime)		output = output + " - Uptime: " + uptime	if silentMode == 1:		xchat.prnt("04<Silent Mode> " + output)	else:		xchat.command("SAY " + output)	os.system('rm -rf temp.info')		def getTunes (args):	global includeColor	outColor = 7	goFull = 0	goiTunes = 1	goRealplayer = 0	includeArtist = 1	includeYear = 0	includeBitrate = 0	includeCount = 0	includeRating = 0	includeTime = 0	includeKind = 0	streamBypass = 0	includeURL = 0	includeLib = 0	silentMode = 0	addons = ""	allGood = 0	cmd = 'osascript -e "tell application \\"iTunes\\" to return podcast of current track & \\"|\\" & player state & \\"|\\" & kind of current track & \\"|\\" & current stream title & \\"|\\" & name of current track & \\"|\\" & artist of current track & \\"|\\" & album of current track & \\"|\\" & bit rate of current track'	argIndex = 8	yearIndex = 0	countIndex = 0	ratingIndex = 0	timeIndex = 0	libIndex = 0	noColor = 0	boldText = ""		arglength = len(args)	if arglength > 1:		i = 1		while i < arglength:			temp = args[i]			if temp == "real":				goiTunes = 0				goRealplayer = 1			if temp == "year":				includeYear = 1			if temp == "bitrate":				includeBitrate = 1			if temp == "count":				includeCount = 1			if temp == "rating":				includeRating = 1			if temp == "time":				includeTime = 1			if temp == "kind":				includeKind = 1			if temp == "url":				includeURL = 1			if temp == "lib":				includeLib = 1			if temp == "full":				includeYear = 1				includeBitrate = 1				includeCount = 1				includeRating = 1				includeTime = 1				includeKind = 1				includeURL = 1				includeLib = 1			if temp.isdigit():				if int(temp) >= 0 and int(temp) <= 15:					outColor = temp			if temp == "nocolor":				noColor = 1			if temp == "silent":				silentMode = 1			i = i + 1# IMPORTANT: This section MUST be in CORRECT ORDER, as it assigns index values		if includeYear == 1:			cmd = cmd + '& \\"|\\" & year of current track'			yearIndex = argIndex			argIndex = argIndex + 1		if includeCount == 1:			cmd = cmd + '& \\"|\\" & played count of current track'			countIndex = argIndex			argIndex = argIndex + 1		if includeRating == 1:			cmd = cmd + '& \\"|\\" & rating of current track'			ratingIndex = argIndex			argIndex = argIndex + 1		if includeTime == 1:			cmd = cmd + '& \\"|\\" & player position & \\"|\\" & time of current track'			timeIndex = argIndex			lengthIndex = argIndex + 1			argIndex = argIndex + 2	cmd = cmd + '"'	if noColor == 1:		boldText = ""						if goiTunes == 1:		if checkitunes(1) < 1:			print "ATTENTION: iTunes is not running!"		else:			temp = os.popen(cmd)			line = temp.readline()			line = trim(line)			tuneList = line.split(', |, ')			if len(tuneList) < 2:				print "ATTENTION: Nothing is currently playing in iTunes!"			else:				temp = tuneList[0]				if temp == "true":					playerStatus = "Podcast"				else:					playerStatus = tuneList[1]					playerStatus = playerStatus.capitalize()				fileType = tuneList[2]				title = tuneList[4]				artist = tuneList[5]				if fileType.find("stream") != -1 or fileType == "missing value":					includeBitrate = 1					streamBypass = 1					playerStatus = "Streaming"					streamName = tuneList[3]					if len(artist) < 1 or artist == "missing value":						includeArtist = 0						server = title						addons = "- " + boldText + "Server: " + server					title = streamName					if title == "missing value":						title = "Untitled"				album = tuneList[6]				if includeArtist == 1:					if len(artist) > 0 and artist != "missing value":						addons = "- " + boldText + "Artist: " +artist				if len(album) > 0 and album != "missing value":					addons = addons + " - " + boldText + "Album: " + album				if includeYear == 1:					year = tuneList[yearIndex]					if year != "missing value" and year != "0":						addons = addons + " - " + boldText + "Year: " + year				if includeBitrate == 1:					bitrate = tuneList[7]					if bitrate != "missing value" and bitrate != "0":						addons = addons + " - " + boldText + "Bitrate: " + bitrate + " kb/s"				if includeCount == 1:					count = tuneList[countIndex]					if count != "missing value":						addons = addons + " - " + boldText + "Play Count: " + count				if includeRating == 1:					if noColor == 0:						ratingBar = "[03"					else:						ratingBar = "["					rating = tuneList[ratingIndex]					if rating == "missing value":						rating = 0					else:						rating = int(rating) / 20					barchar = "|"					for x in range(5):						if x == rating:							if noColor == 0:								ratingBar = ratingBar + "14"							else:								barchar = "-"						ratingBar = ratingBar + barchar					ratingBar = ratingBar + "]"					addons = addons + " - " + boldText + "Rating: " + ratingBar				if includeTime == 1:					elapsed = tuneList[timeIndex]					elapsed = convertTime(elapsed, 1)					totalTime = tuneList[lengthIndex]					addons = addons + " - " + boldText + "Elapsed: " + elapsed					if totalTime != "missing value":						addons = addons + " / " + totalTime				if includeKind == 1:					if streamBypass != 1:						if fileType != "missing value":							addons = addons + " - " + boldText + "Kind: " + fileType				if includeLib == 1:					addons = addons + " - " + boldText + "Playlist: " + getTuneLibSize(1)				if includeURL == 1:					if fileType.find("stream") != -1 or fileType == "missing value":						temp = os.popen('osascript -e "tell application \\"itunes\\" to return address of current track"')						temp = temp.readline()						url = trim(temp)						if url.find("pri.kts-af.net") == -1:							addons = addons + " - " + boldText + "URL: " + url				allGood = 1	else:		if checkRealplayer(1) < 1:			print "ATTENTION: RealPlayer is not running!"		else:			temp = os.popen('osascript -e "tell application \\"RealPlayer\\" to return state of window 1 & \\"|\\" & URL of window 1 & \\"|\\" & clip title of window 1 & \\"|\\" & encoded bitrate of window 1 & \\"|\\" & clip position of window 1 & \\"|\\" & clip length of window 1 & \\"|\\" & original clip size of window 1"')			line = temp.readline()			line = trim(line)			tuneList = line.split(', |, ')			playerStatus = tuneList[0]			playerStatus = playerStatus.capitalize()			duration = tuneList[5]			if float(duration) < 0:				includeDuration = 0				if playerStatus == "Playing":					playerStatus = "Streaming"			else:				includeDuration = 1				duration = convertTime(duration, 1)			title = tuneList[2]			title = title.capitalize()			if includeBitrate == 1 or goFull == 1:				bitrate = tuneList[3]				bitrate = float(bitrate) / 1000				bitrate = int(bitrate)				if bitrate > 0:					addons = addons + " - " + boldText + "Bitrate: " + str(bitrate) + " kb/s"			if includeTime == 1 or goFull == 1:				elapsed = tuneList[timeIndex]				elapsed = convertTime(elapsed, 1)				addons = addons + " - " + boldText + "Elapsed: " + elapsed				if includeDuration == 1:					addons = addons + " / " + duration			if includeURL == 1 or goFull == 1:				url = tuneList[1]				if includeDuration != 1:					addons = addons + " - " + boldText + "URL: " + url			allGood = 1	if allGood == 1:		output = ""		if noColor == 0:			output = "" + str(outColor)		output = output + "{" + playerStatus+ "} \"" + title + "\" " + addons		if silentMode == 1:			xchat.prnt("04<Silent Mode> " + output)		else:			xchat.command("SAY " + output)def getMovies (args):	global includeColor	outColor = 7	goFull = 0	includeResolution = 0	includeTime = 0	noColor = 0	silentMode = 0	output = ""	boldText=""		if checkQuicktime(1) < 1:		print "ATTENTION: QuickTime is not currently running!"	else:		arglength = len(args)		if arglength > 1:			i = 1			while i < arglength:				temp = args[i]				if temp == "res" or temp == "full":					includeResolution = 1				if temp == "time" or temp == "full":					includeTime = 1				if temp.isdigit():						if int(temp) >= 0 and int(temp) <= 15:							outColor = temp				if temp == "nocolor":					noColor = 1				if temp == "silent":					silentMode = 1				i = i + 1		if noColor == 1:			boldText = ""					temp = os.popen('osascript -e "tell application \\"QuickTime Player\\" to return live stream of movie 1 & \\"|\\" & playing of movie 1 & \\"|\\" & name of movie 1 & \\"|\\" & duration of movie 1 & \\"|\\" & current time of movie 1 & \\\"|\\" & time scale of movie 1 & \\"|\\" & natural dimensions of movie 1"')		temp = temp.readline()		temp = trim(temp)		movieList = temp.split(', |, ')		if len(movieList) < 2:			print "ATTENTION: No movie is loaded in QuickTime!"		else:			isStream = movieList[0]			isPlaying = movieList[1]			if isStream == "true":				playerStatus = "Streaming"			elif isPlaying == "true":				playerStatus = "Watching"			else:				playerStatus = "Stopped"			title = movieList[2]			title = title.strip('\x00')			if noColor == 0:				output = "" + str(outColor)			output = output + "{" + playerStatus + "} \"" + title + "\""			if includeResolution == 1 or goFull == 1:				temp = movieList[6]				dimensions = temp.split(', ')				dimensionX = dimensions[0]				dimensionY = dimensions[1]				if dimensionX != "0" or dimensionY != "0":					output = output + " - " + boldText + "Resolution: " + dimensionX + " x " + dimensionY			totalTime = movieList[3]			scale = movieList[5]			totalTime = convertTime(totalTime, scale)			if includeTime == 1 or goFull == 1:				elapsed = movieList[4]				elapsed = convertTime(elapsed, scale)				output = output + " - " + boldText + "Elapsed: " + elapsed + " / " + totalTime			else:				output = output + " - " + boldText + "Duration: " + totalTime			if silentMode == 1:				xchat.prnt("04<Silent Mode> " + output)			else:				xchat.command("SAY " + output)			def getTuneLibSize(bleh):	unit = "B"	temp = os.popen('osascript -e "tell application \\"iTunes\\" to return name of current playlist & \\"|\\" & size of current playlist"')	temp = temp.readline()	temp = trim(temp)	temp = temp.split('|')	libName = temp[0]	output = "\"" + libName + "\"" 	libSize = temp[1]	if libSize != "missing value":		libSize = float(libSize)		if libSize > 1024:			libSize = libSize / 1024			if libSize > 1024:				libSize = libSize / 1024				if libSize > 1024:					libSize = libSize / 1024					if libSize > 1024:						libSize = libSize / 1024						unit = "TB"					else:						unit = "GB"				else:					unit = "MB"			else:				unit = "KB"		libSize = round(libSize,2)		output = output + " @ " + str(libSize) + " " + unit	return outputdef checkChannelModes (word, word_eol, userdata):    global includeColor    modes = word[1]    if modes.find('c') != -1:        includeColor = 0    else:        includeColor = 1    return xchat.EAT_XCHAT    def checkitunes (bleh):	temp = os.popen('ps -cx | grep -c iTunes')	itunecount = temp.readline()	itunecount = int(trim(itunecount))	if itunecount > 0:		temp = os.popen('ps -cx iTunesHelper| grep -c iTunesHelper')		temp = temp.readline()		temp = int(trim(temp))		itunecount = itunecount - temp	return itunecount	# Returns 0 if both folders have write permissions# Returns 1 if the X-Chat Aqua directory does not have write permissions# Returns 2 if the Plugins directory does not write permissionsdef checkPermissions (bleh):	test = os.popen('ls -dl ./')	temp = test.readline()	temp = temp.split()	results = 0	apppermission = temp[0]	if apppermission.find("drw") == -1:		results = 1	else:		test = os.popen('ls -dl Plugins')		temp = test.readline()		temp = temp.split()		pluginpermission = temp[0]		if pluginpermission.find("drw") == -1:			results = 2	return results			def checkQuicktime (bleh):	temp = os.popen('ps -cx | grep -c QuickTime\ Player')	quicktimeCount = temp.readline()	quicktimeCount = int(trim(quicktimeCount))	return quicktimeCount	def checkRealplayer (args):	temp = os.popen('ps -cx | grep -c RealPlayer')	realplayerCount = temp.readline()	realplayerCount = int(trim(realplayerCount))	return realplayerCount	def checkUpdate (args):	latestVersion = getVersion(1)	if str(__module_version__) != str(latestVersion):		return 1	else:		return 0	def convertTime (time, scale):	theTime = ""	hr = 0	mins = 0	totaltime = float(time) / float(scale)	if totaltime > 60:		totaltime = totaltime / 60.0		if totaltime > 60:			totaltime = totaltime / 60.0			hr = int(totaltime)			theTime = str(hr) + ":"			totaltime = (totaltime % 1) * 60		mins = int(totaltime)		if hr > 0:			mins = "%02i" % (mins)		totaltime = (totaltime % 1) * 60	sec = copy.copy(totaltime)	sec = "%02i" % (sec)	theTime = str(theTime) + str(mins) + ":" + str(sec)	return theTimedef domacversion (word, word_eol, userdata):	printmacversion(1)	return xchat.EAT_ALLdef domacinfo (word, word_eol, userdata):	getinfo(word)	return xchat.EAT_ALL	def domacmovie (word, word_eol, userdata):	getMovies(word)	return xchat.EAT_ALL	def domactunes (word, word_eol, userdata):	getTunes(word)	return xchat.EAT_ALL	def domacupdate (word, word_eol, userdata):	if checkPermissions(1) == 1:		print "ATTENTION: You need write permissions for your X-Chat Aqua folder. Navigate to the folder in Finder, go to File -> Get Info, and set 'You can' to 'Read & Write'. Update cancelled."	elif checkPermissions(1) == 2:		print "ATTENTION: You need write permissions for your Plugins folder. Navigate to the folder in Finder, go to File -> Get Info, and set 'You can' to 'Read & Write'. Update cancelled."	else:		latestVersion = getVersion(1)		if checkUpdate(1) == 1:			print "08You have aVirtualInferno version " + __module_version__ + ". The latest version is " + latestVersion + ". Now updating..."			try:				os.system('curl -s -B http://oven.virtualinferno.net/avirtualinferno2.zip -o avirtualinferno2.zip')				os.system('unzip -o -qq avirtualinferno2.zip -d aviunzipped')				os.system('cp -f aviunzipped/avirtualinferno2.pkg/Contents/Archive.pax.gz aviunzipped')				os.system('gunzip -f -q aviunzipped/Archive.pax')				os.system('pax -r < aviunzipped/Archive.pax')				os.system('rm ' + xchatdir + '/avirtualinferno.py')				os.system('mv avirtualinferno.py ' + xchatdir + '/avirtualinferno.py')				xchat.command('PY LOAD avirtualinferno.py')			except:				print "An error has occurred trying to install the update. Please try again later."			os.system('rm -rf aviunzipped')			os.system('rm avirtualinferno2.zip')		else:			print "03aVirtualInferno version " + __module_version__ + " is already up-to-date."	return xchat.EAT_ALL# This method works for US zipcodes only	def domacweather (word, word_eol, userdata):	global includeColor	location = ""	cityname = ""	postalcode = ""	spacer = ""	output = ""	tempinfo = ""	boldText = ""	goFull = 0	includePressure = 0	includeHumidity = 0	includeWind = 0	isGood = 1	feedFound = 0	cityFound = 0	notUS = 0	weatherFound = 0	noColor = 0	silentMode = 0		arglength = len(word)	if arglength > 1:		i = 1		while i < arglength:			arg = word[i]			arg = arg.strip(',')			if arg.isalpha() == 0:				if arg.isdigit() == 0:					if len(arg) == 3:						if i < (arglength - 1):							arg2 = word[i+1]							if arg2.isalpha() == 0:								if arg2.isdigit() == 0:									if len(arg2) == 3:										postalcode = arg + "_" + arg2				else:					postalcode = arg			else:				if arg == "full":					goFull = 1				elif arg == "pressure":					includePressure = 1				elif arg == "humidity":					includeHumidity = 1				elif arg == "wind":					includeWind = 1				elif arg == "nocolor":					noColor = 1				elif arg == "silent":					silentMode = 1				else:					if spacer == "":						if len(cityname) > 0:							spacer = "_"					cityname = cityname + spacer + arg			i = i + 1		if len(postalcode) < 1:			if len(cityname) < 1:				isGood = 0			else:				location = cityname		else:			if postalcode == "":				isGood = 0			else:				location = postalcode	if noColor == 1:		boldText = ""	if isGood == 0:		print "ERROR: No location specified!"	else:				url = "http://www.wunderground.com/auto/rss_full/" + location		cmd = "curl " + url		temp = os.popen(cmd)		lines = temp.readlines()		for line in lines:			if feedFound == 0:				if line.find("Weather Underground RSS Feed") != -1:					feedFound = 1					if len(line) <= 58:						notUS = 1					else:						temp = line.split("for ")						temp = temp[1]						temp = temp.split('<')						city = temp[0]						cityFound = 1			else:				if cityFound == 0:					if line.find("<title>") != -1:						if line.find("Conditions") != -1:							cityFound =1							temp = line.split(" Current")							temp = temp[0]							temp = temp.split('>')							city = temp[1]				if weatherFound == 0:					if line.find("<description>") != -1:						weatherFound = 1						weatherList = line.split(" | ")						temp = weatherList[0]						temp = stripit(temp)						temperature = temp.split('&#176;')						temp1 = temperature[0]						temp = temperature[1]						temp = temp.split(" / ")						temp1Unit = temp[0]						tempinfo = temp1 + temp1Unit						if len(temp) > 1:							temp2 = temp[1]							temp2Unit = temperature[2]							tempinfo = tempinfo + " (" + temp2 + temp2Unit + ")"						temp = weatherList[3]						if temp.find(':') == -1:							temp = temp.split('Conditions ')						else:							temp = temp.split('Conditions: ')						if len(temp) > 1:							conditions = temp[1]							if len(conditions) < 1:								conditions = "Unavailable"						else:							conditions = "Unavailable"						if includeHumidity == 1 or goFull == 1:							temp = weatherList[1]							humidity = stripit(temp)							output = output + " - Humidity: " + boldText + humidity						if includePressure == 1 or goFull == 1:							temp = weatherList[2]							temp = stripit(temp)							temp = temp.split(" / ")							pressure1 = temp[0]							if len(pressure1) > 3:								output = output + " - Pressure: " + boldText + pressure1							if len(temp) > 1:								pressure2 = temp[1].strip()								if len(pressure2) > 3:									output = output + " (" + pressure2 + ")"						if includeWind == 1 or goFull == 1:							temp = weatherList[4]							direction = stripit(temp)							temp = weatherList[5]							temp = stripit(temp)							speed = temp.split(" / ")							speed1 = speed[0]							if speed1.isdigit() == 1:								speed1 = speed1 + "mph"							output = output + " - Wind: " + boldText + direction + " @ " + speed1							if len(speed) > 1:								speed2 = speed[1].split('<')								speed2 = speed2[0]								output = output + " (" + speed2 + ")"									if weatherFound == 0:			print "ERROR: No weather data available for that location!"		else:			saytext = "Weather for " + boldText + city + " - Current Weather: " + boldText + conditions + " - Temperature: " + boldText + tempinfo + output 			if silentMode == 1:				xchat.prnt("04<Silent Mode> " + saytext)			else:				xchat.command("SAY " + saytext)	return xchat.EAT_ALLdef doNotPrintCreation(word, word_eol, userdata):    return xchat.EAT_XCHAT    def getUpdate (args):	print xchatdir	def getVersion (args):	temp = os.popen('curl -s http://oven.virtualinferno.net/macversion')	temp = temp.readline()	latestVersion = trim(temp)	return latestVersion	def printmacversion (args):	print "07=====aVirtualInferno version " + __module_version__ +"====="	def refCPU (cputype, cpusubtype):	cput = int(cputype)	cpust = int(cpusubtype)	if cput == 7:		make = "Intel"		if cpust == 12: model = "Xeon"		elif cpust == 11: model = "Itanium"		elif cpust == 10: model = "Pentium 4"		elif cpust == 9: model = "Pentium M"		elif cpust == 8: model = "Pentium 3"		elif cpust == 7: model = "Celeron"		elif cpust == 6: model = "Pentium II"		elif cpust == 5: model = "Pentium"		elif cpust == 4:			temp = os.popen('sysctl hw.cpufamily machdep.cpu.cores_per_package')			cpufamily = temp.readline()			cpufamily = stripit(cpufamily)			if cpufamily == "1114597871": family = "Core 2"			elif cpufamily == "1943433984": family = "Core"			else: family = ""			count = temp.readline()			count = stripit(count)			if count == "2": model = family + " Duo"			elif count == "1": model = family + " Solo"			else: model = "486 Compatible"		elif cpust == 3: model = "386 Compatible"		else: model = "Processor"	elif cput == 18:		make = "PowerPC"		if cpust == 100: model = "G5"		elif cpust == 11: model = "G4"		elif cpust == 10: model = "G4"		elif cpust == 9: model = "G3"		elif cpust == 8: model = "620"		elif cpust == 7: model = "604e"		elif cpust == 6: model = "604"		elif cpust == 5: model = "603ev"		elif cpust == 4: model = "603e"		elif cpust == 3: model = "603"		elif cpust == 2: model = "602"		elif cpust == 1: model = "601"		else: model = "Processor"	else:		make = "Unknown"		model = "Processor"	return make + " " + model# The following section is used for adding updated modelsdef refMachineType (name):	if name == "MacBook2,1": machine = "MacBook"	elif name == "MacBookPro2,1": machine = "MacBookPro17"	elif name == "MacBookPro2,2": machine = "MacBookPro15"	elif name == "MacBookPro3,1": machine = "MacBookPro15"	elif name == "MacBookPro3,2": machine = "MacBookPro17"	elif name == "AppleTV1,1": machine = "AppleTV"	elif name == "iMac7,1": machine = "iMac"	else: machine = "Mac"	return machine	def refModel (name):	if name == "Mac": model = "Mac"	elif name == "Xserve": model = "Xserve"	elif name == "XserveG5": model = "Xserve G5"	elif name == "Macmini": model = "Mac mini"	elif name == "eMac": model = "eMac"	elif name == "iMac": model = "iMac"	elif name == "iMacG5": model = "iMac G5"	elif name == "PowerMacG3": model = "Power Macintosh G3"	elif name == "PowerMacG3Series": model = "Power Macintosh G3 Series"	elif name == "PowerMacG3PCI": model = "Power Mac G3 (PCI graphics)"	elif name == "PowerMacG4AGP": model = "Power Mac G4 (AGP graphics)"	elif name == "PowerMacG4": model = "Power Mac G4"	elif name == "PowerMacG4Cube": model = "Power Mac G4 Cube"	elif name == "PowerMacG5": model = "Power Mac G5"	elif name == "MacPro": model = "Mac Pro"	elif name == "iBook": model = "iBook"	elif name == "iBookG4": model = "iBook G4"	elif name == "PowerBookG3Series": model = "PowerBook G3 Series"	elif name == "PowerBook": model = "PowerBook"	elif name == "PowerBookG4": model = "PowerBook G4"	elif name == "PowerBookG415": model = "PowerBook G4 15\""	elif name == "PowerBookG417": model = "PowerBook G4 17\""	elif name == "PowerBookG412": model = "PowerBook G4 12\""	elif name == "MacBookPro15": model = "MacBook Pro 15\""	elif name == "MacBookPro17": model = "MacBook Pro 17\""	elif name == "MacBook": model = "MacBook"	elif name == "AppleTV": model = "Apple TV"	else: model = name	return model#def stripit (line):#	temp = line.split(':')#	temp = trim(temp[1])#	return tempdef linevalue(line):	temp = line.readline()	if len(temp) > 0:		temp = temp.split('=')		temp = temp[1]		temp = trim(temp)	return temp	def stripit (line):	temp = line.split(':')	temp = temp[1].strip('\n')	temp = temp.strip()	return temp		def trim (line):	temp = line.strip(':')	temp = temp.strip('\n')	temp = temp.strip()	temp = temp.strip("| |           \"")	temp = temp.strip('\"')	return temp		printmacversion(1)	# X-Chat Aqua Hooksxchat.hook_command("macversion", domacversion, help="/macversion - Displays plugin version.")xchat.hook_command('macinfo', domacinfo, help="/macinfo - Displays Macintosh info. Arguments (do not include quotes): 07'silent'-restricts command output to local display only. 07'full'-output the info from the flags below. 07'cpu'-include the CPU count and CPU type. 07'speed'-include the CPU(s) speed. 07'temp'-include the CPU and GPU temp (if possible). 07'ram'-include the RAM usage information. 07'hd'-include storage capacity information, 'os'-include operating system version information. 07'process'-include the running process count. 07'res'-includes the resolution for all displays connected. 07'uptime'-include the system uptime")xchat.hook_command('macmovie', domacmovie, help="/macmovie - Displays information about currently playing window in QuickTime. Arguments (do not include quotes): 07'silent'-restricts command output to local display only. 07'full'-output the info from the flags below. 07'#'-output the info in the MIRC color of your choice. 07'res'-include the resolution of the foreground movie. 07'time'-include the elapsed and total time of the foreground movie.")xchat.hook_command('mactunes', domactunes, help="/mactunes - Displays information about currently playing item in iTunes (default) or RealPlayer. Arguments (do not include quotes): 07'silent'-restricts command output to local display only. 07'#'-output the info in the MIRC color of your choice. 07'real'- Output RealPlayer information instead of iTunes. 07'full'-output the info from the flags below. 07'bitrate'-includes the bitrate of the current item. 07'count'-includes the play count of the currently playing item. 07'rating'-include the rating of the current playing item. 07'time'-includes the current time position and duration (if possible). 07'length'-includes just the duration of the current item. 07'year'-includes the year of the currently playing item, 'url'-includes the URL of the currently playing item, if the item is a stream.")xchat.hook_command('macupdate', domacupdate, help="/macupdate - Checks latest version")xchat.hook_command('macweather', domacweather, help="/macweather POSTAL CODE or CITY - Displays the current weather conditions for a given city. Arguments (do not include quotes): 07'silent'-restricts command output to local display only. 07'full'-output the info from the flags below. 07'humidity'-includes the humidity percentage. 07'pressure'-includes atmospheric pressure information. 07'wind'-includes windspeed and directional information")