summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Weiser <michael.weiser@gmx.de>2019-02-12 13:47:03 +0000
committerMichael Weiser <michael.weiser@gmx.de>2019-02-13 08:27:45 +0000
commitd97e5779f23d5f62f3cb3cbfaccc3369983018c3 (patch)
tree62fbcfc8fd8559ac1a2001b2caa8a3767ebc2592
parentf5e534d4afdee5379ce7e9f2100f265686055a9b (diff)
Allow multiple files to be scanned at once
To simulate typical usage by e.g. AMaViS, allow scan_file.py to submit more than one file at once for analysis.
-rwxr-xr-xbin/scan_file.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/scan_file.py b/bin/scan_file.py
index c11fa23..b8434c1 100755
--- a/bin/scan_file.py
+++ b/bin/scan_file.py
@@ -49,18 +49,24 @@ def main():
help='Output additional diagnostics')
parser.add_argument('-s', '--socket_file', action='store', required=True,
help='Path to Peekaboo\'s socket file')
- parser.add_argument('-f', '--filename', action='store', required=True,
- help='Path to the file to scan')
+ parser.add_argument('-f', '--filename', action='append', required=True,
+ help='Path to the file to scan. Can be given more '
+ 'than once to scan multiple files.')
args = parser.parse_args()
result_regex = re.compile(r'.*wurde als',
re.MULTILINE + re.DOTALL + re.UNICODE)
- file_abspath = path.abspath(args.filename)
peekaboo = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
peekaboo.connect(args.socket_file)
- request = '[ { "full_name": "%s" } ]' % file_abspath
+
+ file_snippets = []
+ for filename in args.filename:
+ file_snippets.append('{ "full_name": "%s" }' % path.abspath(filename))
+ request = '[ %s ]' % ', '.join(file_snippets)
+
if args.debug:
print ('Sending request: %s' % request)
+
peekaboo.send(request)
print ('Waiting for response...')