rendered paste bodyimport xchat,os,copy# About this plugin__module_name__ = "XInfoAqua"__module_version__ = "7.0s"__module_description__ = "Mac system info and media output"## This script is based on the M[OSX]S script, written in TCL for 10.4# compatibility, then converted to Python for OSx86 compatibility.## Compatibility note: The /macinfo command is compatible with 10.4 and above## Weather information courtesy Weather Underground## Version 7 : added PPC compatability## 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# /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# Global Variablesxchatdir = xchat.get_info("xchatdir")t_bold=chr(2)t_normal=chr(15)t_green=chr(3)+"03"t_blue=chr(3)+"12"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=0def 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 t_blue=t_normal t_purple=t_normal t_red=t_normal t_bold=chr(2)+chr(3)+"02" 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 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 == "bw": t_blue="" t_green="" t_purple="" t_red="" if temp == "spaz": updatespaz=1 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 == "battery" or temp == "full": includeBattery = 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: showDefault = 1 else: showDefault = 1 if showDefault == 1: includeOS = 1 includeCPU = 1 includeCPUSpeed = 1 includeMemory = 1 includeHD = 1 includeProcessCount = 1 includeUptime = 1 includeResolution = 1 includeTemp = 1 includeBattery = 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) junk = temp.readline() temp = temp.readline() temp = temp.split('>') temp = temp[1] temp = temp.split('<') temp = temp[0] machine = refModel(temp) if machine=='Apple Development Platform': machine="Hackint0sh" output = t_normal+t_yellow+ 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 = stripit(line) 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) if numcore == "": numcore = 1 if numcore == "0": numcore = 1 cpucount = int(cpucount) / int(numcore) cpucount = str(cpucount) cpuc=" " if (cpucount=="1"): cpuc = "" else: cpuc = str(cpucount) + " x " tt=os.popen('sysctl machdep.cpu.brand_string') line=tt.readline() line=stripit(line) if cpusubtype=="4": temp = os.popen('sysctl machdep.cpu.cores_per_package') temp = temp.readline() count = stripit(temp) if count == "2": line = "Intel Core Duo" elif count == "1": line = "Intel Core Solo" else: tt=os.popen('sysctl machdep.cpu.brand_string') line=tt.readline() line=stripit(line) else: cmd= "sysctl hw.model" temp = os.popen(cmd) 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" line = mac_name output = output + t_bold+" CPU " + t_bold + t_blue + line 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) output = output + t_normal+ " @ " + t_blue + str(cpuspeed) + cpuspeedprefix + "Hz" + t_normal 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+"]" 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"): cpuest="/EST" 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="/XD" if (x=="NX"): cpunx="/NX" output = output + t_normal+ " ["+t_blue+ttproc+cpupae+cpunx+cpuvt+cpuest tt=os.popen('sysctl machdep.cpu.logical_per_package') line=tt.readline() line=line.split(':') cpuHT=trim(line[1]) tt=os.popen('sysctl machdep.cpu.cores_per_package') line=tt.readline() line=line.split(':') cpuDC=trim(line[1]) if (cpuDC=="4"): output=output+"/QuadCore" cpuHT="0" if (cpuDC=="2"): output=output+"/DualCore" cpuHT="0" if (cpuHT=="2"): output=output+"/HTT" output=output+t_normal+"]" tt=os.popen('sysctl hw.l2cachesize') line=tt.readline() line=int(stripit(line)) output = output + t_bold+" L2 Cache " + t_bold+t_blue+str(line/1024) + "K"# 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_normal+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 + "14" membar = membar + "|" membar = membar + "]" if usedmem >= 1024: usedmem = usedmem / 1024 freeunit = "GB" else: freeunit = "MB" output = output +t_normal+ t_bold+" RAM Used " + t_bold+t_green+str(places(str(usedmem),2)) + freeunit +t_normal+ "/"+ t_green+str(places(str(memnumber),2)) + memnumunit # + " " + membar if includeHD == 1: temp=os.popen('sysctl vm.swapusage') line=temp.readline() cline=line.split(' ') vmtotal=cline[3] vmused=cline[7] output = output + t_normal + t_bold+" Virtual "+ t_normal+vmused+"/"+t_green+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_normal+t_bold+" Disk Used " + t_bold+t_green+str(hdused)+hdusedunit+t_normal+"/"+t_green+str(hdcapacity) + hdcapacityunit if includeBattery ==1: battery_full=0 battery_left=0 temp=os.popen("system_profiler SPPowerDataType") 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_normal + t_bold +" Battery: " + t_normal + t_green + places(str(battery),1) + t_normal + "%" 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 "+t_green+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" output = output +t_normal+ t_bold+" Display " + t_bold +t_green+ gfx_card +t_normal+ " [" +t_green+gfx_mem + gfx_ci + gfx_qe + gfx_q2de + t_normal+ "] " + t_green+ 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]) output = output +t_normal+t_bold+" OS: " +t_bold+ t_blue+osname + " " + osversion + t_normal+" (" + t_blue+osbuild +t_normal+ ")" if includeProcessCount == 1: temp = os.popen('ps -ax | wc -l') line = temp.readline() processCount = trim(line) output = output +t_normal+ t_bold+" Processes: " + t_bold+t_green+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_normal+t_bold+" Up " + t_normal+tt temp = os.popen('date') line = temp.readline() temp = line.split(' ') if temp[2] != "": output = output + t_normal + " ("+temp[1]+"-"+temp[2]+"-"+temp[5][:4]+" : "+temp[3][:5]+")" if temp[2] == "": output = output + t_normal + " ("+temp[1]+"-"+temp[3]+"-"+temp[6][:4]+" : "+temp[4][:5]+")" xchat.command("SAY " + output) os.system('rm -rf temp.info') def getTunes (args): 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 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 + "14" ratingBar = ratingBar + "|" ratingBar = ratingBar + "]" addons = addons + " - Rating: " + ratigBar #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 + " - Kind: " + 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 = 7 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 = "Playlist: \"" + 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 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 theTime def 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 domacupdatespaz (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 = getVersionSpaz(1) if checkUpdate(1) == 1: print "08You have XInfoAqua version " + __module_version__ + ". The latest version is " + latestVersion + ". Now updating..." try: os.system('curl -s -B http://spaz.is-a-geek.com/XInfoAqua.zip -o XInfoAqua.zip') os.system('unzip -o -qq XInfoAqua.zip') os.system('rm ' + xchatdir + '/Plugins/XInfoAqua.py') os.system('mv XInfoAqua.py ' + xchatdir + '/Plugins/XInfoAqua.py') xchat.command('PY LOAD XInfoAqua.py') except: print "An error has occurred trying to install the update. Please try again later." os.system('rm -rf aviunzipped') os.system('rm XInfoAqua.zip') os.system('rm ' +xchatdir+'/Plugins/avirtualinferno.py') else: print "03aXInfoAqua version " + __module_version__ + " is already up-to-date." return xchat.EAT_ALLdef domacweather (word, word_eol, userdata): zipcode = "00000" # 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= t_bold+"Current Weather for "+t_normal+t_bold+w_city+", "+w_state+" (USA) : "+t_blue+w_text+t_normal+t_bold+" Temp:"+t_blue+w_temp+"f/"+str(convertToC(w_temp))+"c "+t_normal+t_bold+"Feels Like : "+t_blue+w_realfeel+"f/"+str(convertToC(w_realfeel))+"c "+t_normal+t_bold+" Wind : "+t_blue+w_windspeed+" mph "+w_windirection xchat.command("SAY "+output) return xchat.EAT_ALLdef domacweatherca (word, word_eol, userdata): xchat.EAT_ALL zipcode = "00000" # Zipcode that the command defaults to 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= t_bold+"Current Weather for "+t_normal+t_bold+w_city+", "+w_state+": "+t_blue+w_text+t_normal+t_bold+" Temp:"+t_blue+w_temp+"f/"+str(convertToC(w_temp))+"c "+t_normal+t_bold+"Feels Like : "+t_blue+w_realfeel+"f/"+str(convertToC(w_realfeel))+"c "+t_normal+t_bold+" Wind : "+t_blue+w_windspeed+" mph "+w_windirection xchat.command("SAY "+output) return xchat.EAT_ALLdef 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_bold+"Current Azureus Transfer." + t_blue +" Down: "+ t_normal + az_down + t_bold + t_blue + " 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 = t_normal+t_bold+t_blue+"File: "+t_normal+az_file_name+" ("+places(az_percent,1)+"% of "+az_file_size_print+")" + t_normal+t_blue+t_bold+" Down: "+t_normal+ az_down_speed+ t_normal+t_blue+t_bold+" Up: "+t_normal+az_up_speed+t_normal+t_blue+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 tmpdef 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 tempdef getUpdate (args): print xchatdir def getVersionSpaz (args): temp = os.popen('curl -s http://spaz.is-a-geek.com/macversion') temp = temp.readline() latestVersion = trim(temp) return latestVersiondef getVersion (args): temp = os.popen('curl -s http://spaz.is-a-geek.com/macversion') temp = temp.readline() latestVersion = trim(temp) return latestVersion def printmacversion (args): print "07=====XInfoAqua 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 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 modeldef stripit (line): #print line temp = line.split(':') temp = trim(temp[1]) return temp 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 OSx86, and XChat Aqua" print "Modified by Spaz from source code from Illuminati. " 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 "" 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!" print "" print"NOTE: For CPU temprature to work, please get SpeedIt Kext at " print " http://www.increw.org/download.html" return xchat.EAT_ALL # X-Chat Aqua Command 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'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',domacupdatespaz, help="/macupdatespaz - Checks for latest version by Spaz")xchat.hook_command('macweather', domacweather, help="/macw zip - US")xchat.hook_command('macweatherca', domacweatherca, help="/macw town, province - CAN")xchat.hook_command('macaz', doAzureus, help="/macaz - Azureus stats")xchat.hook_command('machelp', dohelp, help="/machelp")