diff --git a/cpasswords/server.py b/cpasswords/server.py index d8999f2db70ac1c2f450dbfb4037d4b31980104c..28b8d724e770cb1b6007a4f2c64b2950279aa095 100755 --- a/cpasswords/server.py +++ b/cpasswords/server.py @@ -1,5 +1,4 @@ #!python -# -*- encoding: utf-8 -*- """ Group password manager server @@ -61,7 +60,6 @@ def validate(roles, mode='r'): def getpath(filename, backup=False): """Récupère le chemin du fichier ``filename``""" - filename = filename.encode('utf-8') return os.path.join(serverconfig.STORE, '%s.%s' % (filename, 'bak' if backup else 'json')) @@ -69,7 +67,7 @@ def writefile(filename, contents): """Écrit le fichier avec les bons droits UNIX""" os.umask(0o077) f = open(filename, 'w') - f.write(contents.encode("utf-8")) + f.write(contents) f.close() @@ -167,7 +165,7 @@ def listfiles(): files = {} for filename in filenames: file_dict = json.loads(open(filename).read()) - fname = filename[:-5].decode('utf-8') + fname = filename[:-5] files[fname] = file_dict["roles"] return files @@ -182,7 +180,7 @@ def restorefiles(): for filename in filenames: file_dict = json.loads(open(filename).read()) if not ('-----BEGIN PGP MESSAGE-----' in file_dict["contents"]): - fname = filename[:-5].decode('utf-8') + fname = filename[:-5] with open(fname+'.bak') as f: line = f.readline() backup = '' @@ -304,8 +302,7 @@ def backup(corps, fname, old): back = open(getpath(fname, backup=True), 'a') back.write(json.dumps(old)) back.write('\n') - back.write((u'* %s: %s\n' % - (str(datetime.datetime.now()), corps)).encode("utf-8")) + back.write(f"* {datetime.datetime.now()}: {corps}\n") back.close() @@ -360,8 +357,6 @@ def main(): raise IOError("Ce serveur est read-only.") args = argv[2:] - # On veut des unicode partout - args = [s.decode('utf-8') for s in args] if command.stdin_input: args.append(json.loads(sys.stdin.read())) answer = command.decorated(*args)