All pastes #626436 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-19 17:37 UTC
rendered paste body
dimport xchat,os,copy,re
#
# This script is based on the M[OSX]S script, written in TCL for 10.4
# compatibility, then converted to Python.
# 
# Scroll down for configuration options
#
# Compatibility note: The /macinfo command is compatible with 10.4 and above
#
# Weather information courtesy Weather Underground
#
# Changelog:
#  Version 7      : added PPC compatability
#  Version 7.1p   : fixes for 10.4.8, other minor fixes, speed improvements - prasys
#  Version 7.2j   : minor fixes, speed improvements, better CPU detection, better CPU detection,
#                   added CPU feature detection, added kernel version to OS info, added config 
#                   options, changed /macupdate to use new server. - Joey
#  Version 7.2.1  : better support for real Macs, dual core machines, dual processors, etc. also
#                   fixes a bug for CPUs under 1GHz. - Joey
#  Version 7.2.1a : fixes a minor bug in computer detection.
#  Version 7.2.1b : fixes more bugs
#  Version 7.2.2  : fixes bug that shows 2x CPUs on HTT CPUs, displays "AMD64" instead of "EM64T"
#                   for 64-bit AMD CPUs, adds configuation options so that users can change what
#                   gets displayed with /macinfo by default
#  Version 7.2.2a : changes text colour from black to "no colour"
#  Version 7.2.2b : fixes 7.2.2a
#  Version 7.2.2c : fixes 7.2.2 bug on non-HTT CPUs
#  Version 7.3    : fixes battery info for 8.8.1 kernel [10.4.8], adds 'machine' argument, changes
#                   RAM output slightly with ideas from GivemHell, fixes typo in /mactunes full as
#                   well as changing the output slightly, added video driver detection, added more
#                   kernel info, fixed colour output so it looks right in other clients
#  Version 7.4    : changes PPC detection to the CPU rather than the machine, adds network
#                   information, added FSB detection
#
# Todo List:
# Fix client display
# Add config in client, rather than in script
#
# Usage: /macinfo displays your system information
#			 Arguments (do not include quotes)
#					'#' will output the info in the MIRC color of your choice
#					'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)
#					'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
#                                       'machine' will just output the machine name
#        /mactunes <args> will display iTunes (default) or RealPlayer info
#            Arguments (do not include quotes)
#                   '#' will output the info in the MIRC color of your choice
#					'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
#                   '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)
#                   '#' will output the info in the color of your choice
#                   '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 <ZIP> <args> will display weather info for a US zipcode
#			Arguments (do not include quotes)
#					'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

# The following lines are for configuration. Please change them to suit your needs.

# Change this value to make it so you don't have to type your zip code every time you use
# /macweather
__config_default_zip__ = "14607"
# This decides whether /macinfo shows OS info by default
__config_show_OS__ = 1
# This decides whether /macinfo shows CPU info by default
__config_show_CPU__ = 1
# This decides whether /macinfo shows CPU Speed by default
__config_show_CPUSpeed__ = 1
# This decides whether /macinfo shows Memory info by default
__config_show_memory__ = 1
# This decides whether /macinfo shows Hard Drive info by default
__config_show_hd__ = 1
# This decides whether /macinfo shows Process Count by default
__config_show_processCount__ = 0
# This decides whether /macinfo shows Uptime by default
__config_show_uptime__ = 1
# This decides whether /macinfo shows Graphics info by default
__config_show_resolution__ = 1
# This decides whether /macinfo shows Temp info by default [Note: You need tempurature drivers for this to work]
__config_show_temp__ = 0
# This decides whether /macinfo shows Battery info by default
__config_show_battery__ = 0
# This decides whether /macinfo shows Date info by default
__config_show_date__ = 0
# This decides whether /macinfo shows extended kernel information [build, date] by default
__config_show_kernel__ = 0
# This decides whether /macinfo shows Client info by default [Note: This currently shows the base X-Chat Aqua version,
#                                                                   not the X-Chat Aqua version.
__config_show_client__ = 0
# This decides whether /macinfo shows network information by default
__config_show_network__ = 1
# This is your used Network Interface, eg. en0, en1...
__config_net_interface__ = "en0"

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# DO NOT CHANGE ANYTHING BELOW THIS LINE. YOU MAY BREAK FUNCTIONALITY IF YOU DO.
# Edit at your own risk.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# About this plugin
__module_name__ = "XInfoAqua"
__module_version__ = "7.4"
__module_long_version__ = "11=====XInfoAqua version " + __module_version__ +"====="
__module_authors__ = "11Authored by: Spaz, Illuminati, Prasys, and Joey"
__module_description__ = "Mac system info and media output"
__module_website__ = "http://www.n-lp.com/~osx/"
__module_filename__ = "XInfoAqua"

# Global Variables
xchatdir = xchat.get_info("xchatdir")
t_bold=chr(2)
t_normal=chr(15)
#t_normal=chr(15)+chr(3)+"09"
t_machine=chr(3)+"03"
#t_blue=chr(3)+"02"
outColor="04"
#t_red=chr(3)+"04"

#t_white=chr(3)+"00"
#t_black=chr(3)+"01"
#t_dk_blue=chr(3)+"02"
#t_maroon=chr(3)+"05"
#t_purple=chr(3)+"06"
#t_orange=chr(3)+"07"
#t_yellow=chr(3)+"08"
#t_lt_green=chr(3)+"09"
#t_teal=chr(3)+"10"
#t_cyan=chr(3)+"11"
#t_fuchsia=chr(3)+"13"
#t_dk_gray=chr(3)+"14"
#t_lt_gray=chr(3)+"15"

updatespaz=0

def getinfo (args):
#	t_green=chr(3)+"03"
#	t_blue=chr(3)+"12"
#	t_purple=chr(3)+"06"
#	t_yellow=chr(3)+"12"
#	t_green=t_normal
#	chr(3)+outColor=t_normal
#	t_purple=t_normal
#	t_red=t_normal
	t_bold=chr(2)
	outColor="04"
	
	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
	includeHD = 0 # Set to 1 to always include hard drive information
	includeProcessCount = 0
	includeUptime = 0
	includeResolution = 0
	includeBattery=0
	includeDate=0
	includeClient=0
	includeMemoryBar=0
	includeMachine=0
	includeKernel=0
	includeNetwork=0
	cpucount = 0
	isIntel = 0
	output = ""
	dataTypes = "SPHardwareDataType"
	mac_name = ""
	
	arglength = len(args)
	if arglength > 1:
		i = 1
		while i < arglength:
			temp = args[i]
			if temp.isdigit():
				if int(temp) >= 0 and int(temp) <= 15:
					outColor = temp
			if temp == "bw":
				t_bold=chr(2)
			if temp == "spaz":
				updatespaz=1
			if temp == "os" or temp == "full":
				includeOS = 1
				includeKernel = 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
				includeMemoryBar = 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 == "battery" or temp == "full":
				includeBattery = 1
			if temp == "date" or temp == "full":
				includeDate = 1
			if temp == "client" or temp == "full":
				includeClient = 1
			if temp == "full":
				includeMemoryBar = 0
			if temp == "machine":
				includeMachine = 1
			if temp == "kernel" or temp == "os":
				includeKernel = 1
				includeOS = 1
			if temp == "network" or temp == "net" or temp == "full":
				includeNetwork=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 includeMachine==0:
													if includeKernel==0:
														if includeNetwork==0:
															showDefault = 1
	else:
		showDefault = 1
	t_bold=t_bold+chr(3)+outColor
		
	if showDefault == 1:
		includeOS = __config_show_OS__
		includeCPU = __config_show_CPU__
		includeCPUSpeed = __config_show_CPUSpeed__
		includeMemory = __config_show_memory__
		includeHD = __config_show_hd__
		includeProcessCount = __config_show_processCount__
		includeUptime = __config_show_uptime__
		includeResolution = __config_show_resolution__
		includeTemp = __config_show_temp__
		includeBattery = __config_show_battery__
		includeDate = __config_show_date__
		includeClient = __config_show_client__
		includeKernel = __config_show_kernel__
		includeNetwork = __config_show_network__
		
	temp = os.popen('sysctl hw.model')
	temp = temp.readline()
	temp = stripit(temp)
	compmodel = temp
	if compmodel == 'ACPI':
		compmodel = "ADP2,1"
	cmd = "cat /System/Library/SystemProfiler/SPPlatformReporter.spreporter/Contents/Resources/SPMachineTypes.plist | grep -A 1 \"" + compmodel + "\""
	temp = os.popen(cmd)
	junk = temp.readline()
	temp = temp.readline()
	machine="jHac"
	if temp!='':
		temp = temp.split('>')
		temp = temp[1]
		temp = temp.split('<')
		temp = temp[0]
		if trim(temp)!='':
			if trim(temp)!='Apple Development Platform':
				machine=refModel(temp)
	if includeMachine==1:
		machine = "Machine: " + t_normal + machine
	#output = t_normal + chr(3)+outColor + machine
	output = t_bold + t_machine + machine + t_normal
	

	temp = os.popen('sysctl hw.cputype')
	temp = temp.readline()
	cputype = stripit(temp)
	if cputype == "7":
		isIntel = 1
	if includeCPU == 1:
		temp = os.popen('sysctl hw.ncpu')
		line = temp.readline()
		cpucount = int(stripit(line))
		if isIntel == 1:
			temp = os.popen('sysctl machdep.cpu.cores_per_package')
			temp = temp.readline()
			corecount = int(stripit(temp))
			temp=os.popen('sysctl machdep.cpu.logical_per_package')
			temp=temp.readline()
			cpuHT=int(stripit(temp))
			if corecount!=0:
				cpucount = cpucount / corecount
			if cpuHT!=0:
				cpucount = cpucount / int(cpuHT)

			temp = os.popen('sysctl machdep.cpu.brand_string')
			temp = temp.readline()
			temp = stripit(temp)
			cpu = stripmarks(temp)
			cpu = stripspaces(cpu)
		else:
			temp = os.popen("sysctl hw.model")
			line=temp.readline()
			mac_type=stripit(line)
			#if (mac_type=="ADP2,1"):  mac_name = "Developer Transition Kit" 
    			#if (mac_type=="iMac,1"):  mac_name= "iMac"
    			#if (mac_type=="iMac4,1"):  mac_name= "iMac (Core Duo)"  
    			#if (mac_type=="MacBook1,1"):  mac_name= "MacBook" 
    			#if (mac_type=="MacBookPro1,1"):  mac_name= "MacBook Pro" 
    			#if (mac_type=="Macmini1,1"):  mac_name= "Mac mini (Core Duo/Solo)" 
    			#if (mac_type=="MacPro1,1"):  mac_name= "Mac Pro" 
    			#if (mac_type=="PowerBook1,1"):  mac_name= "PowerBook G3" 
    			#if (mac_type=="PowerBook2,1"):  mac_name= "iBook" 
    			#if (mac_type=="PowerBook2,2"):  mac_name= "iBook (FireWire)" 
    			#if (mac_type=="PowerBook3,1"):  mac_name= "PowerBook G3 (FireWire)" 
    			#if (mac_type=="PowerBook3,2"):  mac_name= "PowerBook G4" 
    			#if (mac_type=="PowerBook3,3"):  mac_name= "PowerBook G4 (Gigabit Ethernet)" 
    			#if (mac_type=="PowerBook3,4"):  mac_name= "PowerBook G4 (DVI)" 
    			#if (mac_type=="PowerBook3,5"):  mac_name= "PowerBook G4 (867, 1 GHz)" 
    			#if (mac_type=="PowerBook4,1"):  mac_name= "iBook G3"  
    			#if (mac_type=="PowerBook4,2"):  mac_name= "iBook G3"
    			#if (mac_type=="PowerBook4,3"):  mac_name= "iBook G3"  
    			#if (mac_type=="PowerBook5,1"):  mac_name= "PowerBook G4 (17-inch)" 
    			#if (mac_type=="PowerBook5,2"):  mac_name= "PowerBook G4 (15-inch FW800)"  
    			#if (mac_type=="PowerBook5,3"):  mac_name= "PowerBook G4 (17-inch 1.33 GHz)"  
    			#if (mac_type== "PowerBook5,4"):  mac_name= "PowerBook G4 (15-inch 1.5/1.33 GHz)"  
    			#if (mac_type=="PowerBook5,5"):  mac_name= "PowerBook G4 (17-inch 1.5 GHz)"  
    			#if (mac_type=="PowerBook5,6"):  mac_name= "PowerBook G4 (15-inch 1.67/1.5 GHz)" 
    			#if (mac_type=="PowerBook5,7"):  mac_name= "PowerBook G4 (17-inch 1.67 GHz)" 
    			#if (mac_type=="PowerBook5,8"):  mac_name= "PowerBook G4 (Double-Layer SD, 15-inch)" 
    			#if (mac_type=="PowerBook5,9"):  mac_name= "PowerBook G4 (Double-Layer SD, 17-inch)" 
    			#if (mac_type=="PowerBook6,1"):  mac_name= "PowerBook G4 (12-inch)"  
    			#if (mac_type=="PowerBook6,2"):  mac_name= "PowerBook G4 (12-inch DVI)"  
    			#if (mac_type=="PowerBook6,3"):  mac_name= "iBook G4"  
    			#if (mac_type=="PowerBook6,4"):  mac_name= "PowerBook G4 (12-inch 1.33 GHz)"  
    			#if (mac_type=="PowerBook6,5"):  mac_name= "iBook G4"  
    			#if (mac_type=="PowerBook6,7"):  mac_name= "iBook G4"  
    			#if (mac_type=="PowerBook6,8"):  mac_name= "PowerBook G4 (12-inch 1.5 GHz)"  
    			#if (mac_type=="PowerMac1,1"):  mac_name= "Power Macintosh G3 (B&W)"  
    			#if (mac_type=="PowerMac1,2"):  mac_name= "Power Macintosh G4 (PCI-Graphics)"  
    			#if (mac_type=="PowerMac10,1"):  mac_name= "Mac mini"  
    			#if (mac_type=="PowerMac10,2"):  mac_name= "Mac mini"  
    			#if (mac_type=="PowerMac11,2"):  mac_name= "Power Macintosh G5 (PCIe)" 
    			#if (mac_type=="PowerMac12,1"):  mac_name= "iMac G5 (iSight)"  
    			#if (mac_type=="PowerMac2,1"):  mac_name= "iMac (Slot-Loading)"  
    			#if (mac_type=="PowerMac2,2"):  mac_name= "iMac (2000)"  
    			#if (mac_type=="PowerMac3,1"):  mac_name= "Power Macintosh G4 (AGP-Graphics)"  
    			#if (mac_type=="PowerMac3,2"):  mac_name= "Power Macintosh G4 (AGP-Graphics)"  
    			#if (mac_type=="PowerMac3,3"):  mac_name= "Power Macintosh G4 (Gigabit Ethernet)" 
    			#if (mac_type=="PowerMac3,4"):  mac_name= "Power Macintosh G4 (Digital Audio)" 
    			#if (mac_type=="PowerMac3,5"):  mac_name= "Power Macintosh G4 (Quick Silver)"  
    			#if (mac_type=="PowerMac3,6"):  mac_name= "Power Macintosh G4 (Mirrored Drive Doors)"  
    			#if (mac_type=="PowerMac4,1"):  mac_name= "iMac (2001)"  
    			#if (mac_type=="PowerMac4,2"):  mac_name= "iMac (Flat Panel)"  
    			#if (mac_type=="PowerMac4,4"):  mac_name= "eMac G3"  
    			#if (mac_type=="PowerMac4,5"):  mac_name= "iMac (17-inch Flat Panel)"  
    			#if (mac_type=="PowerMac5,1"):  mac_name= "Power Macintosh G4 Cube"  
    			#if (mac_type=="PowerMac6,1"):  mac_name= "iMac (USB 2.0)"  
    			#if (mac_type=="PowerMac6,3"):  mac_name= "iMac (20-inch Flat Panel)"  
    			#if (mac_type=="PowerMac6,4"):  mac_name= "eMac (USB 2.0)"  
    			#if (mac_type=="PowerMac7,2"):  mac_name= "Power Macintosh G5"  
    			#if (mac_type=="PowerMac7,3"):  mac_name= "Power Macintosh G5"  
    			#if (mac_type=="PowerMac8,1"):  mac_name= "iMac G5"  
    			#if (mac_type=="PowerMac8,2"):  mac_name= "iMac G5 (Ambient Light Sensor)"  
    			#if (mac_type=="PowerMac9,1"):  mac_name= "Power Macintosh G5 (Late 2004)"  
    			#if (mac_type=="RackMac1,1"):  mac_name= "Xserve G4"  
    			#if (mac_type=="RackMac1,2"):  mac_name= "Xserve G4 (Slot-Loading)"  
    			#if (mac_type=="RackMac3,1"):  mac_name= "Xserve G5"
			if (mac_type=="ADP2,1"):  mac_name = "Developer Transition Kit" 
    			if (mac_type=="iMac,1"):  mac_name= "PowerPC 750 (G3)"
    			if (mac_type=="iMac4,1"):  mac_name= "iMac (Core Duo)"  
    			if (mac_type=="MacBook1,1"):  mac_name= "MacBook" 
    			if (mac_type=="MacBookPro1,1"):  mac_name= "MacBook Pro" 
    			if (mac_type=="Macmini1,1"):  mac_name= "Mac mini (Core Duo/Solo)" 
    			if (mac_type=="MacPro1,1"):  mac_name= "Mac Pro" 
    			if (mac_type=="PowerBook1,1"):  mac_name= "PowerPC 750 (G3)" 
    			if (mac_type=="PowerBook2,1"):  mac_name= "PowerPC 750 (G3)" 
    			if (mac_type=="PowerBook2,2"):  mac_name= "PowerPC 750 (G3)" 
    			if (mac_type=="PowerBook3,1"):  mac_name= "PowerPC 750 (G3)" 
    			if (mac_type=="PowerBook3,2"):  mac_name= "PowerPC 7410 (G4 [AltiVec])" 
    			if (mac_type=="PowerBook3,3"):  mac_name= "PowerPC 7450 (G4) [AltiVec]" 
    			if (mac_type=="PowerBook3,4"):  mac_name= "PowerPC 7455 (G4) [AltiVec]" 
    			if (mac_type=="PowerBook3,5"):  mac_name= "PowerPC 7455 (G4) [AltiVec]" 
    			if (mac_type=="PowerBook4,1"):  mac_name= "PowerPC 750cxe (G3)"  
    			if (mac_type=="PowerBook4,2"):  mac_name= "PowerPC 745/755 (G3)"
    			if (mac_type=="PowerBook4,3"):  mac_name= "PowerPC 750fx (G3)"  
    			if (mac_type=="PowerBook5,1"):  mac_name= "PowerPC 7455 (G4) [AltiVec]" 
    			if (mac_type=="PowerBook5,2"):  mac_name= "PowerPC 7447 (G4) [AltiVec]"  
    			if (mac_type=="PowerBook5,3"):  mac_name= "PowerPC 7447 (G4) [AltiVec]"  
    			if (mac_type=="PowerBook5,4"):  mac_name= "PowerPC 7447A (G4) [AltiVec]"  
    			if (mac_type=="PowerBook5,5"):  mac_name= "PowerPC 7447A (G4)[AltiVec]"  
    			if (mac_type=="PowerBook5,6"):  mac_name= "PowerPC 7447A/B (G4) [AltiVec]" 
    			if (mac_type=="PowerBook5,7"):  mac_name= "PowerPC 7447B (G4) [AltiVec]" 
    			if (mac_type=="PowerBook5,8"):  mac_name= "PowerPC 7447B (G4) [AltiVec]" 
    			if (mac_type=="PowerBook5,9"):  mac_name= "PowerPC 7447B (G4) [AltiVec]" 
    			if (mac_type=="PowerBook6,1"):  mac_name= "PowerPC 7455 (G4) [AltiVec]"  
    			if (mac_type=="PowerBook6,2"):  mac_name= "PowerPC 7455 (G4) [AltiVec]"  
    			if (mac_type=="PowerBook6,3"):  mac_name= "PowerPC 7455 (G4) [AltiVec]"  
    			if (mac_type=="PowerBook6,4"):  mac_name= "PowerPC 7447A (G4) [AltiVec]"  
    			if (mac_type=="PowerBook6,5"):  mac_name= "PowerPC 7447A (G4) [AltiVec]"  
    			if (mac_type=="PowerBook6,7"):  mac_name= "PowerPC 7447A (G4) [AltiVec]"  
    			if (mac_type=="PowerBook6,8"):  mac_name= "PowerPC 7447A (G4) [AltiVec]"  
    			if (mac_type=="PowerMac1,1"):  mac_name= "PowerPC 750 (G3)"  
    			if (mac_type=="PowerMac1,2"):  mac_name= "PowerPC 7400 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac10,1"):  mac_name= "PowerPC (G4) [AltiVec]"  
    			if (mac_type=="PowerMac10,2"):  mac_name= "PowerPC (G4) [AltiVec]"  
    			if (mac_type=="PowerMac11,2"):  mac_name= "PowerPC 970MP (G5) [AltiVec/PPC_64]" 
    			if (mac_type=="PowerMac12,1"):  mac_name= "PowerPC 970fx (G5) [AltiVec/PPC_64]"  
    			if (mac_type=="PowerMac2,1"):  mac_name= "PowerPC 750 (G3)"  
    			if (mac_type=="PowerMac2,2"):  mac_name= "PowerPC 750 (G3)"  
    			if (mac_type=="PowerMac3,1"):  mac_name= "PowerPC 7400 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac3,2"):  mac_name= "PowerPC 7400 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac3,3"):  mac_name= "PowerPC 7400 (G4) [AltiVec]" 
    			if (mac_type=="PowerMac3,4"):  mac_name= "PowerPC 7410 (G4) [AltiVec]" 
    			if (mac_type=="PowerMac3,5"):  mac_name= "PowerPC 7450 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac3,6"):  mac_name= "PowerPC 7455/B (G4) [AltiVec]"  
    			if (mac_type=="PowerMac4,1"):  mac_name= "PowerPC 750/cx (G3)"  
    			if (mac_type=="PowerMac4,2"):  mac_name= "PowerPC 7450/55 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac4,4"):  mac_name= "PowerPC 7450 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac4,5"):  mac_name= "PowerPC 7450 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac5,1"):  mac_name= "PowerPC (G4) [AltiVec]"  
    			if (mac_type=="PowerMac6,1"):  mac_name= "PowerPC 7455 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac6,3"):  mac_name= "PowerPC 7455 (G4) [AltiVec]"  
    			if (mac_type=="PowerMac6,4"):  mac_name= "PowerPC (G4) [AltiVec]"  
    			if (mac_type=="PowerMac7,2"):  mac_name= "PowerPC 970/fx (G5) [AltiVec/PPC64]"  
    			if (mac_type=="PowerMac7,3"):  mac_name= "PowerPC 970fx (G5) [AltiVec/PPC64]"  
    			if (mac_type=="PowerMac8,1"):  mac_name= "PowerPC 970fx (G5) [AltiVec/PPC64]"  
    			if (mac_type=="PowerMac8,2"):  mac_name= "PowerPC 970fx (G5) [AltiVec/PPC64]"  
    			if (mac_type=="PowerMac9,1"):  mac_name= "PowerPC 970fx (G5) [AltiVec/PPC64]"  
    			if (mac_type=="RackMac1,1"):  mac_name= "PowerPC 7455 (G4) [AltiVec]"  
    			if (mac_type=="RackMac1,2"):  mac_name= "PowerPC 7455 (G4) [AltiVec]"  
    			if (mac_type=="RackMac3,1"):  mac_name= "PowerPC 970fx (G5) [AltiVec/PPC64]"
		
			cpu = mac_name
		
		output = output + t_bold + " CPU: " + t_normal + t_normal

		if cpucount > 1:
			output = output + str(cpucount) +  " x "
		#if corecount > 1:
		#	output = output 
		#	if corecount==2:
		#		output = output + "Dual Core "
		#	if corecount==4:
		#		output = output + "Quadcore "
		#	if corecount==8:
		#		output = output + "Octocore "
		output = output + cpu
		
		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
					cpuspeedsuffix = "T"
				else:
					cpuspeedsuffix = "G"
				cpuspeed = round(cpuspeed, 2)
			else:
				cpuspeedsuffix = "M"
				cpuspeed = int(cpuspeed)
		
			output = output + t_bold + " @ " + t_normal + str(cpuspeed) +  cpuspeedsuffix + "Hz"

			temp = os.popen('sysctl kern.cpu_currentfreq')
			line = temp.readline()
			if line != "":
				line = line.split(':')
				cpuspeed = trim(line[1])
				cpuspeed = float(cpuspeed) / 1000
				cpuspeedprefix = "GHz"
				output=output+" ["+str(cpuspeed)+cpuspeedprefix+"]"
		ttproc=""
		if isIntel == 1:
	                ttproc="SSE2"
			tt=os.popen('sysctl hw.optional.sse3')
			ttline=tt.readline()
			ttline=ttline.split(':')
			if (trim(ttline[1])=="1"):
				ttproc="SSE3"
			tt=os.popen('sysctl machdep.cpu.features')
			line=tt.readline()
			line=stripit(line)
			line=line.split()
			cpupae=""
			cpuvt=""
			cpuest=""
			for x in line:
				if (x=="PAE"):
					cpupae="/PAE"
				if (x=="VMX"):
					cpuvt="/VMX"
				if (x=="EST"):
					if checkAMD(cpu)==None:
						cpuest="/EST"
					else:
						cpuest="/PowerNow!"
			tt=os.popen('sysctl machdep.cpu.extfeatures')
			line=tt.readline()
			line=stripit(line)
			line=line.split()
			cpunx=""
			for x in line:
				if (x=="XD"):
					cpunx=cpunx+"/XD"
				if (x=="NX"):
					cpunx=cpunx+"/NX"
				if (x=="EM64T"):
					if checkAMD(cpu)==None:
						cpunx=cpunx+"/EM64T"
					else:
						cpunx=cpunx+"/AMD64"
			tt=os.popen('sysctl machdep.cpu.cores_per_package')
			line=tt.readline()
			cpuDC=stripit(line)
			extra=""
			if (cpuDC=="4"):
				extra=extra+"/QuadCore"
				cpuHT="0"
			if (cpuDC=="2"):
 				extra=extra+"/DualCore"
				cpuHT="0"
			if (cpuHT==2):
				extra=extra+"/HTT"
			tt=os.popen('sysctl hw.l2cachesize')
			line=tt.readline()
			line=int(stripit(line))
			output = output + " ["+ttproc+cpupae+cpunx+cpuvt+cpuest + extra+"]" + t_bold+" L2 Cache: " + t_normal+str(line/1024) + "K"
		temp = os.popen('sysctl hw.busfrequency')
		line = temp.readline()
		line = stripit(line)
		line = int(line) / 1000000
		bus = "FSB"
		if checkAMD(cpu)!=None:
			bus = "HT"
		else:
			if isIntel==1:
				line = line / 4
		output = output + t_bold + " " + bus + ": " + t_normal + str(line) + "MHz"

#	xchat.command("SAY " + output)
#	output=""

	cpuTemp=""
	if includeTemp == 1:
		tt=os.popen('sysctl kern.cpu_temp')
		line=tt.readline()
		if line != "":
			line=line.split(':')
			cpuTemp=trim(line[1])
			output=output+t_bold+" Temp "+t_red+cpuTemp+"c"+t_normal

	if includeMemory == 1:
		temp = os.popen('vm_stat | grep -m 1 free | grep -o \:.*')
		line = temp.readline()
		tempf = trim(line)
		tempf = float(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 = (tempf + tempa + tempi + tempw) * 4096 / 1048576
		freemem = (tempf + tempi) * 4096 / 1048576
		usedmem = memtotal - freemem
		mempercent = (usedmem * 100) / memtotal
		freebar = int(mempercent) / 10
		membar = "[04"
		for i in range(10):
			if i == freebar:
				membar = membar + "09"
			membar = membar + "/"
		membar = membar + "]"
		if usedmem >= 1024:
			usedmem = usedmem / 1024
			freeunit = "GB"
		else:
			freeunit = "MB"
		output = output +t_bold+" RAM: " + t_normal+str(places(str(usedmem),2)) + freeunit+ "/"+str(places(str(memnumber),2)) +  memnumunit

		if showDefault==0 and includeMemoryBar==1:
			output = output + " " + membar + t_normal
	if includeHD == 1:
		temp=os.popen('sysctl vm.swapusage')	
		line=temp.readline()
		cline=line.split(' ')
		vmtotal=cline[3]
		vmused=cline[7]
		output = output + t_bold+" Virtual: "+ t_normal+vmused+"/"+vmtotal

		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])

		hdused = hdcapacity - hdfree

		if hdused > 1048576:
			hdused = float(hdused) / 1048576
			hdusedunit = "TB"
		elif hdused > 1024:
			hdused = float(hdused) / 1024
			hdusedunit = "GB"
		else:
			hdusedunit = "MB" 
		hdused = round(hdused, 2)

		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 + t_bold+" Disk: " + t_normal+str(hdused)+hdusedunit+"/"+str(hdcapacity) +  hdcapacityunit


	if includeBattery ==1:
		battery_full=0
		battery_left=0
		temp=os.popen("ioreg -l -w 0 | grep -m 1 BatteryInfo | grep IOBatteryInfo")
		templist=temp.readlines()
		for x in templist:
			tmp=trim(x)
			tmp=tmp.split(':')
			if trim(tmp[0])=="Full Charge Capacity (mAh)":
				battery_full = float(trim(tmp[1]))
			if trim(tmp[0])=="Remaining Capacity (mAh)":
				battery_left = float(trim(tmp[1]))
		if battery_full > 0:
			battery=(battery_left/battery_full)*100
			output = output + t_bold +" Battery: " + t_normal + places(str(battery),1) + "%"


	if includeResolution == 1:
		gfx_card=""
		gfx_mem=""
		gfx_ci=""
		gfx_qe=""
		gfx_res=""
		gfx_q2de=""
		temp=os.popen("system_profiler SPDisplaysDataType")
		templist=temp.readlines()
		for x in templist:
			tmp=trim(x)
			tmp=tmp.split(':')
			if trim(tmp[0])=="Resolution":
				if gfx_res=="":
					gfx_res=trim(tmp[1])
				else:
					gfx_res=gfx_res+t_normal+" and "+trim(tmp[1])
			if trim(tmp[0])=="Chipset Model":
				gfx_card=trim(tmp[1])
			if trim(tmp[0])=="Vendor":
				if gfx_card=="":
					memtmp=trim(tmp[1])
					memtmp=memtmp.split('(')
					gfx_card=trim(memtmp[0])
			if trim(tmp[0])=="VRAM (Total)":
				gfx_mem=trim(tmp[1])
			if trim(tmp[0])=="Core Image":
				if trim(tmp[1])=="Supported":
					gfx_ci="/CI"
			if trim(tmp[0])=="Quartz Extreme":
				if trim(tmp[1])=="Supported":
					gfx_qe="/QE"				
                        if trim(tmp[0])=="Quartz 2D Extreme":
                                if trim(tmp[1])=="Supported":
                                        gfx_q2de="/Q2DE"
		driver="Stock"
		temp=os.popen("ls /System/Library/Extensions/Titan.kext")
		temp=stripspaces(temp.readline())
		if temp=="Contents":
			driver="Titan"
		else:
			temp = os.popen("ls /System/Library/Extensions/Natit.kext")
			temp = stripspaces(temp.readline())
			if temp=="Contents":
				driver="Natit"
			else:
				temp = os.popen("ls /System/Library/Extensions/NVDriver.kext")
				temp = stripspaces(temp.readline())
				if temp=="Contents":
					driver="MacVidia"
				else:
					temp = os.popen("ls /System/Library/Extensions/Callisto.kext")
					temp = stripspaces(temp.readline())
					if temp=="Contents":
						driver="Callisto"
					else:
						driver="Stock"
					
		
		output = output +t_bold+" Display: " + t_normal+ gfx_card + " [" +gfx_mem + gfx_ci + gfx_qe + gfx_q2de + "/" + driver+ "] " +  unspace(gfx_res)

	if includeOS == 1:
		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])
		temp = os.popen('sysctl kern.ostype')
		temp = temp.readline()
		kernel = stripit2(temp)
		temp = os.popen('sysctl kern.osrelease')
		temp = temp.readline()
		kernel = kernel + ' ' + stripit2(temp)
		output = output +t_bold+" OS: " +t_normal+ osname + " " + osversion + " (" +osbuild+ ")"
		output = output +t_bold+" Kernel: " +t_normal+kernel
		if includeKernel==1:
			temp = os.popen('sysctl kern.version')
			line = temp.readline()
			kerndate = stripit2(line)
			kerndate = kerndate.split(':')
			kernbuild = kerndate[3].split(';')
			temp = kerndate[4].split('/')
			temp2 = temp[1].split('_')
			if temp2[0]=='RELEASE':
				temp = temp[0] + " " + (temp2[1]).lower()
			else:
				temp = temp[1] + " i386"
			kerndate = trim(kerndate[1] + ':' + kerndate[2] + ':' + kernbuild[0])
			kernbuild = trim(kernbuild[1] + " " + temp)
			output = output + t_bold + " Build: " + t_normal + kernbuild + t_bold + " Build Date: " + t_normal + kerndate

	if includeNetwork == 1:
		temp = os.popen('netstat -ibI ' + __config_net_interface__)
		line = temp.readlines()
		line = trim(line[1])
		line = stripspaces(line)
		line = line.split(' ')
		inb = float(line[6])
		outb = float(line[9])
		if inb==0 and outb==0:
			print "Error: You may not have configured the script correctly...network is showing 0 bytes transferred. Please configure XInfoAqua with your main network interface."
		else:
			inb = inb / 1000
			ins='K'
			if inb>=1000:
				inb = inb / 1000
				ins='M'
				if inb>=1000:
					inb = inb / 1000
					ins='G'
					if inb>=1000:
						inb = inb / 1000
						ins='T'
			outs = 'K'
			outb = outb / 1000
			if outb>=1000:
				outb = outb / 1000
				outs='M'
				if outb>=1000:
					outb = outb / 1000
					outs='G'
					if outb>=1000:
						outb = outb / 1000
						outs='T'
			
			network = t_bold + " Net: " + t_normal + "[" + t_bold + __config_net_interface__ + t_normal + "/" + t_bold + "In: " + t_normal + str(round(inb,2)) + ins + "B" + "/" + t_bold + "Out: " + t_normal + str(round(outb,2)) + outs + "B" + "]"
			output = output + network

	if includeProcessCount == 1:
		temp = os.popen('ps -ax | wc -l')
		line = temp.readline()
		processCount = trim(line)
		output = output +t_bold+" Processes: " + t_normal+str(processCount)
	if includeUptime == 1:
		temp = os.popen('uptime | grep up')
		uptime = temp.readline()
		uptime = trim(uptime)
		tup=uptime.split('up')
		tup1=tup[1].split('user')
		tt=tup1[0]
		tt=tt[:-4]
		tt=trim(tt)
		output = output + t_bold+" Uptime: " + t_normal+tt

	if includeClient == 1:
		output = output + t_bold+" Client: " + t_normal+ " X-Chat Aqua v" + xchat.get_info('version')

	if includeDate == 1:
		temp = os.popen('date')
		line = temp.readline()
		temp = line.split(' ')
		if temp[2] != "":
			output = output + " ("+temp[1]+"-"+temp[2]+"-"+temp[5][:4]+" : "+temp[3][:5]+")"
		if temp[2] == "":
			output = output + " ("+temp[1]+"-"+temp[3]+"-"+temp[6][:4]+" : "+temp[4][:5]+")"

	xchat.command("SAY " + output)

	os.system('rm -rf temp.info')
		
def getTunes (args):
	outColor = 4
	goFull = 0
	goiTunes = 1
	goRealplayer = 0
	includeArtist = 1
	includeYear = 0
	includeBitrate = 0
	includeCount = 0
	includeRating = 1
	includeTime = 0
	includeKind = 0
	streamBypass = 0
	includeURL = 0
	includeLib = 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
	
	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
			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 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 = "- 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 = "- Artist: " +artist
				if len(album) > 0 and album != "missing value":
					addons = addons + " - Album: " + album
				if includeYear == 1:
					year = tuneList[yearIndex]
					if year != "missing value" and year != "0":
						addons = addons + " - Year: " + year
				if includeBitrate == 1:
					bitrate = tuneList[7]
					if bitrate != "missing value" and bitrate != "0":
						addons = addons + " - Bitrate: " + bitrate + " kb/s"
				if includeCount == 1:
					count = tuneList[countIndex]
					if count != "missing value":
						addons = addons + " - Play Count: " + count
				if includeRating == 1:
					ratingBar = "[03"
					rating = tuneList[ratingIndex]
					if rating == "missing value":
						rating = 0
					else:
						rating = int(rating) / 20
						for x in range(5):
							if x < rating:
								ratingBar = ratingBar + "‚úÆ"
							else:
								ratingBar = ratingBar + "14‚ú©"
						#ratingBar = ratingBar + "*"
						ratingBar = ratingBar + "]"
						addons = addons + " - Rating: " + ratingBar + t_normal
				#if includeTime == 1:
				#	elapsed = tuneList[timeIndex]
				#	elapsed = convertTime(elapsed, 1)
				#	totalTime = tuneList[lengthIndex]
				#	addons = addons + " - Elapsed: " + elapsed
				#	if totalTime != "missing value":
				#		addons = addons + " / " + totalTime
				if includeKind == 1:
					if streamBypass != 1:
						if fileType != "missing value":
							addons = addons + " - " + t_bold + "Kind: " + t_normal + fileType
				if includeLib == 1:
					addons = addons + " - " + 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 + " - 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 + " - Bitrate: " + str(bitrate) + " kb/s"
			if includeTime == 1 or goFull == 1:
				elapsed = tuneList[timeIndex]
				elapsed = convertTime(elapsed, 1)
				addons = addons + " - Elapsed: " + elapsed
				if includeDuration == 1:
					addons = addons + " / " + duration
			if includeURL == 1 or goFull == 1:
				url = tuneList[1]
				if includeDuration != 1:
					addons = addons + " - URL: " + url
			allGood = 1
	if allGood == 1:
		output = "" + str(outColor) + "{" + playerStatus+ "} \"" + title + "\" " + addons
		xchat.command("SAY " + output)

def getMovies (args):
	outColor = 4
	goFull = 0
	includeResolution = 0
	includeTime = 0
	output = ""
	
	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
				i = i + 1
		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')
			output = "" + str(outColor) + "{" + 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 + " - 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 + " - Elapsed: " + elapsed + " / " + totalTime
			else:
				output = output + " - Duration: " + totalTime
			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 = t_bold + "Playlist: \"" + t_normal + 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 output
	
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 permissions
def 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 (latestVersion):
	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 theTime
	
def domacversion (word, word_eol, userdata):
	printmacversion(1)
	return xchat.EAT_ALL

def 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(latestVersion) == 1:
			print "08You have XInfoAqua version " + __module_version__ + ". The latest version is " + latestVersion + ". Now updating..."

			try:
				fileName = __module_filename__ + '.' + latestVersion + '.zip'
				os.system('curl -s -B ' + __module_website__ + fileName + ' -o ' + fileName)
				os.system('unzip -o -qq ' + fileName)
				os.system('rm ' + 'Plugins/XInfoAqua' + '.' + __module_version__ + '.py')
				os.system('mv XInfoAqua.' + latestVersion + '.py Plugins/XInfoAqua.' + latestVersion + '.py')
				#xchat.command('PY UNLOAD XInfoAqua.py')
				xchat.command('PY LOAD XInfoAqua.' + latestVersion + '.py')
				#xchat.command('PY RELOAD XInfoAqua.py')
			except:
				print "An error has occurred trying to install the update. The update site may be down. Please try again later."
			os.system('rm -rf aviunzipped')
			os.system('rm ' + fileName)
			os.system('rm ' +xchatdir+'/Plugins/avirtualinferno.py')
		else:
			print "03aXInfoAqua version " + __module_version__ + " is already up-to-date."
	return xchat.EAT_ALL

def domacweather (word, word_eol, userdata):	
	zipcode = __config_default_zip__ # Zipcode that the command defaults to
	arglength = len(word)
	if arglength > 1:
		i = 1
		while i < arglength:
			arg = word[i]
			if arg.isdigit():
				if len(arg) == 5:
					zipcode = arg
			i=i+1
	if zipcode == "00000":
		print "Usage : /macweather zipcode       - For USA Zipcodes Only"
		return xchat.EAT_ALL

	url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode=" + zipcode
	cmd = "curl " + url + " > macweather.xml"
	os.system(cmd)
	temp = os.popen("cat macweather.xml")
	temp = temp.readlines()
	x=0
	while x < len(temp):
		if trim(temp[x])=="<City>":
			w_city=trim(temp[x+1])
		if trim(temp[x])=="<State>":
			w_state=trim(temp[x+1])
		if trim(temp[x])=="<Temperature>":
			w_temp=trim(temp[x+1])
		if trim(temp[x])=="<RealFeel>":
			w_realfeel=trim(temp[x+1])
		if trim(temp[x])=="<WeatherText>":
			w_text=trim(temp[x+1])
		if trim(temp[x])=="<WindSpeed>":
			w_windspeed=trim(temp[x+1])
		if trim(temp[x])=="<WindDirection>":
			w_windirection=trim(temp[x+1])

		x=x+1
	output= chr(3)+outColor+t_bold+"Current Weather for "+t_normal+t_bold+w_city+", "+w_state+" (USA) : "+chr(3)+outColor+w_text+t_normal+t_bold+" Temp:"+chr(3)+outColor+w_temp+"f/"+str(convertToC(w_temp))+"c "+t_normal+t_bold+"Feels Like : "+chr(3)+outColor+w_realfeel+"f/"+str(convertToC(w_realfeel))+"c "+t_normal+t_bold+" Wind : "+chr(3)+outColor+w_windspeed+" mph "+w_windirection
	xchat.command("SAY "+output)	
	return xchat.EAT_ALL


def domacweatherca (word, word_eol, userdata):
	xchat.EAT_ALL
	arglength = len(word)
	if arglength < 3:
		print "Usage /macweatherca city, province   -  For Canadian locations only"
		return xchat.EAT_ALL
	if arglength > 1:
		arg = word[1]+"%20"+word[2]
		if arglength==4:
			arg=arg+"%20"+word[3]
		loc = arg
		w_state=word[2]
	url="http://apple.accuweather.com/adcbin/apple/Apple_find_city.asp?location="+loc
	cmd = "curl " + url + " > macweather.xml"
	os.system(cmd)
	temp = os.popen("cat macweather.xml | grep postal")
	temp = temp.readline()
	if temp=="":
		print "Sorry, location not found"
		return xchat.EAT_ALL
	temp = temp.split('=')
	postal=temp[3]
	postal=postal.split('"')
	tt=temp[2].split('"')
	w_state=tt[1]
	url = "http://apple.accuweather.com/adcbin/apple/Apple_Weather_Data.asp?zipcode='" + postal[1] + "'"
	os.system("rm -f macweather.xml")
	cmd = "curl " + url + " > macweather.xml"
	os.system(cmd)
	temp = os.popen("cat macweather.xml")
	temp = temp.readlines()
	x=0
	while x < len(temp):
		if trim(temp[x])=="<City>":
			w_city=trim(temp[x+1])
		if trim(temp[x])=="<Temperature>":
			w_temp=trim(temp[x+1])
		if trim(temp[x])=="<RealFeel>":
			w_realfeel=trim(temp[x+1])
		if trim(temp[x])=="<WeatherText>":
			w_text=trim(temp[x+1])
		if trim(temp[x])=="<WindSpeed>":
			w_windspeed=trim(temp[x+1])
		if trim(temp[x])=="<WindDirection>":
			w_windirection=trim(temp[x+1])

		x=x+1
	output= chr(3)+outColor+t_bold+"Current Weather for "+t_normal+t_bold+w_city+", "+w_state+": "+chr(3)+outColor+w_text+t_normal+t_bold+" Temp:"+chr(3)+outColor+w_temp+"f/"+str(convertToC(w_temp))+"c "+t_normal+t_bold+"Feels Like : "+chr(3)+outColor+w_realfeel+"f/"+str(convertToC(w_realfeel))+"c "+t_normal+t_bold+" Wind : "+chr(3)+outColor+w_windspeed+" mph "+w_windirection
	xchat.command("SAY "+output)	
	return xchat.EAT_ALL

def doAzureus(word, word_eol, userdata):
	xchat.EAT_ALL
	full = 0
	arglength = len(word)
	if arglength > 1:
		if word[1].lower()=="full":
			full=1
	temp=os.popen("cat /tmp/Azureus_Stats.xml")
	temp=temp.readlines()
	x=0
	file_count=0
	az_down=""
	az_up=""
	az_file_name=""
	az_file_size_print=""
	az_file_size=0
	az_downed=0
	az_discard=0
	az_percent=""
	out_tmp=""
	while x < len(temp):
		if az_down=="":
			if trim(temp[x])=="<DOWNLOAD_SPEED>":
				tmp=temp[x+1]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_down=tmp1[0]
		if az_up=="":
			if trim(temp[x])=="<UPLOAD_SPEED>":
				tmp=temp[x+1]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_up=tmp1[0]
				output= t_normal +t_bold +"Current Azureus Transfer." +chr(3)+outColor+ " Down: "+ t_normal + az_down + t_bold + chr(3)+outColor + " Up: " + t_normal + az_up
				xchat.command("SAY "+output)
		
		if full==1:
			if left(trim(temp[x]),6)=="<NAME>":
				tmp=trim(temp[x])
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_file_name=tmp1[0]
			
				tmp=temp[x+4]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_file_size_print=tmp1[0]
				
				
				tmp=temp[x+5]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_file_size=tmp1[0]
									
				tmp=temp[x+21]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_downed=tmp1[0]

				tmp=temp[x+29]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_discard=tmp1[0]

				tmp=temp[x+32]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_down_speed=tmp1[0]

				tmp=temp[x+36]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_up_speed=tmp1[0]

				tmp=temp[x+44]
				tmp=tmp.split(">")
				tmp1=tmp[1].split("<")
				az_eta=tmp1[0]

				az_percent=str( (float(az_downed)-float(az_discard)) / float(az_file_size) * 100)
				
				out_tmp = chr(3)+outColor+t_bold+"File: "+t_normal+az_file_name+" ("+places(az_percent,1)+"% of "+az_file_size_print+")" + chr(3)+outColor+t_bold+" Down: "+t_normal+ az_down_speed+chr(3)+outColor+t_bold+" Up: "+t_normal+az_up_speed+chr(3)+outColor+t_bold+" ETA: "+t_normal+az_eta

				xchat.command("SAY "+out_tmp)
	
			
		x=x+1
	if az_down!="":
		return xchat.EAT_ALL
	else:
		print "Azureus Stats file not found."

def places(str, leng):
 	tmp=str.split(".")
	return tmp[0]+"."+left(tmp[1],1)

def left(str, leng):
    return str[:leng]

def convertToC (inp):
	tmp=(int(inp)-32)*5/9
	return tmp

def unspace (inp):
	x=0
	temp=""
	tmp=inp.split(" ")
	while x < len(tmp):
		if tmp[x]=="and":
			tmp[x]=" and "
		temp = temp + tmp[x]
		x = x + 1

	return temp

def getUpdate (args):
	print xchatdir
	
def getVersion (args):
	temp = os.popen('curl -s ' + __module_website__ + '/xchatinfoversion')
	temp = temp.readline()
	latestVersion = trim(temp)
	return latestVersion
	
def printmacversion (args):
	print __module_long_version__
	print __module_authors__
	print "03Type /machelp for a list of available commands and other information."
	
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 machdep.cpu.cores_per_package')
			temp = temp.readline()
			count = stripit(temp)
			if count == "2": model = "Core Duo"
			elif count == "1": model = "Core 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
	
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 == "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\""
	else: model = name
	return model

def stripit (line):
	#print line
	temp = line.split(':')
	temp = trim(temp[1])
	return temp

def stripit2 (line):
	temp = line.split('=')
	temp = trim(temp[1])
	return temp

def stripspaces (line):
	temp = line.split(' ')
	line = ""
	i = 0
	while i < len(temp):
		if temp[i]!='':
			line = line + " " + temp[i]
		i = i + 1
	line = trim(line)
	return line

def stripmarks (line):
	p = re.compile('{\(abc\)|\(tm\)|CPU|\(R\)|@|Processor|\(C\)|\(abc\)}', re.IGNORECASE)
	return p.sub('', line, count=0)

def checkAMD (cpu):
	return re.match( 'AMD', cpu, re.IGNORECASE )
	
def trim (line):
	temp = line.strip(':')
	temp = temp.strip('\n')
	temp = temp.strip()
	return temp
		
printmacversion(1)

def dohelp(arg1,arg2,arg3):
	print "System Information - For OS X with XChat Aqua"
	print "Modified by Spaz from source code from Illuminati."
	print "Further modified by Prasys & Joey."
	print "" 
	print "/macinfo   :  Gives system information."
	print "       Arguements are:"
	print "         cpu - Gives CPU info only"
	print "         ram - Gives RAM info only"
	print "         res - Gives Display info only"
	print "         hd  - Gives Hard Disk info only"
	print "         os  - Gives OS info only"
	print "         bw  - Outputs without color. Can be combined, eg /macinfo cpu bw"
	print "       NOTE: To change the default options, open XinfoAqua and scroll down a little ways. Change the options you want, save the file, and reload the script in X-Chat Aqua."
	print "" 
	print "/macweather *zipcode*              : Gives weather for USA zipcode "
	print ""
	print "/macweatherca *city*, *province*   : Gives weather for Canada locations "
	print ""
	print "/macweatherca *city*, *country*    : Gives weather for Global locations "
	print ""
	print "/mactunes  :  Gives information about song playing in iTunes"
	print "       Arguements are:"
	print "         full - Gives extended information"
	print ""
	print "/macaz     : Gives up/down speed for Azureus transfers"
	print "       Arguements are:"
	print "         full   -  Also gives filenames and % transfered"
	print "      note: To make this work, goto Statistics in Azerues Preferences"
	print "            Set Enable to on, set Save Directory to /tmp and leave everything else alone"
	print "            You can change the Save Frequency to whatever you want."
	print ""
	print "/macupdate  : Downloads the latest version"
	print ""
	print "/machelp    : duh!"

	return xchat.EAT_ALL

def doblame(arg1,arg2,arg3):
	xchat.command("ME blames nVidia_user!")
	return xchat.EAT_ALL
def dod(arg1,arg2,arg3):
       xchat.command("ME says 'come and visit us @ #scripts @ irc.macspeak.net'")
       return xchat.EAT_ALL


	
# X-Chat Aqua Command Hooks
xchat.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'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")
xchat.hook_command('mactunes', domactunes, help="/mactunes - Displays information about currently playing item in iTunes (default) or RealPlayer. Arguments (do not include quotes): 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'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="/macupdatespaz - Checks for latest version by Spaz")
xchat.hook_command('macweather', domacweather, help="/macw zip - US")
xchat.hook_command('macweatherca', domacweatherca, help="/macw city, country - International")
xchat.hook_command('macaz', doAzureus, help="/macaz - Azureus stats")
xchat.hook_command('machelp', dohelp, help="/machelp")
xchat.hook_command('blame', doblame, help='/blame - blames nVidia_user')
xchat.hook_command('visit', dod, help='/visit - says "Visit #scripts @ irc.macspeak.net')