#!/bin/python3 import os import sys import logging import json import requests # Identity attributes # {'username' : '', 'full_name' : '', 'email' : '', public_key : '' } logging.basicConfig(format='%(levelname)s\t- %(message)s') logger = logging.getLogger() logger.setLevel(logging.INFO) state = {} #get file #file handle - file def getFile(args): if len(args) < 1: logger.error("Need a file handle.") sys.exit(-1) if len(args) == 2: if (not os.path.isfile(args[1])): logger.error("File '" + args[1] + "' not found.") sys.exit(-1) file = json.loads(requests.get(f'http://{state['REP_ADDRESS']}/file'), params = {"file_handle" : args[0]}) # decrypt file content = '' #decrypt(file.encode('utf-8')) if len(args) == 1: sys.stdout.write(content) else: with open(args[1], "wb") as f: f.write(content) if __name__ == '__main__': getFile(sys.argv[1:])