def debug_init(): root_container.leav = False root_container.add_container( container.container(0, 0, 0, [], 0.5, 0, 1, True, 0)) root_container.add_container( container.container(0, 0, 0, [], 0.5, 1, 2, False, 0)) root_container.childs[1].add_container( container.container(0, 0, 0, [], 0.5, 0, 3, True, 0)) root_container.childs[1].add_container( container.container(0, 0, 0, [], 0.5, 0, 4, True, 0)) print(windowlist) root_container.childs[0].hwnd = int(windowlist[0]) print( win32gui.GetWindowText(windowlist[0]) + " " + str(windowlist[0]) + "\n") index = 0 test1 = windowlist test1.pop(0) for hwnd in test1: try: win32gui.ShowWindow(hwnd, win32con.SW_NORMAL) root_container.childs[1].childs[index].hwnd = int(hwnd) print(win32gui.GetWindowText(hwnd) + " " + str(hwnd) + "\n") except Exception as e: print("Error Type 1\n" + str(hwnd)) index += 1
def __init__(self, imageDirectory, imageName, blockDimension, outputDirectory): print("\tStep 1 of 4: Object and variable initialization") # image parameter self.imageOutputDirectory = outputDirectory self.imagePath = imageName self.imageData = Image.open(imageDirectory + imageName) self.imageWidth, self.imageHeight = self.imageData.size # height = vertikal, width = horizontal if self.imageData.mode != 'L': # L means grayscale self.isThisRGBImage = True self.imageData = self.imageData.convert('RGB') RGBImagePixels = self.imageData.load() self.imageGrayscale = self.imageData.convert( 'L' ) # creates a grayscale version of current image to be used later GrayscaleImagePixels = self.imageGrayscale.load() for yCoordinate in range(0, self.imageHeight): for xCoordinate in range(0, self.imageWidth): redPixelValue, greenPixelValue, bluePixelValue = RGBImagePixels[ xCoordinate, yCoordinate] GrayscaleImagePixels[xCoordinate, yCoordinate] = int( 0.299 * redPixelValue) + int( 0.587 * greenPixelValue) + int( 0.114 * bluePixelValue) else: self.isThisRGBImage = False self.imageData = self.imageData.convert('L') # algorithm's parameters from the first paper self.N = self.imageWidth * self.imageHeight self.blockDimension = blockDimension self.b = self.blockDimension * self.blockDimension self.Nb = (self.imageWidth - self.blockDimension + 1) * (self.imageHeight - self.blockDimension + 1) self.Nn = 2 # amount of neighboring block to be evaluated self.Nf = 188 # minimum treshold of the offset's frequency self.Nd = 50 # minimum treshold of the offset's magnitude # algorithm's parameters from the second paper self.P = (1.80, 1.80, 1.80, 0.0125, 0.0125, 0.0125, 0.0125) self.t1 = 2.80 self.t2 = 0.02 print('\t', self.Nb, self.isThisRGBImage) # container initialization to later contains several data self.featurescontainer = container.container() self.blockPaircontainer = container.container() self.offsetDictionary = {}
def test_Out(self): c = container() ofsttest = open("testcontout.txt").read() ofst = open("tests.txt", "w") ofst = c.OutData(ofst) ofst1 = open("tests.txt").read() self.assertEqual(ofst1, ofsttest)
def __init__(self, remoteShell, domainAdmin="admin", domain=None): self.remoteShell = remoteShell self.uptoolPath = "/opt/quest/bin/uptool" self.domainAdmin = domainAdmin self.defaultDomain = domain self.container = container.container(self.remoteShell, self.domainAdmin, self.defaultDomain) self.create = upCreate.create(self.remoteShell, self.domainAdmin, self.defaultDomain) self.delete = upDelete.delete(self.remoteShell, self.domainAdmin, self.defaultDomain) self.depopulate = depopulate.depopulate(self.remoteShell, self.domainAdmin, self.defaultDomain) self.list = upList.list(self.remoteShell, self.domainAdmin, self.defaultDomain) self.membership = membership.membership(self.remoteShell, self.domainAdmin, self.defaultDomain) self.migrate = migrate.migrate(self.remoteShell, self.domainAdmin, self.defaultDomain) self.modify = modify.modify(self.remoteShell, self.domainAdmin, self.defaultDomain) self.populate = populate.populate(self.remoteShell, self.domainAdmin, self.defaultDomain) isinstance(self.container, container.container) isinstance(self.create, upCreate.create) isinstance(self.delete, upDelete.delete) isinstance(self.depopulate, depopulate.depopulate) isinstance(self.list, upList.list) isinstance(self.membership, membership.membership) isinstance(self.migrate, migrate.migrate) isinstance(self.modify, modify.modify) isinstance(self.populate, populate.populate)
def test_Sort(self): c = container() ctest = container() nm1 = bin_matrix() nm1.key = 1 nm2 = triangle_matrix() nm2.key = 2 nm3 = triangle_matrix() nm3.key = 1 nm4 = bin_matrix() nm4.key = 1 c.matrices.append(nm1) c.matrices.append(nm2) c.matrices.append(nm3) c.matrices.append(nm4) c.Sort() ctest.matrices.append(nm1) ctest.matrices.append(nm3) ctest.matrices.append(nm4) ctest.matrices.append(nm2) self.assertEqual(c.matrices, ctest.matrices)
def test_Out_filtr(self): c = container() bin = bin_matrix() bin.mtx = "1" c.matrices.append(bin) diag = diagonal_matrix() diag.mtx = "226" c.matrices.append(diag) ofsttest = open("testcontoutFiltr.txt").read() ofst = open("tests.txt", "w") ofst = c.OutDataFirstType(ofst) ofst1 = open("tests.txt").read() self.assertEqual(ofst1, ofsttest)
def main(): #Make some vegtables veggies = [] CreatePlants(veggies) #Print the Veggies for v in veggies: print(v) global containers containers.append( container(30, 200, gardenmixsoil("MySoil", 10.0, 20.0, 100.0), veggies) ) print("\nPress Any key to quit simulation...\n") Simulate()
def getSamplePackage(self): '''Find or pull down a known sample .pkg and source it''' if self.samplePackagePath is not None: return self.samplePackagePath # get and mount the image dmgItem = container(commonTestConfiguration.getDownloadedPkgInDmgPath()) dmgItem.mount(mountReadWrite=False) samplePackagePath = os.path.join(dmgItem.getWorkingPath(), 'AirPortClientUpdate2009001.pkg') self.assertTrue(os.path.exists(samplePackagePath), 'Unable to setup the sameple package') self.samplePackagePath = samplePackagePath return samplePackagePath
def getSamplePackage(self): '''Find or pull down a known sample .pkg and source it''' if self.samplePackagePath is not None: return self.samplePackagePath # get and mount the image dmgItem = container( commonTestConfiguration.getDownloadedPkgInDmgPath()) dmgItem.mount(mountReadWrite=False) samplePackagePath = os.path.join(dmgItem.getWorkingPath(), 'AirPortClientUpdate2009001.pkg') self.assertTrue(os.path.exists(samplePackagePath), 'Unable to setup the sameple package') self.samplePackagePath = samplePackagePath return samplePackagePath
def csvparser(filename): """ 读csv并处理 """ with open(filename, "r") as f: reader = csv.reader(f) csv_header = next(reader) for i in reader: data = todict(csv_header, i) if data["Name"] == "": continue thiscontainer = container(data, cargos) containers.append(thiscontainer) thisidentity = thiscontainer.getidentity() if thisidentity in identities.keys(): identities[thisidentity].append(thiscontainer) else: identities[thisidentity] = [thiscontainer] return
def main(): pygame.init() screen = display.set_mode((640, 480)) display.set_caption('shard gui') screen.fill(colours['white']) pygame.display.update() t = toolbar(things=[box('label.png'), box('label.png')]) c = cancel('label.png') cl = clear('label.png') f = forward('label.png') b = back('label.png') t.add([c, cl, b, f]) g = grid(screen, 0, t.height, screen.get_width(), screen.get_height() - t.height) con = container(t, g, screen) done = False while not done: rs = con.draw(screen) display.update(rs) events = pygame.event.get() for e in events: if (e.type == QUIT): done = True break elif (e.type == KEYDOWN): if (e.key == K_ESCAPE): done = True break else: con.handleEvent(e) return
def main(): pygame.init() screen = display.set_mode((640, 480)) display.set_caption('shard gui') screen.fill(colours['white']) pygame.display.update() t = toolbar(things = [box('label.png'), box('label.png')]) c = cancel('label.png') cl = clear('label.png') f = forward('label.png') b = back('label.png') t.add([c, cl, b, f]) g = grid(screen, 0, t.height, screen.get_width(), screen.get_height()-t.height) con = container(t, g, screen) done = False while not done: rs = con.draw(screen) display.update(rs) events = pygame.event.get() for e in events: if(e.type == QUIT): done = True break elif(e.type == KEYDOWN): if(e.key == K_ESCAPE): done = True break else: con.handleEvent(e) return
def test_Clear(self): c = container() for i in range(12): c.matrices.append(i) c.Clear() self.assertEqual(c.matrices, [])
os.path.join(thisContainer.getWorkingPath(), internalItem) for internalItem in os.listdir( thisContainer.getWorkingPath()) ] # ToDo: try to find the exact items by name first # find the item that matches the frontmost allowedBuilds item for thisItem in innerSearchItems: baseImageCandidate = None if hasattr(thisItem, 'isContainerType'): baseImageCandidate = thisItem else: try: baseImageCandidate = container(thisItem) except: continue if not baseImageCandidate.isContainerType('dmg'): continue macOSInformation = baseImageCandidate.getMacOSInformation() if macOSInformation['macOSInstallerDisc'] is not True: continue if macOSInformation['macOSType'] != 'MacOS X Client': continue # see if one of the patterns in allowedBuilds matches
def findInstallerDisc(allowedBuilds=None, searchItems=None, systemType='MacOS X Client'): # -- validate input if systemType != 'MacOS X Client': raise NotImplementedError('At this time only MacOS X Client is supported') # allowedBuilds parsedAllowedBuilds = [] if hasattr(allowedBuilds, 'capitalize'): for thisItem in allowedBuilds.split(','): try: parsedAllowedBuilds.append(macOSXVersionParser.macOSXVersion(thisItem.strip())) except: raise ValueError('The allowedBuild item is not in the correct form: ' + thisItem) elif hasattr(allowedBuilds, '__iter__'): if len(allowedBuilds) == 0: raise ValueError('There were no allowBuilds provided') for thisValue in allowedBuilds: try: parsedAllowedBuilds.append(macOSXVersionParser.macOSXVersion(thisValue)) except: raise ValueError('The allowedBuild item is not in the correct form: ' + thisValue) elif allowedBuilds is not None: raise ValueError('Unable to understand the allowedBuild provided: ' + str(allowedBuilds)) # -- confirm or setup search folders if hasattr(searchItems, 'capitalize'): # the path to a single item searchItems = [searchItems] elif hasattr(searchItems, '__iter__'): # array of paths to search items, so nothing to do pass elif searchItems is None: searchItems = [] if allowedBuilds is not None: # non-legacy mode if not os.path.isdir(commonConfiguration.standardOSDiscFolder): # worry-warting raise ValueError('The legacy OS installer disc folder does not exist or was not a directory: ' + str(commonConfiguration.standardOSDiscFolder)) searchItems.append(commonConfiguration.standardOSDiscFolder) if not os.path.isdir(commonConfiguration.legacyOSDiscFolder): # worry-warting raise ValueError('The legacy OS installer disc folder does not exist or was not a directory: ' + str(commonConfiguration.legacyOSDiscFolder)) searchItems.append(commonConfiguration.legacyOSDiscFolder) else: raise ValueError('Did not understand the searchItems input: ' + str(searchItems)) # confirm that the item in the list are valid searchContainers = [] for thisItem in searchItems: thisContainer = None try: thisContainer = container(thisItem) except: raise ValueError('Unable to understand the search item: ' + str(thisItem)) if not thisContainer.isContainerType('folder'): # note: dmg's are "folders" raise ValueError('The search item "%s" was a %s, which is not useable .Must be dmg, volume, or folder' % (thisItem, thisContainer.getType())) searchContainers.append(thisContainer) # -- search through the folders # legacy search mode if allowedBuilds is None: for thisContainer in searchContainers: results = { 'InstallerDisc':None, 'SupportingDiscs':[] } innerSearchItems = None if thisContainer.isContainerType('dmg'): innerSearchItems = [thisContainer] else: innerSearchItems = [os.path.join(thisContainer.getWorkingPath(), internalItem) for internalItem in os.listdir(thisContainer.getWorkingPath())] for thisItem in innerSearchItems: if hasattr(thisItem, 'isContainerType'): results['InstallerDisc'] = thisItem else: candidateConainter = None try: candidateConainter = container(thisItem) except Exception, e: #print e pass # we are in legacy mode, so fail if the name matches one of our preset names if os.path.basename(candidateConainter.getStoragePath()) in legacyOSDiscNames or os.path.basename(thisItem) in legacyOSDiscNames: if candidateConainter is None or not candidateConainter.isContainerType('dmg'): # note: volume would work here as well but needs InstaDMG support raise ValueError('In legacy mode the item "%s" was named like an installer disc, but was not a dmg' % thisItem) results['InstallerDisc'] = candidateConainter elif candidateConainter is not None and candidateConainter.isContainerType('dmg'): # note: volume would work here as well but needs InstaDMG support results['SupportingDiscs'].append(candidateConainter) if results['InstallerDisc'] is not None: macOSInformation = results['InstallerDisc'].getMacOSInformation() if macOSInformation is not None and macOSInformation['macOSInstallerDisc'] is True: return results else: raise ValueError('In legacy mode the item "%s" was named like an installer disc, but was not' % results['InstallerDisc'].getWorkingPath())
def findInstallerDisc(allowedBuilds=None, searchItems=None, systemType='MacOS X Client'): # -- validate input if systemType != 'MacOS X Client': raise NotImplementedError( 'At this time only MacOS X Client is supported') # allowedBuilds parsedAllowedBuilds = [] if hasattr(allowedBuilds, 'capitalize'): for thisItem in allowedBuilds.split(','): try: parsedAllowedBuilds.append( macOSXVersionParser.macOSXVersion(thisItem.strip())) except: raise ValueError( 'The allowedBuild item is not in the correct form: ' + thisItem) elif hasattr(allowedBuilds, '__iter__'): if len(allowedBuilds) == 0: raise ValueError('There were no allowBuilds provided') for thisValue in allowedBuilds: try: parsedAllowedBuilds.append( macOSXVersionParser.macOSXVersion(thisValue)) except: raise ValueError( 'The allowedBuild item is not in the correct form: ' + thisValue) elif allowedBuilds is not None: raise ValueError('Unable to understand the allowedBuild provided: ' + str(allowedBuilds)) # -- confirm or setup search folders if hasattr(searchItems, 'capitalize'): # the path to a single item searchItems = [searchItems] elif hasattr(searchItems, '__iter__'): # array of paths to search items, so nothing to do pass elif searchItems is None: searchItems = [] if allowedBuilds is not None: # non-legacy mode if not os.path.isdir( commonConfiguration.standardOSDiscFolder): # worry-warting raise ValueError( 'The legacy OS installer disc folder does not exist or was not a directory: ' + str(commonConfiguration.standardOSDiscFolder)) searchItems.append(commonConfiguration.standardOSDiscFolder) if not os.path.isdir( commonConfiguration.legacyOSDiscFolder): # worry-warting raise ValueError( 'The legacy OS installer disc folder does not exist or was not a directory: ' + str(commonConfiguration.legacyOSDiscFolder)) searchItems.append(commonConfiguration.legacyOSDiscFolder) else: raise ValueError('Did not understand the searchItems input: ' + str(searchItems)) # confirm that the item in the list are valid searchContainers = [] for thisItem in searchItems: thisContainer = None try: thisContainer = container(thisItem) except: raise ValueError('Unable to understand the search item: ' + str(thisItem)) if not thisContainer.isContainerType( 'folder'): # note: dmg's are "folders" raise ValueError( 'The search item "%s" was a %s, which is not useable .Must be dmg, volume, or folder' % (thisItem, thisContainer.getType())) searchContainers.append(thisContainer) # -- search through the folders # legacy search mode if allowedBuilds is None: for thisContainer in searchContainers: results = {'InstallerDisc': None, 'SupportingDiscs': []} innerSearchItems = None if thisContainer.isContainerType('dmg'): innerSearchItems = [thisContainer] else: innerSearchItems = [ os.path.join(thisContainer.getWorkingPath(), internalItem) for internalItem in os.listdir( thisContainer.getWorkingPath()) ] for thisItem in innerSearchItems: if hasattr(thisItem, 'isContainerType'): results['InstallerDisc'] = thisItem else: candidateConainter = None try: candidateConainter = container(thisItem) except Exception, e: #print e pass # we are in legacy mode, so fail if the name matches one of our preset names if os.path.basename(candidateConainter.getStoragePath( )) in legacyOSDiscNames or os.path.basename( thisItem) in legacyOSDiscNames: if candidateConainter is None or not candidateConainter.isContainerType( 'dmg' ): # note: volume would work here as well but needs InstaDMG support raise ValueError( 'In legacy mode the item "%s" was named like an installer disc, but was not a dmg' % thisItem) results['InstallerDisc'] = candidateConainter elif candidateConainter is not None and candidateConainter.isContainerType( 'dmg' ): # note: volume would work here as well but needs InstaDMG support results['SupportingDiscs'].append(candidateConainter) if results['InstallerDisc'] is not None: macOSInformation = results[ 'InstallerDisc'].getMacOSInformation() if macOSInformation is not None and macOSInformation[ 'macOSInstallerDisc'] is True: return results else: raise ValueError( 'In legacy mode the item "%s" was named like an installer disc, but was not' % results['InstallerDisc'].getWorkingPath())
def test_In(self): c = container() file = ["1 1 3 4 5 6", "2 1 1 2 3 4"] c.InData(file) self.assertEqual(len(c.matrices), 2)
from container import container try: ifst = open("input.txt").read().split("\n") except: exit() ofst = open("output.txt", "w") ofst1 = open("output1.txt", "w") print("Start.") c = container() c.InData(ifst) ofst.write("Filled container.\n") c.Sort() c.OutData(ofst) c.OutDataFirstType(ofst1) c.Clear() ofst.write("Empty container.\n") c.OutData(ofst) print("Stop") ofst.close() ofst1.close()
if thisContainer.isContainerType('dmg'): innerSearchItems = [thisContainer] else: innerSearchItems = [os.path.join(thisContainer.getWorkingPath(), internalItem) for internalItem in os.listdir(thisContainer.getWorkingPath())] # ToDo: try to find the exact items by name first # find the item that matches the frontmost allowedBuilds item for thisItem in innerSearchItems: baseImageCandidate = None if hasattr(thisItem, 'isContainerType'): baseImageCandidate = thisItem else: try: baseImageCandidate = container(thisItem) except: continue if not baseImageCandidate.isContainerType('dmg'): continue macOSInformation = baseImageCandidate.getMacOSInformation() if macOSInformation['macOSInstallerDisc'] is not True: continue if macOSInformation['macOSType'] != 'MacOS X Client': continue # see if one of the patterns in allowedBuilds matches
root_container.childs[1].add_container( container.container(0, 0, 0, [], 0.5, 0, 4, True, 0)) print(windowlist) root_container.childs[0].hwnd = int(windowlist[0]) print( win32gui.GetWindowText(windowlist[0]) + " " + str(windowlist[0]) + "\n") index = 0 test1 = windowlist test1.pop(0) for hwnd in test1: try: win32gui.ShowWindow(hwnd, win32con.SW_NORMAL) root_container.childs[1].childs[index].hwnd = int(hwnd) print(win32gui.GetWindowText(hwnd) + " " + str(hwnd) + "\n") except Exception as e: print("Error Type 1\n" + str(hwnd)) index += 1 def main(): add_all_windows() debug_init() place_Windows(root_container, 0, 0) if __name__ == '__main__': root_container = container.container(system_width, system_height, 0, [], 1, 0, 0, False, 0) main()