def clone(): cave_moss = thing.Thing('cave moss', __file__) cave_moss.set_description( 'cave moss', 'This is some strange moss growing in the cave.') cave_moss.add_adjectives('cave') cave_moss.add_names('moss') return cave_moss
def cleanup(): certIdlength = 64 with open('configure.json') as file: json_text = json.load(file) thing_name = json_text['thing_name'] thing_obj = thing.Thing(thing_name) principals = thing_obj.list_principals() # Delete certificates and policies attached to thing for eachPrincipal in principals: certId = eachPrincipal[-certIdlength:] certarn = eachPrincipal cert_obj = certs.Certificate(certId) # Get policies attached to certificate policies_attached = cert_obj.list_policies() # Delete certificate cert_obj.delete() # Delete policies attached to the certificate for each_policy in policies_attached: policy_obj = policy.Policy(each_policy['policyName']) policy_obj.delete() # Delete Thing thing_obj.delete()
def delete_prereq(): with open('configure.json') as file: json_text = json.load(file) # Delete Thing thing_name = json_text['thing_name'] thing_obj = thing.Thing(thing_name) thing_obj.delete() # Delete certificate cert_id_filename = thing_name + '_cert_id_file' cert_id_file = open(cert_id_filename, 'r') cert_id = cert_id_file.read() cert_obj = certs.Certificate(cert_id) cert_obj.delete() os.remove(cert_id_filename) # Delete cert_pem file and private_key_pem file cert_pem_filename = thing_name + '_cert_pem_file' private_key_pem_filename = thing_name + '_private_key_pem_file' os.remove(cert_pem_filename) os.remove(private_key_pem_filename) # Delete policy policy_name = thing_name + '_amazon_freertos_policy' policy_obj = policy.Policy(policy_name) policy_obj.delete()
def mouse_down(self, w, x, y, button): l = self.level if self.editor_mode: if button == 3 or self.editor_mode_erase: got_one = False if self.editor_mode_tp: t = l.thing_find(x, y, self.editor_mode_tp.name) if t is not None: t.destroy("via editor erase") got_one = True if not got_one: t = l.thing_top(x, y) if t is not None and not t.tp.is_player: t.destroy("via editor erase 2") elif self.editor_mode_draw and self.editor_mode_tp: t = l.thing_find_same_type(x, y, self.editor_mode_tp.name) if t is not None: t.destroy("via editor draw") t = thing.Thing(level=l, tp_name=self.editor_mode_tp.name, x=x, y=y) t.push() return True return True
def clone(): paper = thing.Thing('paper', __file__) paper.set_description('torn paper', 'This paper appears to be torn from a book.') paper.actions.append(action.Action(read, ['read'], True, False)) paper.add_adjectives('torn') return paper
def delete_prereq(): with open('configure.json') as file: json_text = json.load(file) # Delete Thing thing_name = json_text['thing_name'] thing_obj = thing.Thing(thing_name) thing_obj.delete() # Delete certificate cert_id_filename = thing_name + '_cert_id.txt' cert_id_file = open(cert_id_filename, 'r') cert_id = cert_id_file.read() cert_obj = certs.Certificate(cert_id) cert_obj.delete() cert_id_file.close() cert_id_file_path = os.path.abspath(cert_id_filename) os.chmod(cert_id_file_path, 0o666) os.remove(cert_id_filename) # Delete cert_pem file and private_key_pem file cert_pem_filename = thing_name + '_cert.pem' private_key_pem_filename = thing_name + '_private_key.pem' cert_pem_file_path = os.path.abspath(cert_pem_filename) private_key_pem_file_path = os.path.abspath(private_key_pem_filename) os.chmod(cert_pem_file_path, 0o666) os.chmod(private_key_pem_file_path, 0o666) os.remove(cert_pem_filename) os.remove(private_key_pem_filename) # Delete policy policy_obj = policy.Policy(thing_name) policy_obj.delete()
def clone(): paper = thing.Thing('paper', __file__) paper.set_description('paper', 'This paper appears to be part of a letter.') paper.actions.append(action.Action(read, ['read'], True, False)) paper.add_names('letter') return paper
def clone(): gold = thing.Thing('gold', __file__) gold.set_description( 'bunch of shiny gold coins', 'This is a collection of seven shiny, real gold coins.') gold.set_weight(74000) return gold
def create_weapon(name, x, y): weap = thing.Thing() weap.name = name weap.x = x weap.y = y data = WEAPONS[name] weap.name = name weap.type = data[0] weap.mask = weap.type weap.value = data[1] # $$$ weap.stats.mass = data[2] # kg weap.stats.hpmax = data[3] # durability weap.stats.hp = data[3] # durability weap.material = data[4] weap.statMods = {} # stat modifiers for equipping if data[5][0]: weap.statMods.update({'range': data[5][0]}) if data[5][1]: weap.statMods.update({'atk': data[5][1]}) if data[5][2]: weap.statMods.update({'dmg': data[5][2]}) if data[5][3]: weap.statMods.update({'dfn': data[5][3]}) if data[5][4]: weap.statMods.update({'arm': data[5][4]}) if data[5][5]: weap.statMods.update({'asp': data[5][5]}) if data[5][6]: weap.statMods.update({'msp': data[5][6]}) if data[5][7]: weap.statMods.update({'element': data[5][7]}) weap.ammoType = data[6] #for mod in data[7]: # weap.mods.append(mod) weap.color = COL['white'] weap.equipType = EQ_MAINHAND rog.make(weap, CANEQUIP) return weap
def clone(): paper = thing.Thing('paper', __file__) paper.set_description('paper', 'This paper appears to be a note of some sort.') paper.actions.append(action.Action(read, ['read'], True, False)) paper.add_names('note') return paper
def things_flood_fill_(self, p, tp, walked): sys.setrecursionlimit(mm.MAP_WIDTH * mm.MAP_HEIGHT) if p.oob(): return "" if walked[p.x][p.y] == 1: return walked[p.x][p.y] = 1 for f in self.things_at[p.x][p.y]: other_tp = f.tp if not tp.is_wall: if other_tp.is_wall: return t = self.thing_find_same_type(p, tp.name) if t is not None: t.destroy("via flood fill") t = thing.Thing(level=self, tp_name=tp.name, x=p.x, y=p.y, z=p.z) t.push() self.things_flood_fill_(Point(p.x - 1, p.y, p.z), tp, walked) self.things_flood_fill_(Point(p.x + 1, p.y, p.z), tp, walked) self.things_flood_fill_(Point(p.x, p.y - 1, p.z), tp, walked) self.things_flood_fill_(Point(p.x, p.y + 1, p.z), tp, walked)
def prereq(): with open('configure.json') as file: json_text = json.load(file) # Validate that the entries in the JSON are valid. validate_json_text(json_text) # Create a Thing thing_name = json_text['thing_name'] thing_obj = thing.Thing(thing_name) if not thing_obj.create(): # Create a Certificate cert_obj = certs.Certificate() result = cert_obj.create() # Store certId cert_id = result['certificateId'] cert_id_filename = thing_name + '_cert_id_file' print('Writing certificate ID to: {}'.format(cert_id_filename)) cert_id_file = open(cert_id_filename, 'w') cert_id_file.write(cert_id) cert_id_file_path = os.path.abspath(cert_id_filename) os.chmod(cert_id_file_path, 0o444) cert_id_file.close() # Store cert_pem as file cert_pem = result['certificatePem'] cert_pem_filename = thing_name + '_cert_pem_file' print('Writing certificate PEM to: {}'.format(cert_pem_filename)) cert_pem_file = open(cert_pem_filename, 'w') cert_pem_file.write(cert_pem) cert_pem_file_path = os.path.abspath(cert_pem_filename) os.chmod(cert_pem_file_path, 0o444) cert_pem_file.close() # Store private key PEM as file private_key_pem = result['keyPair']['PrivateKey'] private_key_pem_filename = thing_name + '_private_key_pem_file' print( 'Writing private key PEM to: {}'.format(private_key_pem_filename)) private_key_pem_file = open(private_key_pem_filename, 'w') private_key_pem_file.write(private_key_pem) private_key_pem_file_path = os.path.abspath(private_key_pem_filename) os.chmod(private_key_pem_file_path, 0o444) private_key_pem_file.close() # Create a Policy policy_document = misc.create_policy_document() policy_name = thing_name + '_amazon_freertos_policy' policy_obj = policy.Policy(policy_name, policy_document) policy_obj.create() # Attach certificate to Thing cert_obj.attach_thing(thing_name) # Attach policy to certificate cert_obj.attach_policy(policy_name) print("Completed prereq operation!")
def clone(): branch = thing.Thing('branch', __file__) branch.set_description( 'sturdy oak branch', 'This is a sturdy oak branch. It seems like it could burn for quite a while.' ) branch.add_adjectives('sturdy', 'oak') return branch
def clone(): petal = thing.Thing('%s petal' % species, __file__) petal.set_description('%s petal' % species, 'This is a petal from a %s.' % species) petal.add_names('petal') petal.add_adjectives(species) petal.set_volume(0.0005) petal.set_weight(0.5) return petal
def clone(): log = thing.Thing('log', __file__) log.set_description( 'sturdy log', 'This log is about two feet long, and looks far more stable than the rest.' ) log.flammable = True log.add_adjectives('sturdy') return log
def clone(): plate = thing.Thing('plate', __file__) plate.set_description('dinner plate', 'This is a normal-looking white dinner plate.') plate.set_weight(1000) plate.set_volume(1.25) plate.add_adjectives('dinner', 'white') return plate
def create(x, y, ID): name, typ, mat, fgcol, lo, kg, solid, push, script = STUFF[ID] tt = thing.Thing(x, y, _type=typ, name=name, color=COL[fgcol]) tt.mass = kg tt.material = mat if lo: hp(tt, lo) tt.isSolid = solid if push: rog.make(tt, CANPUSH) #_applyResistancesFromMaterial(tt, mat) return tt
def __init__(self): global NORTH, EAST, SOUTH, WEST random.seed() # create monsters and players count = 1 self.thing[str(count)] = THING.Thing(1, 1, self.m.PLAYER, "PlayerOne", "", NORTH, count) count += 1 self.thing[str(count)] = THING.Thing(2, 1, self.m.PLAYER, "PlayerTwo", "", EAST, count) count += 1 self.thing[str(count)] = THING.Thing(1, 5, self.m.GREMLIN, "Gremlin 1", "", NORTH, count) count += 1 self.thing[str(count)] = THING.Thing(7, 5, self.m.GREMLIN, "Gremlin 2", "", EAST, count) count += 1 self.thing[str(count)] = THING.Thing(13, 13, self.m.GREMLIN, "Gremlin 3", "", SOUTH, count) count += 1 self.thing[str(count)] = THING.Thing(13, 5, self.m.GREMLIN, "Gremlin 4", "", WEST, count) count += 1 self.thing[str(count)] = THING.Thing(5, 13, self.m.GREMLIN, "Gremlin 5", "", NORTH, count) count += 1 self.thing[str(count)] = THING.Thing(3, 11, self.m.GREMLIN, "Gremlin 6", "", EAST, count) count += 1 self.thing[str(count)] = THING.Thing(11, 9, self.m.GREMLIN, "Gremlin 7", "", SOUTH, count) count += 1 self.thing[str(count)] = THING.Thing(9, 1, self.m.GREMLIN, "Gremlin 8", "", WEST, count) #place monsters and players in the maze for k, v in self.thing.items(): self.m.halls[v.x][v.y] = int(k) print("mazesvr view of maze") self.m.display() return
def prereq(): with open('configure.json') as file: json_text = json.load(file) # If using existing policy, make sure policy exists before # creating the thing thing_name = json_text.get('thing_name', "") mac_addr = json_text.get('mac_addr', "") # Create a Thing thing_obj = thing.Thing(thing_name) if not thing_obj.create(): # Create a Certificate cert_obj = certs.Certificate() result = cert_obj.create() # Store certId cert_id = result['certificateId'] cert_id_filename = thing_name + '_cert_id.txt' cert_id_file = open(cert_id_filename, 'w') cert_id_file.write(cert_id) cert_id_file_path = os.path.abspath(cert_id_filename) os.chmod(cert_id_file_path, 0o664) cert_id_file.close() # Store cert_pem as file cert_pem = result['certificatePem'] cert_pem_filename = thing_name + '_cert.pem' cert_pem_file = open(cert_pem_filename, 'w') cert_pem_file.write(cert_pem) cert_pem_file_path = os.path.abspath(cert_pem_filename) os.chmod(cert_pem_file_path, 0o664) cert_pem_file.close() # Store private key PEM as file private_key_pem = result['keyPair']['PrivateKey'] private_key_pem_filename = thing_name + '_private_key.pem' private_key_pem_file = open(private_key_pem_filename, 'w') private_key_pem_file.write(private_key_pem) private_key_pem_file_path = os.path.abspath(private_key_pem_filename) os.chmod(private_key_pem_file_path, 0o664) private_key_pem_file.close() # Create thing policy policy_document_text = misc.create_policy_document_text(thing_name) if policy_document_text: policy_obj = policy.Policy(thing_name, policy_document_text) cert_policy_name = policy_obj.create() print('Creating Certificate Policy {}'.format(cert_policy_name)) # Attach the Policy to the Cert, Cert to thing cert_obj.attach_thing(thing_name) cert_obj.attach_policy(cert_policy_name)
def push_block(self, tp_name, at): l = g.level t = thing.Thing(level=l, tp_name=tp_name, at=at) if t.collision_check(): t.destroy(reason="collision") return None t.push() return t
def makepot_acid(): pot=thing.Thing() pot.type = POTION pot.mask = POTION pot.stats.hp = 1 pot.mass = 0.2 pot.color = COL['yellow'] pot.material = MAT_GLASS pot.stats.resfire = 90 pot.stats.resbio = 100 rog.register_inanimate(pot) pot.quaff=quaff_acid return pot
def prereq(): with open('configure.json') as configure_file: json_text = json.load(configure_file) # Create a Thing thing_name = json_text['thing_name'] thing_obj = thing.Thing(thing_name) if not thing_obj.create(): # Create a Certificate cert_obj = certs.Certificate() result = cert_obj.create() # Store certId cert_id = result['certificateId'] cert_id_filename = thing_name + '_cert_id_file.txt' cert_id_file = open(cert_id_filename, 'w') cert_id_file.write(cert_id) cert_id_file_path = os.path.abspath(cert_id_filename) os.chmod(cert_id_file_path, 0o444) cert_id_file.close() # Store cert_pem as file cert_pem = result['certificatePem'] cert_pem_filename = thing_name + '_cert_pem_file.pem' cert_pem_file = open(cert_pem_filename, 'w') cert_pem_file.write(cert_pem) cert_pem_file_path = os.path.abspath(cert_pem_filename) os.chmod(cert_pem_file_path, 0o444) cert_pem_file.close() # Store private key PEM as file private_key_pem = result['keyPair']['PrivateKey'] private_key_pem_filename = thing_name + '_private_key_pem_file.pem' private_key_pem_file = open(private_key_pem_filename, 'w') private_key_pem_file.write(private_key_pem) private_key_pem_file_path = os.path.abspath(private_key_pem_filename) os.chmod(private_key_pem_file_path, 0o444) private_key_pem_file.close() # Create a Policy policy_document = misc.create_policy_document() policy_name = thing_name + '_amazon_freertos_policy' policy_obj = policy.Policy(policy_name, policy_document) policy_obj.create() # Attach certificate to Thing cert_obj.attach_thing(thing_name) # Attach policy to certificate cert_obj.attach_policy(policy_name)
def prereq(): with open('configure.json') as file: json_text = json.load(file) aws_config = json_text["aws_config"] optiga_config = json_text["optiga_trust_config"] # Create a Certificate cert_obj = certs.Certificate() result = cert_obj.create(optiga_config['executable_path'], optiga_config['i2c_device'], optiga_config['privatekey_objectid'], optiga_config['certificate_objectid']) # Create a Thing if doesn't exist thing_name = aws_config['thing_name'] thing_obj = thing.Thing(thing_name) if not thing_obj.exists(): thing_obj.create() # Store certId cert_id = result['certificateId'] cert_id_filename = thing_name + '_cert_id_file' cert_id_file = open(cert_id_filename, 'w') cert_id_file.write(cert_id) cert_id_file_path = os.path.abspath(cert_id_filename) os.chmod(cert_id_file_path, 0o444) cert_id_file.close() # Store cert_pem as file cert_pem = result['certificatePem'] cert_pem_filename = thing_name + '_cert_pem_file' cert_pem_file = open(cert_pem_filename, 'w') cert_pem_file.write(cert_pem) cert_pem_file_path = os.path.abspath(cert_pem_filename) os.chmod(cert_pem_file_path, 0o444) cert_pem_file.close() # Create a Policy if doesn't exist policy_obj = policy.Policy(aws_config['policy_name']) if not policy_obj.exists(): policy_document = misc.create_policy_document() policy_obj.attach_rules(policy_document) policy_obj.create() # Attach certificate to Thing cert_obj.attach_thing(aws_config['thing_name']) # Attach policy to certificate cert_obj.attach_policy(aws_config['policy_name'])
def setup(): with open('configure.json') as file: json_text = json.load(file) # Create a Thing thing_name = json_text['thing_name'] thing_obj = thing.Thing(thing_name) if not thing_obj.create(): # Create a Certificate cert_obj = certs.Certificate() result = cert_obj.create() # Store cert_pem cert_pem = result['certificatePem'] # Store Private key PEM private_key_pem = result['keyPair']['PrivateKey'] wifi_ssid = json_text['wifi_ssid'] wifi_passwd = json_text['wifi_password'] wifi_security = json_text['wifi_security'] # Modify 'aws_clientcredential.h' file misc.client_credential( wifi_ssid = wifi_ssid, wifi_passwd = wifi_passwd, wifi_security = wifi_security, thing_name = thing_name, credentials_or_keys = "client_credential") # Modify 'aws_clientcredential_keys.h' file misc.client_credential( client_certificate_pem = cert_pem, clientprivate_key_pem = private_key_pem, credentials_or_keys = "client_keys") # Create a Policy policy_document = misc.create_policy_document() policy_name = thing_name + '_amazon_freertos_policy' policy_obj = policy.Policy(policy_name, policy_document) policy_obj.create() # Attach certificate to Thing cert_obj.attach_thing(thing_name) # Attach policy to certificate cert_obj.attach_policy(policy_name)
def delete_prereq(): with open('configure.json') as configure_file: json_text = json.load(configure_file) # Delete Thing thing_name = json_text['thing_name'] thing_obj = thing.Thing(thing_name) if thing_obj.exists(): thing_obj.delete() # Delete certificate cert_id_filename = thing_name + '_cert_id_file.txt' if os.path.exists(cert_id_filename): cert_id_file = open(cert_id_filename, 'r') cert_id = cert_id_file.read() cert_obj = certs.Certificate(cert_id) cert_obj.delete() cert_id_file.close() cert_id_file_path = os.path.abspath(cert_id_filename) os.chmod(cert_id_file_path, 0o666) os.remove(cert_id_filename) # Delete cert_pem file and private_key_pem file cert_pem_filename = thing_name + '_cert_pem_file.pem' if os.path.exists(cert_pem_filename): cert_pem_file_path = os.path.abspath(cert_pem_filename) os.chmod(cert_pem_file_path, 0o666) os.remove(cert_pem_filename) private_key_pem_filename = thing_name + '_private_key_pem_file.pem' if os.path.exists(private_key_pem_filename): private_key_pem_file_path = os.path.abspath(private_key_pem_filename) os.chmod(private_key_pem_file_path, 0o666) os.remove(private_key_pem_filename) # Delete policy policy_name = thing_name + '_amazon_freertos_policy' policy_obj = policy.Policy(policy_name) if policy_obj.exists(): policy_obj.delete()
def delete_prereq(): with open('configure.json') as file: json_text = json.load(file) # Delete Thing thing_name = json_text['thing_name'] thing_obj = thing.Thing(thing_name) thing_obj.delete() # Delete certificate cert_id_filename = thing_name + '_cert_id_file' cert_id_file = open(cert_id_filename, 'r') cert_id = cert_id_file.read() cert_obj = certs.Certificate(cert_id) cert_obj.delete() cert_id_file.close() cert_id_file_path = os.path.abspath(cert_id_filename) os.chmod(cert_id_file_path, 0o666) print("Deleting {}".format(cert_id_filename)) os.remove(cert_id_filename) # Delete cert_pem file and private_key_pem file cert_pem_filename = thing_name + '_cert_pem_file' private_key_pem_filename = thing_name + '_private_key_pem_file' cert_pem_file_path = os.path.abspath(cert_pem_filename) private_key_pem_file_path = os.path.abspath(private_key_pem_filename) os.chmod(cert_pem_file_path, 0o666) os.chmod(private_key_pem_file_path, 0o666) print("Deleting {}".format(cert_pem_filename)) os.remove(cert_pem_filename) print("Deleting {}".format(private_key_pem_filename)) os.remove(private_key_pem_filename) # Delete policy policy_name = thing_name + '_amazon_freertos_policy' policy_obj = policy.Policy(policy_name) policy_obj.delete() print("Successfully deleted prereqs!")
def __init__(self, map_path): parsed_map = parse_to_lists(map_path) self._tiles = [] self._things = [] self._start_position = None for y, row in zip(range(len(parsed_map)), parsed_map): _tile_row = [] for x, column in enumerate(row): _tile_to_append = tile.create_based_on_char(column) _tile_to_append.x = x _tile_to_append.y = y if column is 's': if self._start_position is None: self._start_position = (x, y) else: raise MultiplePlayerStartError() elif column is 'b': _tile_to_append.thing = thing.Thing() self._things.append(_tile_to_append) _tile_row.append(_tile_to_append) self._tiles.append(_tile_row) if self._start_position is None: raise NoPlayerStartError()
status = p.close() if status != 0: print("Sendmail exit status", status) def addMsg(s): global msg msg = msg + s + "\n" msg = "" deb = time.time() menuPhil = menuCantine.MenuCantine() menuPhil.load() tempExt = thing.Thing(keyPiscine, 1) portail = thing.Thing(keyPortail, 1) tempExt.load() portail.load() m = openWeather.OWM(meteoKey) m.load("real") # pas en mode demo m.analyse() dt = dateConv.DateConv() bus = cts.Cts(idCts, pwdCts, arretCts) bus.load() addMsg(dt.nowStr()) addMsg(dt.heure()) derMesure = tempExt.getField(0, "created_at")
def clone(): seed = thing.Thing('poppyseed', __file__) seed.set_description(seed.names[0], 'This is a normal poppy seed.') return seed
def clone(): truffles = thing.Thing('truffles', __file__) truffles.set_description( 'truffles', 'These truffles look very determined for some reason.') return truffles