import os def inandout(compname): #This function removes a computer that has been thoroughly searched from the list of computers to search so that if the the search takes more #than one execution, then it won't be redundant. Brines = open("complist.txt").readlines() Lines = open("complist.txt", "w") i = 0 print "LEN: ", len(Brines) while i < len(Brines): #print i if compname != Brines[i][:-1].split()[0]: #print "|" + compname + "| != |" + Brines[i][:-1].split()[0] + "|" Lines.write(Brines[i]) i = i + 1 Lines.close() return 1 def lowercase(input): return input.lower() def notin(name): #################################################################################################################################################################### ###############Specification for directories not to enter########################################################################################################### badirs = [".", "..", "Program Files", "WINDOWS", "Default User", "temp", "All Users", "i386", "WINNT", "Perl", "Start Menu"] #badirs = badirs + ["Documents and Settings", "filebox"] # for testing purposes to speed up search process. ##################################################################################################################################################################### i = 0 name = name[:-1] while i < len(badirs): if lowercase(name) == lowercase(badirs[i]) or lowercase(name[:len(badirs[i])]) == lowercase(badirs[i]): return 0 i = i + 1 return 1 def latestdirfind(input): i = len(input)-2 while i > -1: if input[i] == "\\": return input[i+1:] i = i - 1 return input def extchk(single): ################################################################################################ #################Specification for filetypes to search for###################################### extensions = ["mp3", "shn", "wav", "hnf", "m4a", "hnf", "lac", "ape", "wma", "ogg"]############# ################################################################################################ i = 0 while i < len(extensions): if lowercase(single) == extensions[i]: return 1 i = i + 1 return 0 def FileNameSearch(filename, keyword): #See if a keyword is contained if keyword == "": return 1 i = 0 while i < len(filename)-len(keyword)-1: #print filename if filename[i:i+len(keyword)] == keyword: return 1 i = i + 1 return 0 def concatenate(comp, dir, newdir): #This Function properly formats the output the user sees most of the time - the name of the directory currently being searched if len(comp) + len(dir) + len(newdir) > 79: return comp + dir[:75-len(newdir) - len(comp)] + "...\\" + newdir return comp + dir + newdir def conneckt0r(host): pinger = "ping -n 1 " + host + " > c:\\ping.txt" os.system(pinger) res = open("c:\\ping.txt").readlines() #import list of files/folders in working directory. os.system("del c:\\ping.txt")#remove list of files/folders in working directory. if res[0][:22] == "Ping request could not": return 0 #print res[0][:22] return 1 def CompParse(dirname, drivename, compname, copyto): dircomm= """dir \"""" + drivename + dirname + """\" > c:\yay.txt""" # send list of files/folders to a txt file for reading. #print "dirname: |" + dirname + "|" #print "dircomm: " + dircomm x = os.system(dircomm) dir = open("c:\yay.txt").readlines() #import list of files/folders in working directory. dir = dir[5:] os.system("del c:\yay.txt")#remove list of files/folders in working directory. if x==0: #print "CONNECT! Successful to" + compname #print dir i = 0 while i < len(dir): line = dir[i].split() if line[3] == "