Correct hashlib calls
This commit is contained in:
parent
6546ad8651
commit
f23f107b33
3 changed files with 5 additions and 5 deletions
|
|
@ -922,7 +922,7 @@ class CmdIRC2Chan(COMMAND_DEFAULT_CLASS):
|
||||||
self.msg("Account '%s' already exists and is not a bot." % botname)
|
self.msg("Account '%s' already exists and is not a bot." % botname)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
password = hashlib.md5(str(time.time())).hexdigest()[:11]
|
password = hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:11]
|
||||||
try:
|
try:
|
||||||
bot = create.create_account(botname, None, password, typeclass=botclass)
|
bot = create.create_account(botname, None, password, typeclass=botclass)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ def homogenize_prototype(prototype, custom_keys=None):
|
||||||
if "prototype_key" not in prototype:
|
if "prototype_key" not in prototype:
|
||||||
# assign a random hash as key
|
# assign a random hash as key
|
||||||
homogenized["prototype_key"] = "prototype-{}".format(
|
homogenized["prototype_key"] = "prototype-{}".format(
|
||||||
hashlib.md5(str(time.time())).hexdigest()[:7])
|
hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:7])
|
||||||
|
|
||||||
if "typeclass" not in prototype and "prototype_parent" not in prototype:
|
if "typeclass" not in prototype and "prototype_parent" not in prototype:
|
||||||
homogenized["typeclass"] = settings.BASE_OBJECT_TYPECLASS
|
homogenized["typeclass"] = settings.BASE_OBJECT_TYPECLASS
|
||||||
|
|
|
||||||
|
|
@ -230,14 +230,14 @@ def prototype_from_object(obj):
|
||||||
# no unambiguous prototype found - build new prototype
|
# no unambiguous prototype found - build new prototype
|
||||||
prot = {}
|
prot = {}
|
||||||
prot['prototype_key'] = "From-Object-{}-{}".format(
|
prot['prototype_key'] = "From-Object-{}-{}".format(
|
||||||
obj.key, hashlib.md5(str(time.time())).hexdigest()[:7])
|
obj.key, hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:7])
|
||||||
prot['prototype_desc'] = "Built from {}".format(str(obj))
|
prot['prototype_desc'] = "Built from {}".format(str(obj))
|
||||||
prot['prototype_locks'] = "spawn:all();edit:all()"
|
prot['prototype_locks'] = "spawn:all();edit:all()"
|
||||||
prot['prototype_tags'] = []
|
prot['prototype_tags'] = []
|
||||||
else:
|
else:
|
||||||
prot = prot[0]
|
prot = prot[0]
|
||||||
|
|
||||||
prot['key'] = obj.db_key or hashlib.md5(str(time.time())).hexdigest()[:6]
|
prot['key'] = obj.db_key or hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:6]
|
||||||
prot['typeclass'] = obj.db_typeclass_path
|
prot['typeclass'] = obj.db_typeclass_path
|
||||||
|
|
||||||
location = obj.db_location
|
location = obj.db_location
|
||||||
|
|
@ -690,7 +690,7 @@ def spawn(*prototypes, **kwargs):
|
||||||
# we must always add a key, so if not given we use a shortened md5 hash. There is a (small)
|
# we must always add a key, so if not given we use a shortened md5 hash. There is a (small)
|
||||||
# chance this is not unique but it should usually not be a problem.
|
# chance this is not unique but it should usually not be a problem.
|
||||||
val = prot.pop("key", "Spawned-{}".format(
|
val = prot.pop("key", "Spawned-{}".format(
|
||||||
hashlib.md5(str(time.time())).hexdigest()[:6]))
|
hashlib.md5(bytes(str(time.time()), 'utf-8')).hexdigest()[:6]))
|
||||||
create_kwargs["db_key"] = init_spawn_value(val, str)
|
create_kwargs["db_key"] = init_spawn_value(val, str)
|
||||||
|
|
||||||
val = prot.pop("location", None)
|
val = prot.pop("location", None)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue