forked from joxeankoret/multiav
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiav-client.py
More file actions
40 lines (33 loc) · 1.05 KB
/
multiav-client.py
File metadata and controls
40 lines (33 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
import os
import sys
import json
import pprint
import postfile
#-----------------------------------------------------------------------
class CMultiAvUploader:
def __init__(self, host):
self.host = host
def scan(self, filename, fast=False):
selector = "/api/upload"
if fast:
selector = "/api/upload_fast"
file_buf = open(filename, "rb").read()
files = [("file_upload", os.path.basename(filename), file_buf)]
json_txt = postfile.post_multipart(self.host, selector, [], files)
d = json.loads(json_txt)
return d
#-----------------------------------------------------------------------
def usage():
print "Usage:", sys.argv[0], "<multi-av host> <filename> [--fast]"
#-----------------------------------------------------------------------
def main(url, filename, fast=False):
scanner = CMultiAvUploader(url)
ret = scanner.scan(filename, fast)
print "Results:\n"
pprint.pprint(ret)
if __name__ == "__main__":
if len(sys.argv) < 3:
usage()
else:
main(sys.argv[1], sys.argv[2], len(sys.argv) > 3)