From: Nils Gillmann Date: Wed, 23 May 2018 17:31:01 +0000 (+0000) Subject: more flakes. X-Git-Tag: v0.11.0pre66~36^2~8 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=454935bd76a9106ad6eda4d5c3d0861d6e559777;p=oweals%2Fgnunet.git more flakes. Signed-off-by: Nils Gillmann --- diff --git a/src/fs/test_gnunet_fs_idx.py.in b/src/fs/test_gnunet_fs_idx.py.in index 30592c2e4..a669998fb 100755 --- a/src/fs/test_gnunet_fs_idx.py.in +++ b/src/fs/test_gnunet_fs_idx.py.in @@ -25,50 +25,50 @@ import re import shutil srcdir = "../.." -gnunet_pyexpect_dir = os.path.join (srcdir, "contrib/scripts") +gnunet_pyexpect_dir = os.path.join(srcdir, "contrib/scripts") if gnunet_pyexpect_dir not in sys.path: - sys.path.append (gnunet_pyexpect_dir) + sys.path.append(gnunet_pyexpect_dir) from gnunet_pyexpect import pexpect if os.name == 'posix': - download = './gnunet-download' - gnunetarm = 'gnunet-arm' - publish = './gnunet-publish' - unindex = './gnunet-unindex' + download = './gnunet-download' + gnunetarm = 'gnunet-arm' + publish = './gnunet-publish' + unindex = './gnunet-unindex' elif os.name == 'nt': - download = './gnunet-download.exe' - gnunetarm = 'gnunet-arm.exe' - publish = './gnunet-publish.exe' - unindex = './gnunet-unindex.exe' + download = './gnunet-download.exe' + gnunetarm = 'gnunet-arm.exe' + publish = './gnunet-publish.exe' + unindex = './gnunet-unindex.exe' if os.name == "nt": - shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-idx"), True) + shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-idx"), True) else: - shutil.rmtree ("/tmp/gnunet-test-fs-py-idx", True) + shutil.rmtree("/tmp/gnunet-test-fs-py-idx", True) -arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_fs_idx_data.conf']) -arm.communicate () +arm = subprocess.Popen([gnunetarm, '-sq', '-c', 'test_gnunet_fs_idx_data.conf']) +arm.communicate() try: - pub = pexpect () + pub = pexpect() - pub.spawn (None, [publish, '-c', 'test_gnunet_fs_idx_data.conf', '-m', "description:Test archive", '-k', 'tst', 'test_gnunet_fs_rec_data.tgz'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR\.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG\.17822'\.\r?\n")) + pub.spawn(None, [publish, '-c', 'test_gnunet_fs_idx_data.conf', '-m', "description:Test archive", '-k', 'tst', 'test_gnunet_fs_rec_data.tgz'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR\.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG\.17822'\.\r?\n")) - down = pexpect () - down.spawn (None, [download, '-c', 'test_gnunet_fs_idx_data.conf', '-o', 'test_gnunet_fs_rec_data.tar.gz', 'gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG.17822'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - down.expect ("stdout", re.compile (r"Downloading `test_gnunet_fs_rec_data.tar.gz' done (.*).\r?\n")) - os.remove ("test_gnunet_fs_rec_data.tar.gz") + down = pexpect() + down.spawn(None, [download, '-c', 'test_gnunet_fs_idx_data.conf', '-o', 'test_gnunet_fs_rec_data.tar.gz', 'gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG.17822'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + down.expect("stdout", re.compile(r"Downloading `test_gnunet_fs_rec_data.tar.gz' done (.*).\r?\n")) + os.remove("test_gnunet_fs_rec_data.tar.gz") - un = pexpect () - un.spawn (None, [unindex, '-c', 'test_gnunet_fs_idx_data.conf', 'test_gnunet_fs_rec_data.tgz'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - un.expect ("stdout", re.compile (r'Unindexing done\.\r?\n')) + un = pexpect() + un.spawn(None, [unindex, '-c', 'test_gnunet_fs_idx_data.conf', 'test_gnunet_fs_rec_data.tgz'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + un.expect("stdout", re.compile(r'Unindexing done\.\r?\n')) finally: - arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_fs_idx_data.conf']) - arm.communicate () - if os.name == "nt": - shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-idx"), True) - else: - shutil.rmtree ("/tmp/gnunet-test-fs-py-idx", True) + arm = subprocess.Popen([gnunetarm, '-eq', '-c', 'test_gnunet_fs_idx_data.conf']) + arm.communicate() + if os.name == "nt": + shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-idx"), True) + else: + shutil.rmtree("/tmp/gnunet-test-fs-py-idx", True) diff --git a/src/fs/test_gnunet_fs_psd.py.in b/src/fs/test_gnunet_fs_psd.py.in index b27a24c84..4b27b4532 100755 --- a/src/fs/test_gnunet_fs_psd.py.in +++ b/src/fs/test_gnunet_fs_psd.py.in @@ -36,7 +36,7 @@ reload(sys) sys.setdefaultencoding('utf8') srcdir = "../.." -gnunet_pyexpect_dir = os.path.join (srcdir, "contrib/scripts") +gnunet_pyexpect_dir = os.path.join(srcdir, "contrib/scripts") if gnunet_pyexpect_dir not in sys.path: sys.path.append(gnunet_pyexpect_dir) diff --git a/src/fs/test_gnunet_fs_rec.py.in b/src/fs/test_gnunet_fs_rec.py.in index e20a9ff78..aa9b7b461 100755 --- a/src/fs/test_gnunet_fs_rec.py.in +++ b/src/fs/test_gnunet_fs_rec.py.in @@ -27,88 +27,90 @@ import tarfile import filecmp srcdir = "../.." -gnunet_pyexpect_dir = os.path.join (srcdir, "contrib/scripts") +gnunet_pyexpect_dir = os.path.join(srcdir, "contrib/scripts") if gnunet_pyexpect_dir not in sys.path: - sys.path.append (gnunet_pyexpect_dir) + sys.path.append(gnunet_pyexpect_dir) from gnunet_pyexpect import pexpect from pydiffer import dcdiff if os.name == 'posix': - download = './gnunet-download' - gnunetarm = 'gnunet-arm' - publish = './gnunet-publish' - unindex = './gnunet-unindex' - search = './gnunet-search' - directory = './gnunet-directory' + download = './gnunet-download' + gnunetarm = 'gnunet-arm' + publish = './gnunet-publish' + unindex = './gnunet-unindex' + search = './gnunet-search' + directory = './gnunet-directory' elif os.name == 'nt': - download = './gnunet-download.exe' - gnunetarm = 'gnunet-arm.exe' - publish = './gnunet-publish.exe' - unindex = './gnunet-unindex.exe' - search = './gnunet-search.exe' - directory = './gnunet-directory.exe' + download = './gnunet-download.exe' + gnunetarm = 'gnunet-arm.exe' + publish = './gnunet-publish.exe' + unindex = './gnunet-unindex.exe' + search = './gnunet-search.exe' + directory = './gnunet-directory.exe' if os.name == "nt": - shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-rec"), True) + shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-rec"), True) else: - shutil.rmtree ("/tmp/gnunet-test-fs-py-rec", True) + shutil.rmtree("/tmp/gnunet-test-fs-py-rec", True) -arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_fs_rec_data.conf']) -arm.communicate () +arm = subprocess.Popen([gnunetarm, '-sq', '-c', 'test_gnunet_fs_rec_data.conf']) +arm.communicate() -# pray that `tar' is in PATH -tar = tarfile.open ('test_gnunet_fs_rec_data.tgz') -tar.extractall () +# pray that `tar' is in PATH. +# FIXME: Actually we should check for that and output +# a message if it isn't found. +tar = tarfile.open('test_gnunet_fs_rec_data.tgz') +tar.extractall() # first, basic publish-search-download run try: - pub = pexpect () - pub.spawn (None, [publish, '-c', 'test_gnunet_fs_rec_data.conf', '-d', '-k', 'testdir', 'dir/'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - # Can't say much for publishing, except that the last one is the toplevel directory - pub.expect ("stdout", re.compile (r"Publishing `.+' done\.\r?\n")) - pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) - pub.expect ("stdout", re.compile (r"Publishing `.+' done\.\r?\n")) - pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) - pub.expect ("stdout", re.compile (r"Publishing `.+' done\.\r?\n")) - pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) - pub.expect ("stdout", re.compile (r"Publishing `.+' done\.\r?\n")) - pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) - pub.expect ("stdout", re.compile (r"Publishing `.+' done\.\r?\n")) - pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) - pub.expect ("stdout", re.compile (r"Publishing `.+' done\.\r?\n")) - pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) - pub.expect ("stdout", re.compile (r"Publishing `.+[\\/]dir[\\/]' done\.\r?\n")) - m = pub.expect ("stdout", re.compile (r".+\r?\n")) - if not m: - sys.exit (3) - output = m.string - url = output[output.find ("`")+1:output.find("'")] + pub = pexpect() + pub.spawn(None, [publish, '-c', 'test_gnunet_fs_rec_data.conf', '-d', '-k', 'testdir', 'dir/'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + # Can't say much for publishing, except that the last one is the toplevel directory + pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) + pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) + pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) + pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) + pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) + pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) + pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) + pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) + pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) + pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) + pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) + pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) + pub.expect("stdout", re.compile(r"Publishing `.+[\\/]dir[\\/]' done\.\r?\n")) + m = pub.expect("stdout", re.compile(r".+\r?\n")) + if not m: + sys.exit(3) + output = m.string + url = output[output.find("`")+1:output.find("'")] - down = pexpect () - down.spawn (None, [download, '-c', 'test_gnunet_fs_rec_data.conf', '-R', '-o', 'rdir.gnd', url], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - down.expect ("stdout", re.compile (r"Downloading `rdir.gnd' done (.*).\r?\n")) + down = pexpect() + down.spawn(None, [download, '-c', 'test_gnunet_fs_rec_data.conf', '-R', '-o', 'rdir.gnd', url], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + down.expect("stdout", re.compile(r"Downloading `rdir.gnd' done (.*).\r?\n")) - d = pexpect () - d.spawn (None, [directory, '-c', 'test_gnunet_fs_rec_data.conf', 'rdir/a.gnd'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - d.expect ("stdout", re.compile (r"Directory `a/' meta data:\r?\n")) - d.expect ("stdout", re.compile (r"Directory `a/' contents:\r?\n")) - d.expect ("stdout", re.compile (r"COPYING (.*)\r?\n")) - d.expect ("stdout", re.compile (r"INSTALL (.*)\r?\n")) + d = pexpect() + d.spawn(None, [directory, '-c', 'test_gnunet_fs_rec_data.conf', 'rdir/a.gnd'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + d.expect("stdout", re.compile(r"Directory `a/' meta data:\r?\n")) + d.expect("stdout", re.compile(r"Directory `a/' contents:\r?\n")) + d.expect("stdout", re.compile(r"COPYING (.*)\r?\n")) + d.expect("stdout", re.compile(r"INSTALL (.*)\r?\n")) + + os.remove("rdir/b.gnd") + os.remove("rdir/a.gnd") + diff = dcdiff('dir', 'rdir') + if len(diff) != 0: + raise Exception("Unexpected difference between source directory and downloaded result:\n{}".format(diff)) - os.remove ("rdir/b.gnd") - os.remove ("rdir/a.gnd") - diff = dcdiff ('dir', 'rdir') - if len (diff) != 0: - raise Exception ("Unexpected difference between source directory and downloaded result:\n{}".format (diff)) - finally: - arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_fs_rec_data.conf']) - arm.communicate () - if os.name == "nt": - shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-rec"), True) - else: - shutil.rmtree ("/tmp/gnunet-test-fs-py-rec", True) - shutil.rmtree ("dir", True) - shutil.rmtree ("rdir", True) - shutil.rmtree ("rdir.gnd", True) + arm = subprocess.Popen([gnunetarm, '-eq', '-c', 'test_gnunet_fs_rec_data.conf']) + arm.communicate() + if os.name == "nt": + shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-rec"), True) + else: + shutil.rmtree("/tmp/gnunet-test-fs-py-rec", True) + shutil.rmtree("dir", True) + shutil.rmtree("rdir", True) + shutil.rmtree("rdir.gnd", True) diff --git a/src/util/gnunet-qr.py.in b/src/util/gnunet-qr.py.in index 549ce5af1..a5918fdf8 100755 --- a/src/util/gnunet-qr.py.in +++ b/src/util/gnunet-qr.py.in @@ -4,105 +4,106 @@ import getopt import subprocess from sys import argv try: - import zbar + import zbar except ImportError as e: - print('Cannot run gnunet-qr, please install zbar-python') - sys.exit (1) + print('Cannot run gnunet-qr, please install zbar-python') + sys.exit(1) -def help (): - print('gnunet-qr\n\ + +def help(): + print('gnunet-qr\n\ Scan a QR code using a video device and import\n\ Arguments mandatory for long options are also mandatory for short options.\n\ -c, --config=FILENAME use configuration file FILENAME\n\ -d, --device=DEVICE use device DEVICE\n\ -s, --silent do not show preview windows\n\ -h, --help print this help\n\ - -v, --verbose be verbose\n\ + -v, --verbose be verbose\n\ Report bugs to gnunet-developers@gnu.org.\n\ GNUnet home page: http://www.gnu.org/software/gnunet/\n\ General help using GNU software: http://www.gnu.org/gethelp/') if __name__ == '__main__': - configuration = '' - device = '/dev/video0' - url = '' - verbose = False - silent = False - # Parse arguments - try: - opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:sv", ["config","help", "device","silent","verbose"]) - except getopt.GetoptError as e: - help () - print(str (e)) - exit (1) - for o,a in opts: - if o in ("-h", "--help"): - help () - sys.exit (0) - elif o in ("-c", "--config"): - configuration = a - elif o in ("-d", "--device"): - device = a - elif o in ("-s", "--silent"): - silent = True - elif o in ("-v", "--verbose"): - verbose = True - if (True == verbose): - print('Initializing') - # create a Processor - proc = zbar.Processor() + configuration = '' + device = '/dev/video0' + url = '' + verbose = False + silent = False + # Parse arguments + try: + opts, args = getopt.gnu_getopt(sys.argv[1:], "c:hd:sv", ["config", "help", "device", "silent", "verbose"]) + except getopt.GetoptError as e: + help() + print(str(e)) + exit(1) + for o, a in opts: + if o in ("-h", "--help"): + help() + sys.exit(0) + elif o in ("-c", "--config"): + configuration = a + elif o in ("-d", "--device"): + device = a + elif o in ("-s", "--silent"): + silent = True + elif o in ("-v", "--verbose"): + verbose = True + if (True == verbose): + print('Initializing') + # create a Processor + proc = zbar.Processor() + + # configure the Processor + proc.parse_config('enable') + + # initialize the Processor + try: + if (True == verbose): + print('Opening video device ' + device) + proc.init(device) + except Exception as e: + print('Failed to open device ' + device) + exit(1) + + # enable the preview window + # if (True == silent): + # proc.visible = True + # else: + # proc.visible = False + + proc.visible = True + # read at least one barcode (or until window closed) + try: + if (True == verbose): + print('Capturing') + proc.process_one() + except Exception as e: + # Window was closed without finding code + exit(1) - # configure the Processor - proc.parse_config('enable') + # hide the preview window + proc.visible = False - # initialize the Processor - try: - if (True == verbose): - print('Opening video device ' + device) - proc.init(device) - except Exception as e: - print('Failed to open device ' + device) - exit (1) - - # enable the preview window - #if (True == silent): - # proc.visible = True - #else: - # proc.visible = False - - proc.visible = True - # read at least one barcode (or until window closed) - try: - if (True == verbose): - print('Capturing') - proc.process_one() - except Exception as e: - # Window was closed without finding code - exit (1) - - # hide the preview window - proc.visible = False - - # extract results - for symbol in proc.results: - # do something useful with results - if (True == verbose): - print('Found ', symbol.type, ' symbol ', '"%s"' % symbol.data) - args = list() - args.append("gnunet-uri") - if (configuration != ''): - args.append (str("-c " + str(configuration))) - args.append (str(symbol.data)) - cmd = '' - for a in args: - cmd += " " + str(a) - if (verbose): - print('Running `' + cmd +'`') - res=subprocess.call(args) - if (0 != res): - print('Failed to add URI ' + str(symbol.data)) - else: - print('Added URI ' + str(symbol.data)) - exit (res) - exit (1) + # extract results + for symbol in proc.results: + # do something useful with results + if (True == verbose): + print('Found ', symbol.type, ' symbol ', '"%s"' % symbol.data) + args = list() + args.append("gnunet-uri") + if (configuration != ''): + args.append(str("-c " + str(configuration))) + args.append(str(symbol.data)) + cmd = '' + for a in args: + cmd += " " + str(a) + if (verbose): + print('Running `' + cmd +'`') + res=subprocess.call(args) + if (0 != res): + print('Failed to add URI ' + str(symbol.data)) + else: + print('Added URI ' + str(symbol.data)) + exit(res) + exit(1)