def setUp(self) -> None: self.filled_by_admin = 0 self.responded = 0 self.all_guests = 0 self.viewed = 0 self.all_invites = [] for i in range(0, 100): guest = self._generate_random_guest() if i % 3 == 0: guest.last_viewed = datetime.datetime.utcnow() self.viewed += 1 if i % 6 == 0: guest.number_of_guests = random.randint(1, 4) guest.will_attend = True self.all_guests += guest.number_of_guests guest.last_responded = datetime.datetime.utcnow() if random.randint(1, 4) % 4 == 1: guest.favourite_music = petname.generate() if random.randint(1, 4) % 4 == 3: guest.food_allergies = petname.generate() self.responded += 1 if i % 5 == 0 and not guest.last_responded: guest.filled_by_admin = True guest.will_attend = i % 10 == 0 guest.number_of_guests = random.randint( 1, 4) if guest.will_attend else 0 self.all_guests += guest.number_of_guests self.filled_by_admin += 1 if i % 9 == 0 and not guest.last_responded and not guest.filled_by_admin: guest.will_attend = False guest.last_responded = datetime.datetime.utcnow() self.responded += 1 self.all_invites.append(guest) guest.save()
def get_nickname(self): rand_id = petname.generate() with self.lock: while rand_id in self.nicknames.keys(): rand_id = petname.generate() self.nicknames[rand_id] = {"appeared": time(), "last_seen": time()} return rand_id
def __init__(self, templates_path, namespace_count, host_count, path_count, tls_ratio, deployment_name, deployment_image, deployment_replicas, ingress_domain): self.namespace_count = namespace_count self.host_count = host_count self.path_count = path_count self.tls_ratio = tls_ratio self.deployment_name = deployment_name self.deployment_image = deployment_image self.deployment_replicas = deployment_replicas self.ingress_domain = ingress_domain self.templates_path = templates_path self.namespace_list = [] for i in range(1,self.namespace_count + 1): name = petname.generate(1) + str(i) self.namespace_list.append(name) self.path_list = [] for i in range(1,self.path_count + 1): name = petname.generate(1) + str(i) self.path_list.append(name) self.generate_host_path() if args.path_count > 1: self.generate_host_mpath()
def genAnimal() -> dict: """ Generates and returns a dictionary to describe a mutant animal. """ animal = {} heads = ["snake", "bull", "lion", "raven", "bunny"] animal["head"] = heads[rand.randint(0, len(heads) - 1)] animal["body"] = pn.generate(words=1) + "-" + pn.generate(words=1) animal["arms"] = rand.randint(2, 10) animal["legs"] = rand.randint(3, 12) animal["tails"] = animal["arms"] + animal["legs"] return animal
def random_client_name(words=3, letters=6, hostname=False): """Generate a pseudorandom but human-readable Oauth client name """ client_name = petname.generate(words=words, letters=letters) if hostname: client_name = socket.gethostname().lower() + '-' + client_name return client_name
def generate(model_num): if model_num == 0: new_name = 'bootstrap' else: new_name = petname.generate() full_name = "%06d-%s" % (model_num, new_name) return full_name
def randomPeople(names=150): people = [(uid, name) for uid, name in zip([ ''.join(choices(ascii_lowercase, k=3)) + ''.join(choices(digits, k=3)) for i in range(names) ], [generate(words=3, separator=' ').title() for i in range(names)])] assert (len(set(people)) == names) # No duplicates, pls return people
def new_run_dir(self, base_dir): cond = True while cond: rname = petname.generate(letters=8) run_dir = os.path.join(base_dir, rname) cond = os.path.isdir(run_dir) os.makedirs(run_dir) print('Saving run data in', run_dir) return run_dir
def new_run_dir(): run_dir = '/cs/experiments/err_detect/ru/ru_new_run' cond = True while cond: rname = petname.generate(letters=8) run_dir = os.path.join(run_dir, rname) cond = os.path.isdir(run_dir) os.makedirs(run_dir) return run_dir
def generate(model_num): if model_num == 0: new_name = 'bootstrap' elif go.N == 19: new_name = random.choice(NAMES) else: new_name = petname.generate() full_name = "%06d-%s" % (model_num, new_name) return full_name
def generate(model_num): """Generates a new model name, given the model number.""" if model_num == 0: new_name = 'bootstrap' elif go.N == 19: new_name = random.choice(NAMES) else: new_name = petname.generate() full_name = "%06d-%s" % (model_num, new_name) return full_name
def genAnimal() -> dict: """ Returns ------- dict A complete description of a generated animal according to Dr. Moreau's specifications: - A head randomly chosen from this list: snake, bull, lion, raven, bunny - A body made up of two animals randomly chosen using the petname library - A random number of arms; must be an even number and between 2-10, inclusive - A random number of legs; must be a multiple of three and between 3-12, inclusive - A non-random number of tails that is equal to the sum of arms and legs """ animal = {} heads = ["snake", "bull", "lion", "raven", "bunny"] animal["head"] = heads[rand.randint(0, len(heads) - 1)] animal["body"] = pn.generate(words=1) + "-" + pn.generate(words=1) animal["arms"] = getRandMultiple(2, 10, 2) animal["legs"] = getRandMultiple(3, 12, 3) animal["tails"] = animal["arms"] + animal["legs"] return animal
def name_gen_petname(**kwargs): words = kwargs.get('words', random.randint(1, 4)) word_len = kwargs.get('word_len', random.randint(3, 10)) first_last = kwargs.get('first_last', 'first') name = petname.generate(words, ' ', word_len) if first_last == 'first': return ' '.join(name.split(' ')[:-1]) else: return name.split(' ')[-1]
def generate_host_path(self): file_loader = jinja2.FileSystemLoader(self.templates_path) env = jinja2.Environment(loader=file_loader) template = env.get_template('ingress-host-path.j2') for namespace in self.namespace_list: for idx in range(1,self.host_count + 1): output = template.render(deployment_name=self.deployment_name, deployment_image=self.deployment_image, deployment_replicas=self.deployment_replicas, deployment_namespace=namespace, idx = petname.generate(1) + str(idx), ingress_domain=self.ingress_domain) print(output)
def generate(name, size): """Generates new dataset.""" wave_fun = DampedSineWave() x, y = generate_random_fun_samples(wave_fun, size, (-4 * math.pi, 4 * math.pi), noise=True) dataset_data = {'x': x.tolist(), 'y': y.tolist()} if not name: name = petname.generate(3) dataset = Dataset(name=name, input_size=1, output_size=1, size=size, source_function=wave_fun.latex_repr, data=dataset_data) db.session.add(dataset) db.session.commit() return True
def main(): args = parse_args() name = args.name or petname.generate() # Parse microstack.rc # TODO: we need a share lib that does this in a more robust way. mstackrc = '{SNAP_COMMON}/etc/microstack.rc'.format(**os.environ) with open(mstackrc, 'r') as rc_file: for line in rc_file.readlines(): if not line.startswith('export'): continue key, val = line[7:].split('=') os.environ[key.strip()] = val.strip() return launch(name, args)
def multipass(self): self.machine = petname.generate() self.prefix = ['multipass', 'exec', self.machine, '--'] check('sudo', 'snap', 'install', '--classic', '--edge', 'multipass') check('multipass', 'launch', '--cpus', '2', '--mem', '8G', self.distro, '--name', self.machine) check('multipass', 'copy-files', self.snap, '{}:'.format(self.machine)) # Figure out machine's ip info = check_output('multipass', 'info', self.machine, '--format', 'json') info = json.loads(info) self.horizon_ip = info['info'][self.machine]['ipv4'][0]
def multipass(self): self.MACHINE = petname.generate() self.PREFIX = ['multipass', 'exec', self.MACHINE, '--'] check('sudo', 'snap', 'install', '--classic', '--edge', 'multipass') check('multipass', 'launch', '--cpus', '2', '--mem', '8G', self.DISTRO, '--name', self.MACHINE) check('multipass', 'copy-files', self.SNAP, '{}:'.format(self.MACHINE)) # Figure out machine's ip info = check_output('multipass', 'info', self.MACHINE, '--format', 'json') info = json.loads(info) self.HORIZON_IP = info['info'][self.MACHINE]['ipv4'][0]
def new_id(self) -> str: """Returns a unique (not used by any active poll) human understandable id """ # List of Tuples: # First element is the number of words to try # Second element is the number of repetitions (-1 = infinity) tries = [(1, 10), (2, -1)] for num_words, num_reps in tries: cnt = 0 while cnt != num_reps: cnt += 1 possible_id = petname.generate(words=num_words).lower() if possible_id not in self.by_id: return possible_id raise exp.RocketBotPollException('Could not find a new id')
def __init__(self, *, seed=None): if seed is None: self.seed = petname.generate(3, letters=10) else: self.seed = seed self.random = random.Random() self.random.seed(self.seed) self.data = None self.rounds = 0 self.royale = None self.current_day = 0 self.current_event_type = None self.current_arena = None self.running_arena = False self.feasted = False self.unreported_deaths = []
def run_everything(args): """Function that runs everything in the script""" project = None zone = None user_pubkey = None login_shape = None cluster_name = None branch = None ansible_branch = None checkpoint_file = "checkpoint_input.json" if os.path.exists(checkpoint_file): try: with open(checkpoint_file, "r") as FILE: data = json.load(FILE) zone = str(data["zone"]) project = str(data["project"]) user_pubkey = str(data["pubkey"]) login_shape = str(data["shape"]) cluster_name = str(data["name"]) if "branch" in data: branch = str(data["branch"]) if "ansible_branch" in data: ansible_branch = str(data["ansible_branch"]) except Exception as e: print(f"[ERROR] Error reading checkpoint file: {e}") print(f"[ERROR] Remove {checkpoint_file}") sys.exit(-1) elif args.json: try: with open(args.json, "r") as FILE: data = json.load(FILE) except Exception as e: print(f"Failed to read parameters from json file " f"'{args.json}': {e}") sys.exit(-1) if "zone" in data: zone = str(data["zone"]) else: zone = default_zone if "project" in data: project = str(data["project"]) if "pubkey" in data: user_pubkey = str(data["pubkey"]) if "shape" in data: login_shape = str(data["shape"]) else: login_shape = default_shape if "branch" in data: branch = str(data["branch"]) else: branch = default_branch if "ansible_branch" in data: ansible_branch = str(data["ansible_branch"]) else: if args.zone: zone = str(args.zone) if args.project: project = str(args.project) if args.key: user_pubkey = str(args.key) if args.shape: login_shape = str(args.shape) if args.branch: branch = str(args.branch) if args.ansible_branch: ansible_branch = str(args.ansible_branch) while not project: project = input("Which google project should the cluster be " "created in? ") while not zone: zone = input(f"Which zone should the cluster run in " f"[{default_zone}]? ") if not zone: zone = default_zone while not login_shape: login_shape = input(f"What shape should be used for the login node " f"[{default_shape}]? ") if not login_shape: login_shape = default_shape while not user_pubkey: user_pubkey = input("Please copy here you public SSH key: ") while not branch: branch = input(f"Which branch should be used of CitC " f"[{default_branch}]? ") if not branch: branch = default_branch user_keyfile = os.path.expanduser(user_pubkey) if user_pubkey.startswith("http"): import urllib.request s = urllib.request.urlopen(user_pubkey).read().decode() user_pubkey = str(s) elif not user_keyfile.startswith("ssh"): if os.path.exists(user_keyfile): user_pubkey = open(user_keyfile, "r").readline().strip() else: print(f"[ERROR] Unable to open keyfile {user_keyfile}") sys.exit(-1) if not cluster_name: cluster_name = petname.generate() # save the checkpoint input - need to generate the cluster name if not os.path.exists(checkpoint_file): with open(checkpoint_file, "w") as FILE: data = {"zone": zone, "project": project, "pubkey": user_pubkey, "shape": login_shape, "name": cluster_name, "branch": branch} if ansible_branch: data["ansible_branch"] = ansible_branch FILE.write(json.dumps(data)) region = "-".join(zone.split("-")[0:-1]) print(f"\nCreating a Cluster-in-the-Cloud called {cluster_name}") print(f"This will be created in the project {project}") print(f"The cluster will be created in the region {region}") print(f"The cluster will be created in the zone {zone}") print(f"The login node will be of shape {login_shape}\n\n") if dry: print("*** DRY RUN ***\n\n") if os.path.exists("citc-terraform"): if not dry: os.chdir("citc-terraform") print(os.getcwd()) run_command("git pull") else: run_command(f"git clone --branch {branch} " f"https://github.com/ACRC/citc-terraform.git") if not dry: os.chdir("citc-terraform") print(os.getcwd()) if not has_completed("gcloud_set_project"): run_command(f"gcloud config set project {project}") if not has_completed("gcloud_login"): run_command("gcloud auth login") if not has_completed("gcloud_enable_services"): run_command(f"gcloud services enable compute.googleapis.com " f"iam.googleapis.com " f"cloudresourcemanager.googleapis.com " f"file.googleapis.com") citc_name = f"citc-admin-{cluster_name}" if not has_completed("gcloud_add_account"): # Create an account to run terraform - this shows that the user # has permission to run the subsequent steps. If these fail, then # we can send back a meaningful error message run_command(f"gcloud iam service-accounts create {citc_name} " f"--display-name {citc_name}") run_command(f"gcloud projects add-iam-policy-binding {project} " f"--member serviceAccount:" f"{citc_name}@{project}.iam.gserviceaccount.com " "--role='roles/editor'") run_command(f"gcloud projects add-iam-policy-binding {project} " f"--member serviceAccount:" f"{citc_name}@{project}.iam.gserviceaccount.com " "--role='roles/resourcemanager.projectIamAdmin'") run_command("gcloud iam service-accounts keys create " "citc-terraform-credentials.json " f"--iam-account " f"{citc_name}@{project}.iam.gserviceaccount.com") #### #### Should have everything installed here and have sufficient #### permission to run #### if not has_completed("generate_keys"): run_command(f"ssh-keygen -t rsa -f " f"{os.environ['HOME']}/.ssh/citc-google " f"-C provisioner -N \"\"") if not has_completed("init_terraform"): run_command("terraform init google") if not has_completed("create_tfvars"): # Now create the tfvars file if dry: print("\n===Creating the terraform.tfvars===") FILE = sys.stdout else: FILE = open("terraform.tfvars", "w") FILE.write("# Google Cloud Platform Information\n") FILE.write(f"region = \"{region}\"\n") FILE.write(f"zone = \"{zone}\"\n") FILE.write(f"project = \"{project}\"\n") FILE.write(f"management_shape = \"{login_shape}\"\n") FILE.write(f"credentials = \"citc-terraform-credentials.json\"\n") FILE.write(f"private_key_path = \"~/.ssh/citc-google\"\n") FILE.write(f"public_key_path = \"~/.ssh/citc-google.pub\"\n") if ansible_branch: FILE.write(f"ansible_branch = \"{ansible_branch}\"\n") FILE.write(f"cluster_id = \"{cluster_name}\"\n") if dry: print("\n") else: FILE.close() if not has_completed("terraform_validate"): run_command("terraform validate google") if not has_completed("terraform_plan"): run_command("terraform plan google") if not has_completed("terraform_apply"): run_command("terraform apply -auto-approve google") cmd = "terraform output -no-color -state=terraform.tfstate " \ "ManagementPublicIP" if dry: print(f"[DRY-RUN] {cmd}") cluster_ip = "192.168.0.1" else: print(f"[EXECUTE] {cmd}") try: args = shlex.split(cmd) p = subprocess.run(args, capture_output=True) cluster_ip = p.stdout.decode("utf-8").strip() except Exception as e: print(f"[ERROR] {e}") sys.exit(-1) if not has_completed("save_pubkey"): # upload ${USER_PUBKEY} to citc-user .ssh folder if dry: FILE = sys.stdout print("\n===Creating citc-admin.pub===") else: FILE = open("citc-admin.pub", "w") FILE.write(f"{user_pubkey}\n") if dry: print("\n") else: FILE.close() scp_options = "-o StrictHostKeyChecking=no -i ~/.ssh/citc-google" if not has_completed("upload_pubkey"): run_command(f"scp {scp_options} citc-admin.pub " f"provisioner@{cluster_ip}:") if not has_completed("upload_terraform_files"): if not dry: os.chdir("..") print(os.getcwd()) run_command("tar -zcvf terraform.tgz .ssh " "citc-terraform " "checkpoint_input.json") run_command(f"scp {scp_options} terraform.tgz " f"provisioner@{cluster_ip}:") print("\n\nYour Cluster-in-the-Cloud has now been created :-)") print("Proceed to the next stage. Connect to the cluster") print(f"by running 'ssh citc@{cluster_ip}'\n") has_completed("everything") return cluster_ip
def __init__(self, distribution): self.distribution = distribution self.name = petname.generate() self._launch()
def random_pet(words=2, separator="-"): return petname.generate(words, separator)
def validate_author(author): if not author or author == 'Anonymous': author = petname.generate(2, ' ') return author
def __init__(self, ws, stahp, count): self.ws = ws self.name = petname.generate() self.stahp = stahp self.count = count
def random(self): name = petname.generate() speed = RandomSpeed() horse = Horse(name, speed) return horse
def getbody(): body1 = petname.generate(words = 1) body2 = petname.generate(words = 1) return body1 + '-' + body2
def test_works(self): words = 3 sep = '-' name = petname.generate(words, sep) self.assertEqual(len(name.split(sep)), words)
help='size of network intermediate layer (default: 64)') parser.add_argument('--dataset', '--data', default='hotel', choices=['hotel'], help='pick a specific dataset (default: "hotel")') args = parser.parse_args() writer = SummaryWriter() global_step = 0 # ========== set input/output files ============ dataset_name = args.dataset model_name = args.model if model_name is None: model_name = petname.generate() input_file = 'hotel-8-12.npz' model_file = 'trained_models/' + model_name + '-' + dataset_name + '.pt' # FIXME: ====== training hyper-parameters ====== # Unrolled GAN n_unrolling_steps = args.unrolling_steps # Info GAN use_info_loss = True loss_info_w = 0.5 n_latent_codes = 2 # L2 GAN use_l2_loss = False use_variety_loss = False loss_l2_w = 0.5 # WARNING for both l2 and variety # Learning Rate
def fill(db_connection): # Fill table ARENA venues = ['Arena', 'Stadium', 'Bowl', 'Dome', 'Colosseum', 'Field', 'Garden', 'Ground', 'Oval'] arena_types = ['Fire', 'Water', 'Earth', 'Sky', 'Metal', 'Electricity'] arena_entries = [( random.choice(['', 'The ']) + names.get_full_name() + ' ' + random.choice(venues), # name random.choice(arena_types) # type ) for _ in range(198)] arena_entries.append(('Skyfall', 'Earth')) arena_entries.append(('Kirby', 'Sky')) db_connection.cursor().executemany('INSERT INTO arena VALUES (?, ?)', arena_entries) print('Filled table ARENA...') # Fill table ARENA_RULES arena_rules_entries = [( arena_entries[int(i / 2)][0], # Arena name fk lorem.sentence() # Arena rules ) for i in range(400)] db_connection.cursor().executemany('INSERT INTO arena_rules VALUES (?, ?)', arena_rules_entries) print('Filled table ARENA_RULES...') # Fill CHIEF_ORGANIZER chief_organizer_entries = [( 4, # Authorization random.getrandbits(32), # Employee ID names.get_first_name(), # First name names.get_last_name(), # Last name round(random.randrange(70000, 100000) / 500) * 500 # Salary ) for _ in range(200)] db_connection.cursor().executemany('INSERT INTO chief_organizer VALUES (?, ?, ?, ?, ?)', chief_organizer_entries) print('Filled table CHIEF_ORGANIZER...') # Fill REFEREE referee_entries = [( 2, # Authorization random.getrandbits(32), # Employee ID names.get_first_name(), # First name names.get_last_name(), # Last name round(random.randrange(50000, 80000) / 500) * 500 # Salary ) for _ in range(200)] db_connection.cursor().executemany('INSERT INTO referee VALUES (?, ?, ?, ?, ?)', referee_entries) print('Filled table REFEREE...') # Fill TOURNAMENT formats = ['Single Elimination', 'Double Elimination', 'Multilevel', 'Straight Round Robin', 'Round Robin Double Split', 'Round Robin Triple Split', 'Round Robin Quadruple Split', 'Semi Round Robin', 'Ladder', 'Pyramid'] tournament_entries = [( chief_organizer_entries[i][1], # CHIEF_ORGANIZER_FK datetime.datetime.now() + datetime.timedelta(days=28 + random.random() * 56), # END_DATE random.choice(formats), # FORMAT random.randint(1, 500), # MATCH_COUNT ' '.join([lorem.sentence() for _ in range(3)]), # RULES datetime.datetime.now() + datetime.timedelta(days=random.random() * 14), # START_DATE names.get_full_name() + '\'s ' + random.choice(['Tournament', 'Tourney', 'Championship']) # TOURNAMENT_NAME ) for i in range(200)] db_connection.cursor().executemany('INSERT INTO tournament VALUES (?, ?, ?, ?, ?, ?, ?)', tournament_entries) print('Filled table TOURNAMENT...') # Fill TOURNAMENT_PRIZES prizes = ['Cash', 'Car', 'Robot', 'All You Can Eat Pass'] tournament_prizes_entries = [( tournament_entries[i][6], random.choice(prizes) ) for i in range(200)] db_connection.cursor().executemany('INSERT INTO tournament_prizes VALUES (?, ?)', tournament_prizes_entries) print('Filled table TOURNAMENT_PRIZES...') # Fill GAME game_entries = [( arena_entries[random.randint(0, 199)][0], # ARENA_NAME_FK datetime.datetime.now() + datetime.timedelta(days=14 + random.random() * 56), # END_TIME random.getrandbits(32), # GAME_ID 0, # PARTICIPATION_COUNT referee_entries[random.randint(0, 199)][1], # REFEREE_FK datetime.datetime.now() + datetime.timedelta(days=14 + random.random() * 7), # START_TIME tournament_entries[random.randint(0, 199)][6], # TOURNAMENT_NAME_FK ) for _ in range(200)] db_connection.cursor().executemany('INSERT INTO game VALUES (?, ?, ?, ?, ?, ?, ?)', game_entries) print('Filled table GAME...') # Fill ATTENDEE attendee_entries = [( names.get_first_name(), # FIRST_NAME names.get_last_name(), # LAST_NAME game_entries[random.randint(0, 199)][2], # GAME_ID_FK random.getrandbits(32), # TICKET_NUMBER ) for _ in range(2000)] db_connection.cursor().executemany('INSERT INTO attendee VALUES (?, ?, ?, ?)', attendee_entries) print('Filled table ATTENDEE...') # Fill CONCESSIONS_VENDOR concessions_vendor_entries = [( 2, # AUTHORIZATION random.getrandbits(32), # EMPLOYEE_ID names.get_first_name(), # FIRST_NAME names.get_last_name(), # LAST_NAME round(random.randrange(40000, 60000) / 500) * 500, # Salary attendee_entries[random.randint(0, 999)][3] # TICKET_NUMBER_FK ) for _ in range(200)] db_connection.cursor().executemany('INSERT INTO concessions_vendor VALUES (?, ?, ?, ?, ?, ?)', concessions_vendor_entries) print('Filled table CONCESSIONS_VENDOR...') # Fill TICKET_VENDOR ticket_vendor_entries = [( 2, # AUTHORIZATION random.getrandbits(32), # EMPLOYEE_ID names.get_first_name(), # FIRST_NAME names.get_last_name(), # LAST_NAME round(random.randrange(40000, 50000) / 500) * 500, # Salary attendee_entries[random.randint(0, 999)][3] # TICKET_NUMBER_FK ) for _ in range(200)] db_connection.cursor().executemany('INSERT INTO ticket_vendor VALUES (?, ?, ?, ?, ?, ?)', ticket_vendor_entries) print('Filled table TICKET_VENDOR...') # Fill CONTESTANT robot_models = ['Tank', 'Hunter', 'Tactical'] normal_attacks = ['Punch', 'Kick', 'Scratch'] special_attacks = ['Body Slam', 'Uppercut', 'Ram'] titles = ['Champion', 'Contender', 'Star', 'Rising Star', 'Mythic'] contestant_entries = [( random.randint(1, 100), # DEFENSE names.get_first_name(), # FIRST_NAME 100, # HEALTH names.get_last_name(), # LAST_NAME 1, # LOSSES 2, # GAMES_PLAYED game_entries[random.randint(0, 199)][2], # GAME_ID_FK random.choice(robot_models), # MODEL random.choice(normal_attacks), # NORMAL_ATTACK random.randint(1, 10), # PRIMARY_ATK_DAMAGE random.randint(1, 5), # PRIMARY_ATK_KNOCKBACK random.randint(15, 75), # PRIMARY_ATK_ANGLE random.getrandbits(32), # ROBOT_LICENSE petname.generate(separator=' ').title(), # ROBOT_NAME random.randint(3, 15), # SECONDARY_ATK_DAMAGE random.randint(2, 8), # SECONDARY_ATK_KNOCKBACK random.randint(15, 75), # SECONDARY_ATK_ANGLE random.getrandbits(32), # SERIAL_NUMBER random.choice(special_attacks), # SPECIAL_ATTACK random.randint(1, 100), # SPEED random.choice(titles), # TITLE random.randint(1, 100), # WEIGHT 1, # WINS ) for _ in range(200)] db_connection.cursor().executemany('INSERT INTO contestant VALUES \ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', contestant_entries) print('Filled table CONTESTANT...') # Fill RECEPTIONIST receptionist_entries = [( 2, # AUTHORIZATION random.getrandbits(32), # EMPLOYEE_ID names.get_first_name(), # FIRST_NAME names.get_last_name(), # LAST_NAME contestant_entries[random.randint(0, 199)][12], # ROBOT_LICENSE_FK round(random.randrange(40000, 60000) / 500) * 500 # Salary ) for _ in range(200)] db_connection.cursor().executemany('INSERT INTO receptionist VALUES (?, ?, ?, ?, ?, ?)', receptionist_entries) print('Filled table RECEPTIONIST...') # Fill BATTLE for key_1 in range(200): key_2 = random.randint(0, 199) while key_1 == key_2: key_2 = random.randint(0, 199) cmd = 'INSERT INTO battle VALUES (' + str(contestant_entries[key_1][12]) + ', ' \ + str(contestant_entries[key_2][12]) + ')' db_connection.cursor().execute(cmd) print('Filled table BATTLE...') # Set specific robot names contestant_id = db_connection.cursor().execute('SELECT robot_license FROM contestant LIMIT 3;').fetchall() cmd = ''' UPDATE contestant SET robot_name=\'sumilidon\', primary_atk_knockback=200, primary_atk_damage=7, primary_atk_angle=360, secondary_atk_knockback=500, secondary_atk_damage=15, secondary_atk_angle=8 WHERE robot_license={} '''.format(contestant_id[0][0]) db_connection.cursor().execute(cmd) cmd = ''' UPDATE contestant SET robot_name=\'metabee\', primary_atk_knockback=500, primary_atk_damage=12, primary_atk_angle=8, secondary_atk_knockback=200, secondary_atk_damage=9, secondary_atk_angle=4 WHERE robot_license={} '''.format(contestant_id[1][0]) db_connection.cursor().execute(cmd) cmd = 'UPDATE contestant SET robot_name=\'rokusho\' WHERE robot_license={}'.format(contestant_id[2][0]) db_connection.cursor().execute(cmd) db_connection.commit()