From 902658af85363d24527c8138e64e8506bb9b89fb Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Tue, 9 Feb 2016 03:02:51 +0100 Subject: [PATCH] =?utf8?q?Fonctions=20pour=20batch-(d=C3=A9)valider=20des?= =?utf8?q?=20transactions?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- client.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/client.py b/client.py index f015762..1537ba4 100755 --- a/client.py +++ b/client.py @@ -105,6 +105,27 @@ def do(stuff): global a a.write(json.dumps(stuff)) + +# Shortcuts +def _toggle_transactions(l, action="valider"): + """(Dé)valide plein de transactions si on lui donne la liste d'ids.""" + global a + for i in l: + assert isinstance(i, int) + print i, + do(["%s_transaction" % (action,), i]) + out = lit(a) + if out: + print out + +def cancel_transactions(l): + """Annule plein de transactions. Mange une liste d'ids de transactions.""" + _toggle_transactions(l, action="devalider") + +def validate_transactions(l): + """Valide plein de transactions. Mange une liste d'ids de transactions.""" + _toggle_transactions(l, action="valider") + if __name__=="__main__": where=raw_input("quel serveur ?") #port=int(raw_input("port ? ")) @@ -124,4 +145,3 @@ if __name__=="__main__": password = getpass.getpass("password:") print login(a, user, password) print "Socket créée dans la variable \"a\"" - -- 2.39.2