diff options
author | ng0 <ng0@n0.is> | 2019-10-12 18:16:07 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-10-12 18:16:07 +0000 |
commit | a5f5e7ed9b07b902af4438d76087e034abcba9b2 (patch) | |
tree | 6f376f93f1c785103d0b30f54311a0f61d2bdced /contrib | |
parent | 8e827de2a1db34dfe15f5f9da2850ca469b5ecc3 (diff) | |
download | gnunet-a5f5e7ed9b07b902af4438d76087e034abcba9b2.tar.gz gnunet-a5f5e7ed9b07b902af4438d76087e034abcba9b2.zip |
format python
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/scripts/gnunet-chk.py.in | 23 | ||||
-rw-r--r-- | contrib/scripts/gnunet_janitor.py.in | 1 | ||||
-rw-r--r-- | contrib/scripts/gnunet_pyexpect.py.in | 20 | ||||
-rw-r--r-- | contrib/scripts/pydiffer.py.in | 5 | ||||
-rwxr-xr-x | contrib/scripts/removetrailingwhitespace.py.in | 1 | ||||
-rw-r--r-- | contrib/scripts/terminate.py.in | 2 |
6 files changed, 33 insertions, 19 deletions
diff --git a/contrib/scripts/gnunet-chk.py.in b/contrib/scripts/gnunet-chk.py.in index 0fb591627..7d2cf73d3 100755 --- a/contrib/scripts/gnunet-chk.py.in +++ b/contrib/scripts/gnunet-chk.py.in | |||
@@ -29,9 +29,8 @@ import sys | |||
29 | from Crypto.Cipher import AES | 29 | from Crypto.Cipher import AES |
30 | from functools import reduce | 30 | from functools import reduce |
31 | 31 | ||
32 | |||
33 | # Defaults | 32 | # Defaults |
34 | DBLOCK_SIZE = (32 * 1024) # Data block size | 33 | DBLOCK_SIZE = (32 * 1024) # Data block size |
35 | 34 | ||
36 | # Pick a multiple of 2 here to achive 8-byte alignment! We also | 35 | # Pick a multiple of 2 here to achive 8-byte alignment! We also |
37 | # probably want DBlocks to have (roughly) the same size as IBlocks. | 36 | # probably want DBlocks to have (roughly) the same size as IBlocks. |
@@ -39,7 +38,7 @@ DBLOCK_SIZE = (32 * 1024) # Data block size | |||
39 | # byte = 2 * 512 bits). DO NOT CHANGE! | 38 | # byte = 2 * 512 bits). DO NOT CHANGE! |
40 | CHK_PER_INODE = 256 | 39 | CHK_PER_INODE = 256 |
41 | 40 | ||
42 | CHK_HASH_SIZE = 64 # SHA-512 hash = 512 bits = 64 bytes | 41 | CHK_HASH_SIZE = 64 # SHA-512 hash = 512 bits = 64 bytes |
43 | 42 | ||
44 | CHK_QUERY_SIZE = CHK_HASH_SIZE # Again a SHA-512 hash | 43 | CHK_QUERY_SIZE = CHK_HASH_SIZE # Again a SHA-512 hash |
45 | 44 | ||
@@ -94,11 +93,11 @@ class AESKey(object): | |||
94 | """Class for AES Keys. Contains the main key and the initialization | 93 | """Class for AES Keys. Contains the main key and the initialization |
95 | vector. """ | 94 | vector. """ |
96 | 95 | ||
97 | key = None # The actual AES key | 96 | key = None # The actual AES key |
98 | iv = None # The initialization vector | 97 | iv = None # The initialization vector |
99 | cipher = None # The cipher object | 98 | cipher = None # The cipher object |
100 | KEY_SIZE = 32 # AES 256-bit key = 32 bytes | 99 | KEY_SIZE = 32 # AES 256-bit key = 32 bytes |
101 | IV_SIZE = AES.block_size # Initialization vector size (= AES block size) | 100 | IV_SIZE = AES.block_size # Initialization vector size (= AES block size) |
102 | 101 | ||
103 | def __init__(self, passphrase): | 102 | def __init__(self, passphrase): |
104 | """Creates a new AES key. | 103 | """Creates a new AES key. |
@@ -355,13 +354,15 @@ def chkuri_from_path(path): | |||
355 | 354 | ||
356 | def usage(): | 355 | def usage(): |
357 | """Prints help about using this script.""" | 356 | """Prints help about using this script.""" |
358 | print(""" | 357 | print( |
358 | """ | ||
359 | Usage: gnunet-chk.py [options] file | 359 | Usage: gnunet-chk.py [options] file |
360 | Prints the Content Hash Key of given file in GNUNET-style URI. | 360 | Prints the Content Hash Key of given file in GNUNET-style URI. |
361 | 361 | ||
362 | Options: | 362 | Options: |
363 | -h, --help : prints this message | 363 | -h, --help : prints this message |
364 | """) | 364 | """ |
365 | ) | ||
365 | 366 | ||
366 | 367 | ||
367 | if '__main__' == __name__: | 368 | if '__main__' == __name__: |
@@ -373,7 +374,7 @@ if '__main__' == __name__: | |||
373 | usage() | 374 | usage() |
374 | sys.exit(2) | 375 | sys.exit(2) |
375 | for option, value in opts: | 376 | for option, value in opts: |
376 | if option in("-h", "--help"): | 377 | if option in ("-h", "--help"): |
377 | usage() | 378 | usage() |
378 | sys.exit(0) | 379 | sys.exit(0) |
379 | if len(args) != 1: | 380 | if len(args) != 1: |
diff --git a/contrib/scripts/gnunet_janitor.py.in b/contrib/scripts/gnunet_janitor.py.in index b0b50ca76..d6834bfb4 100644 --- a/contrib/scripts/gnunet_janitor.py.in +++ b/contrib/scripts/gnunet_janitor.py.in | |||
@@ -31,6 +31,7 @@ import time | |||
31 | import signal | 31 | import signal |
32 | import terminate | 32 | import terminate |
33 | 33 | ||
34 | |||
34 | def get_process_list(): | 35 | def get_process_list(): |
35 | result = [] | 36 | result = [] |
36 | pids = [pid for pid in os.listdir('/proc') if pid.isdigit()] | 37 | pids = [pid for pid in os.listdir('/proc') if pid.isdigit()] |
diff --git a/contrib/scripts/gnunet_pyexpect.py.in b/contrib/scripts/gnunet_pyexpect.py.in index 188436f51..48f8acdc1 100644 --- a/contrib/scripts/gnunet_pyexpect.py.in +++ b/contrib/scripts/gnunet_pyexpect.py.in | |||
@@ -11,7 +11,7 @@ | |||
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | # Affero General Public License for more details. | 13 | # Affero General Public License for more details. |
14 | # | 14 | # |
15 | # You should have received a copy of the GNU Affero General Public License | 15 | # You should have received a copy of the GNU Affero General Public License |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | # | 17 | # |
@@ -27,7 +27,7 @@ import shutil | |||
27 | import time | 27 | import time |
28 | 28 | ||
29 | 29 | ||
30 | class pexpect (object): | 30 | class pexpect(object): |
31 | def __init__(self): | 31 | def __init__(self): |
32 | super(pexpect, self).__init__() | 32 | super(pexpect, self).__init__() |
33 | 33 | ||
@@ -54,12 +54,22 @@ class pexpect (object): | |||
54 | if len(stream) == 0: | 54 | if len(stream) == 0: |
55 | return True | 55 | return True |
56 | else: | 56 | else: |
57 | print("Failed to find `{1}' in {0}, which is `{2}' ({3})".format(s, r, stream, len(stream))) | 57 | print( |
58 | "Failed to find `{1}' in {0}, which is `{2}' ({3})". | ||
59 | format(s, r, stream, len(stream)) | ||
60 | ) | ||
58 | sys.exit(2) | 61 | sys.exit(2) |
59 | raise ValueError("Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'".format(r)) | 62 | raise ValueError( |
63 | "Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'" | ||
64 | .format(r) | ||
65 | ) | ||
60 | m = r.search(stream.decode(), flags) | 66 | m = r.search(stream.decode(), flags) |
61 | if not m: | 67 | if not m: |
62 | print("Failed to find `{1}' in {0}, which is is `{2}'".format(s, r.pattern, stream)) | 68 | print( |
69 | "Failed to find `{1}' in {0}, which is is `{2}'".format( | ||
70 | s, r.pattern, stream | ||
71 | ) | ||
72 | ) | ||
63 | sys.exit(2) | 73 | sys.exit(2) |
64 | stream = stream[m.end():] | 74 | stream = stream[m.end():] |
65 | if s == 'stdout': | 75 | if s == 'stdout': |
diff --git a/contrib/scripts/pydiffer.py.in b/contrib/scripts/pydiffer.py.in index 35d9ffa35..08f0f4ae6 100644 --- a/contrib/scripts/pydiffer.py.in +++ b/contrib/scripts/pydiffer.py.in | |||
@@ -10,7 +10,10 @@ def getdiff(old, new): | |||
10 | diff = [] | 10 | diff = [] |
11 | with open(old) as a: | 11 | with open(old) as a: |
12 | with open(new) as b: | 12 | with open(new) as b: |
13 | for l in difflib.unified_diff(a.read().splitlines(), b.read().splitlines()): | 13 | for l in difflib.unified_diff( |
14 | a.read().splitlines(), | ||
15 | b.read().splitlines() | ||
16 | ): | ||
14 | diff.append(l) | 17 | diff.append(l) |
15 | return diff | 18 | return diff |
16 | 19 | ||
diff --git a/contrib/scripts/removetrailingwhitespace.py.in b/contrib/scripts/removetrailingwhitespace.py.in index 5824fb591..e6c2d9014 100755 --- a/contrib/scripts/removetrailingwhitespace.py.in +++ b/contrib/scripts/removetrailingwhitespace.py.in | |||
@@ -3,7 +3,6 @@ | |||
3 | import sys | 3 | import sys |
4 | import re | 4 | import re |
5 | 5 | ||
6 | |||
7 | for fileName in sys.argv[1:]: | 6 | for fileName in sys.argv[1:]: |
8 | f = open(fileName, 'r+') | 7 | f = open(fileName, 'r+') |
9 | fileString = f.read() | 8 | fileString = f.read() |
diff --git a/contrib/scripts/terminate.py.in b/contrib/scripts/terminate.py.in index f57ac6167..2cb4a13c4 100644 --- a/contrib/scripts/terminate.py.in +++ b/contrib/scripts/terminate.py.in | |||
@@ -26,7 +26,7 @@ import subprocess | |||
26 | import os | 26 | import os |
27 | 27 | ||
28 | 28 | ||
29 | class dummyobj (object): | 29 | class dummyobj(object): |
30 | pass | 30 | pass |
31 | 31 | ||
32 | 32 | ||