def generateLinkFileinMac(): ResToolFind = False startFileName = 'startup.sh' #ResToolFile = 'taskManager.py' for disk in machine.getMacPartitions(): resToolRealFolder = '/Volumes/' + disk + '/' + RestDrName ResToolRelPath = resToolRealFolder + '/' + startFileName # ResToolFullPath = os.path.normpath(os.path.join(disk, '/', ResToolFolder, ResToolFile)) if os.path.exists(ResToolRelPath): ResToolFind = True break if ResToolFind: # stream += disk + '\n' stream = 'cd ' + resToolRealFolder + '\n' stream += './' + startFileName + '\n' linkFilePath = 'linkResClient.sh' startF = file(linkFilePath, 'wb') startF.write(stream) startF.close() time.sleep(1) # change to executable file os.system('chmod +x ' + linkFilePath) os.system('./' + linkFilePath) # cmd = [] # cmd.append('chmod +x ' + linkFilePath) # cmd.append('./' + linkFilePath) # subprocess.Popen(cmd).pid else: #do nothing return
def macGetUniqePartiotionName(self, name): import random rint = random.randint(1, 999) oldPartitions = set(machine.getMacPartitions()) newName = name + str(rint) if newName in oldPartitions: return self.macGetUniqePartiotionName(name) else: return newName