How to use get_image_name method in testcontainers-python

Best Python code snippet using testcontainers-python_python

sprites.py

Source:sprites.py Github

copy

Full Screen

...17 self.map[name]['width'] = int(node.attrib.get('width'))18 self.map[name]['height'] = int(node.attrib.get('height'))19 def get_image_rect(self, x, y, w, h):20 return self.spritesheet.subsurface(pg.Rect(x, y, w, h))21 def get_image_name(self, name):22 rect = pg.Rect(self.map[name]['x'], self.map[name]['y'],23 self.map[name]['width'], self.map[name]['height'])24 return self.spritesheet.subsurface(rect)25class Player(pg.sprite.Sprite):26 def __init__(self, game, x, y):27 self.groups = game.all_sprites28 pg.sprite.Sprite.__init__(self, self.groups)29 self.game = game30 self.current_frame = 031 self.last_update = 032 self.load_images()33 self.image = self.standing_frames_d[0]34 self.rect = pg.Rect(0,0,24,24)35 self.walking = True36 self.idle = True37 self.last_dir = 'D'38 self.x = x39 self.y = y40 self.idle = True41 def load_images(self):42 self.standing_frames_l = [self.game.spritesheet_player.get_image_name("Idle-Left-1.png"),43 self.game.spritesheet_player.get_image_name("Idle-Left-2.png"),44 self.game.spritesheet_player.get_image_name("Idle-Left-3.png"),45 self.game.spritesheet_player.get_image_name("Idle-Left-4.png"),46 self.game.spritesheet_player.get_image_name("Idle-Left-5.png"),47 self.game.spritesheet_player.get_image_name("Idle-Left-6.png"),48 self.game.spritesheet_player.get_image_name("Idle-Left-7.png")]49 for frame in self.standing_frames_l:50 frame.set_colorkey(MAGENTA)51 self.standing_frames_r = [self.game.spritesheet_player.get_image_name("Idle-Right-1.png"),52 self.game.spritesheet_player.get_image_name("Idle-Right-2.png"),53 self.game.spritesheet_player.get_image_name("Idle-Right-3.png"),54 self.game.spritesheet_player.get_image_name("Idle-Right-4.png"),55 self.game.spritesheet_player.get_image_name("Idle-Right-5.png"),56 self.game.spritesheet_player.get_image_name("Idle-Right-6.png"),57 self.game.spritesheet_player.get_image_name("Idle-Right-7.png")]58 for frame in self.standing_frames_r:59 frame.set_colorkey(MAGENTA)60 self.standing_frames_u = [self.game.spritesheet_player.get_image_name("Idle-Up-1.png"),61 self.game.spritesheet_player.get_image_name("Idle-Up-2.png"),62 self.game.spritesheet_player.get_image_name("Idle-Up-3.png"),63 self.game.spritesheet_player.get_image_name("Idle-Up-4.png"),64 self.game.spritesheet_player.get_image_name("Idle-Up-5.png"),65 self.game.spritesheet_player.get_image_name("Idle-Up-6.png"),66 self.game.spritesheet_player.get_image_name("Idle-Up-7.png")]67 for frame in self.standing_frames_u:68 frame.set_colorkey(MAGENTA)69 self.standing_frames_d = [self.game.spritesheet_player.get_image_name("Idle-Down-1.png"),70 self.game.spritesheet_player.get_image_name("Idle-Down-2.png"),71 self.game.spritesheet_player.get_image_name("Idle-Down-3.png"),72 self.game.spritesheet_player.get_image_name("Idle-Down-4.png"),73 self.game.spritesheet_player.get_image_name("Idle-Down-5.png"),74 self.game.spritesheet_player.get_image_name("Idle-Down-6.png"),75 self.game.spritesheet_player.get_image_name("Idle-Down-7.png")]76 for frame in self.standing_frames_d:77 frame.set_colorkey(MAGENTA)78 self.walk_frames_r = [self.game.spritesheet_player.get_image_name("Walk-Right-1.png"),79 self.game.spritesheet_player.get_image_name("Walk-Right-2.png"),80 self.game.spritesheet_player.get_image_name("Walk-Right-3.png"),81 self.game.spritesheet_player.get_image_name("Walk-Right-4.png")]82 for frame in self.walk_frames_r:83 frame.set_colorkey(MAGENTA)84 self.walk_frames_l = [self.game.spritesheet_player.get_image_name("Walk-Left-1.png"),85 self.game.spritesheet_player.get_image_name("Walk-Left-2.png"),86 self.game.spritesheet_player.get_image_name("Walk-Left-3.png"),87 self.game.spritesheet_player.get_image_name("Walk-Left-4.png")]88 for frame in self.walk_frames_l:89 frame.set_colorkey(MAGENTA)90 self.walk_frames_u = [self.game.spritesheet_player.get_image_name("Walk-Up-1.png"),91 self.game.spritesheet_player.get_image_name("Walk-Up-2.png"),92 self.game.spritesheet_player.get_image_name("Walk-Up-3.png"),93 self.game.spritesheet_player.get_image_name("Walk-Up-4.png")]94 for frame in self.walk_frames_u:95 frame.set_colorkey(MAGENTA)96 self.walk_frames_d = [self.game.spritesheet_player.get_image_name("Walk-Down-1.png"),97 self.game.spritesheet_player.get_image_name("Walk-Down-2.png"),98 self.game.spritesheet_player.get_image_name("Walk-Down-3.png"),99 self.game.spritesheet_player.get_image_name("Walk-Down-4.png")]100 for frame in self.walk_frames_d:101 frame.set_colorkey(MAGENTA)102 def move(self, dx=0, dy=0):103 if not self.collide_with_walls(dx, dy):104 self.x += dx105 self.y += dy106 def collide_with_walls(self, dx=0, dy=0):107 for wall in self.game.walls:108 if wall.x == self.x + dx and wall.y == self.y + dy:109 return True110 return False111 def update(self):112 self.animate(self.game.state)113 self.rect.x = self.x * TILESIZE114 self.rect.y = self.y * TILESIZE115 def animate(self, state):116 now = pg.time.get_ticks()117 #print(state)118 if self.walking:119 if now - self.last_update > 100:120 self.last_update = now121 self.current_frame = (self.current_frame + 1) % len(self.walk_frames_r)122 bottom = self.rect.bottom123 if state =='R':124 self.image = self.walk_frames_r[self.current_frame]125 elif state == 'L':126 self.image = self.walk_frames_l[self.current_frame]127 elif state == 'U':128 self.image = self.walk_frames_u[self.current_frame]129 elif state == 'D':130 self.image = self.walk_frames_d[self.current_frame]131 self.rect = self.image.get_rect()132 self.rect.bottom = bottom133 if self.idle:134 if now - self.last_update > 250:135 self.last_update = now136 self.current_frame = (self.current_frame + 1) % len(self.standing_frames_d)137 bottom = self.rect.bottom138 if self.last_dir == 'D':139 self.image = self.standing_frames_d[self.current_frame]140 elif self.last_dir == 'U':141 self.image = self.standing_frames_u[self.current_frame]142 elif self.last_dir == 'R':143 self.image = self.standing_frames_r[self.current_frame]144 elif self.last_dir == 'L':145 self.image = self.standing_frames_l[self.current_frame]146 self.rect = self.image.get_rect()147 self.rect.bottom = bottom148class Enemy(pg.sprite.Sprite):149 def __init__(self, game, x, y):150 self.groups = game.all_sprites, game.mobs151 pg.sprite.Sprite.__init__(self, self.groups)152 self.game = game153 self.current_frame = 0154 self.last_update = 0155 self.load_images()156 self.image = self.standing_frames_d[0]157 self.rect = pg.Rect(0,0,24,24)158 self.walking = True159 self.idle = True160 self.last_dir = 'D'161 self.x = x162 self.y = y163 self.idle = True164 def load_images(self):165 self.standing_frames_l = [self.game.spritesheet_enemy_1.get_image_name("Idle-Left-1.png"),166 self.game.spritesheet_enemy_1.get_image_name("Idle-Left-2.png"),167 self.game.spritesheet_enemy_1.get_image_name("Idle-Left-3.png"),168 self.game.spritesheet_enemy_1.get_image_name("Idle-Left-4.png")]169 for frame in self.standing_frames_l:170 frame.set_colorkey(MAGENTA)171 self.standing_frames_r = [self.game.spritesheet_enemy_1.get_image_name("Idle-Right-1.png"),172 self.game.spritesheet_enemy_1.get_image_name("Idle-Right-2.png"),173 self.game.spritesheet_enemy_1.get_image_name("Idle-Right-3.png"),174 self.game.spritesheet_enemy_1.get_image_name("Idle-Right-4.png")]175 for frame in self.standing_frames_r:176 frame.set_colorkey(MAGENTA)177 self.standing_frames_u = [self.game.spritesheet_enemy_1.get_image_name("Idle-Up-1.png"),178 self.game.spritesheet_enemy_1.get_image_name("Idle-Up-2.png"),179 self.game.spritesheet_enemy_1.get_image_name("Idle-Up-3.png"),180 self.game.spritesheet_enemy_1.get_image_name("Idle-Up-4.png")]181 for frame in self.standing_frames_u:182 frame.set_colorkey(MAGENTA)183 self.standing_frames_d = [self.game.spritesheet_enemy_1.get_image_name("Idle-Down-1.png"),184 self.game.spritesheet_enemy_1.get_image_name("Idle-Down-2.png"),185 self.game.spritesheet_enemy_1.get_image_name("Idle-Down-3.png"),186 self.game.spritesheet_enemy_1.get_image_name("Idle-Down-4.png")]187 for frame in self.standing_frames_d:188 frame.set_colorkey(MAGENTA)189 self.walk_frames_r = [self.game.spritesheet_enemy_1.get_image_name("Walk-Right-1.png"),190 self.game.spritesheet_enemy_1.get_image_name("Walk-Right-2.png"),191 self.game.spritesheet_enemy_1.get_image_name("Walk-Right-3.png"),192 self.game.spritesheet_enemy_1.get_image_name("Walk-Right-4.png")]193 for frame in self.walk_frames_r:194 frame.set_colorkey(MAGENTA)195 self.walk_frames_l = [self.game.spritesheet_enemy_1.get_image_name("Walk-Left-1.png"),196 self.game.spritesheet_enemy_1.get_image_name("Walk-Left-2.png"),197 self.game.spritesheet_enemy_1.get_image_name("Walk-Left-3.png"),198 self.game.spritesheet_enemy_1.get_image_name("Walk-Left-4.png")]199 for frame in self.walk_frames_l:200 frame.set_colorkey(MAGENTA)201 self.walk_frames_u = [self.game.spritesheet_enemy_1.get_image_name("Walk-Up-1.png"),202 self.game.spritesheet_enemy_1.get_image_name("Walk-Up-2.png"),203 self.game.spritesheet_enemy_1.get_image_name("Walk-Up-3.png"),204 self.game.spritesheet_enemy_1.get_image_name("Walk-Up-4.png")]205 for frame in self.walk_frames_u:206 frame.set_colorkey(MAGENTA)207 self.walk_frames_d = [self.game.spritesheet_enemy_1.get_image_name("Walk-Down-1.png"),208 self.game.spritesheet_enemy_1.get_image_name("Walk-Down-2.png"),209 self.game.spritesheet_enemy_1.get_image_name("Walk-Down-3.png"),210 self.game.spritesheet_enemy_1.get_image_name("Walk-Down-4.png")]211 for frame in self.walk_frames_d:212 frame.set_colorkey(MAGENTA)213 def move(self, dx=0, dy=0):214 if not self.collide_with_walls(dx, dy):215 self.x += dx216 self.y += dy217 def collide_with_walls(self, dx=0, dy=0):218 for wall in self.game.walls:219 if wall.x == self.x + dx and wall.y == self.y + dy:220 return True221 return False222 def update(self):223 self.animate(self.game.state)224 self.rect.x = self.x * TILESIZE...

Full Screen

Full Screen

start_container.sh

Source:start_container.sh Github

copy

Full Screen

...5import time6import argparse7DEFNAME="singularity.def"8EXP_PATH="/git/sferes2/exp/"9def get_image_name():10 return f"{os.path.basename(os.path.dirname(os.getcwd()))}_v2_ffmpeg.sif"11def build_sandbox():12 #check if the sandbox has already been created13 image_name = get_image_name()14 if os.path.exists(image_name):15 return16 17 print(f"{image_name} does not exist, building it now from {DEFNAME}")18 assert os.path.exists(DEFNAME) #exit if defname is not found19 #run commands20 command = os.popen(f"singularity build --force --fakeroot --sandbox {image_name} {DEFNAME}")21 output = command.read()[:-1]22 23 24def run_container(nvidia): 25 image_name = get_image_name()26 27 additional_args = ""28 if nvidia:29 print("Nvidia runtime ON")30 additional_args += "--nv"31 #command = f"singularity shell -w {image_name}"32 command = f"singularity shell {additional_args} --bind {os.path.dirname(os.getcwd())}:{EXP_PATH}/{image_name[:-4]} {image_name}"33 subprocess.run(command.split())34 35 36def main():37 parser = argparse.ArgumentParser(description='Build a sandbox container and shell into it.')38 parser.add_argument('-n', '--nv', action='store_true', help='enable experimental Nvidia support')39 ...

Full Screen

Full Screen

texturepack.py

Source:texturepack.py Github

copy

Full Screen

...5# python .\texturepack.py .\UIFrames.json6assert(len(sys.argv) == 2)7with open(sys.argv[1]) as f:8 info = json.loads(f.read())9def get_image_name(file_name):10 name, ext = file_name.split(".")11 assert(ext in ("tga", "svg", "png"))12 return name13assert(info['meta']['scale'] == "1")14total_w = info['meta']['size']['w']15total_h = info['meta']['size']['h']16name = get_image_name(info['meta']['image'])17OUTER_TEMPLATE = """18\t\twidth = {},19\t\theight = {},20\t\tcoord = {{21{}22\t\t}}23"""24inner_parts = []25for file_name, frame_info in info['frames'].items():26 file_name = get_image_name(file_name)27 assert(not frame_info['trimmed'] and not frame_info['rotated'])28 x = frame_info['frame']['x']29 y = frame_info['frame']['y']30 w = frame_info['frame']['w']31 h = frame_info['frame']['h']32 inner_parts += ["\t\t\t[\"{}\"] = {{ {}, {}, {}, {} }}".format(file_name, x, x + w, y, y + h)]33inner_parts.sort()34with open(name + ".lua", 'w') as f:...

Full Screen

Full Screen

food.py

Source:food.py Github

copy

Full Screen

...10 def get_position(self):11 return self.__x, self.__y12 def get_points(self):13 return self.__points14 def get_image_name(self):15 pass16class Banana(Food):17 def __init__(self, pos_x, pos_y):18 super().__init__(20, 10, pos_x, pos_y)19 def get_image_name(self):20 return 'bananas.png'21class Apple(Food):22 def __init__(self, pos_x, pos_y):23 super().__init__(10, 20, pos_x, pos_y)24 def get_image_name(self):25 return 'apple.png'26class Cherry(Food):27 def __init__(self, pos_x, pos_y):28 super().__init__(5, 50, pos_x, pos_y)29 def get_image_name(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run testcontainers-python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful