From f7ed4da0d08acf0e73c61b5c28f95bf5364a3cb5 Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Thu, 2 Apr 2015 23:36:53 +0500 Subject: [PATCH] Platform independent manifest verification --- bin/verify-manifest | 12 ------------ bin/verify-manifest.py | 17 +++++++++++++++++ minecraft/networking/types.py | 8 ++++---- tox.ini | 3 ++- 4 files changed, 23 insertions(+), 17 deletions(-) delete mode 100755 bin/verify-manifest create mode 100755 bin/verify-manifest.py diff --git a/bin/verify-manifest b/bin/verify-manifest deleted file mode 100755 index e64b39c..0000000 --- a/bin/verify-manifest +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -OUTPUT=`check-manifest` -EXPECTED_OUTPUT="lists of files in version control and sdist match" -if [[ "$OUTPUT" != "$EXPECTED_OUTPUT" ]]; then - echo "Check-manifest didn't match." - echo "OUTPUT: $OUTPUT" - echo "EXPECTED_OUTPUT: $EXPECTED_OUTPUT" - exit 1 # Error -else - echo "Manifest verified." - exit 0 -fi \ No newline at end of file diff --git a/bin/verify-manifest.py b/bin/verify-manifest.py new file mode 100755 index 0000000..94b3ad0 --- /dev/null +++ b/bin/verify-manifest.py @@ -0,0 +1,17 @@ +import os, subprocess +import errno, sys + +EXPECTED_OUTPUT = "lists of files in version control and sdist match" + + +def check_manifest(): + os.chdir('..') + output = subprocess.check_output(["check-manifest"]).decode() + print(output) + if EXPECTED_OUTPUT == output.strip(): + return 1 + else: + sys.exit(2) + +if __name__ == '__main__': + check_manifest() \ No newline at end of file diff --git a/minecraft/networking/types.py b/minecraft/networking/types.py index 75607f4..51b83f5 100644 --- a/minecraft/networking/types.py +++ b/minecraft/networking/types.py @@ -104,14 +104,14 @@ class VarInt(Type): @staticmethod def send(value, socket): - o = "" + out = "" while True: - b = value & 0x7F + byte = value & 0x7F value >>= 7 - o += struct.pack("B", b | (0x80 if value > 0 else 0)) + out += struct.pack("B", byte | (0x80 if value > 0 else 0)) if value == 0: break - socket.send(o) + socket.send(out) @staticmethod def size(value): diff --git a/tox.ini b/tox.ini index 6c0efa6..45aa92d 100644 --- a/tox.ini +++ b/tox.ini @@ -62,6 +62,7 @@ commands = basepython = python3.4 deps = check-manifest +changedir = bin commands = - {toxinidir}/bin/verify-manifest + python verify-manifest.py \ No newline at end of file