From f9744091d16d405e22d949a1bcc4e7875470b6c2 Mon Sep 17 00:00:00 2001 From: Edoardo Putti Date: Mon, 20 Feb 2017 16:45:10 +0100 Subject: [PATCH] remove RequestLoader class --- models/request.py | 61 ----------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/models/request.py b/models/request.py index 4a1fac9..71e4056 100755 --- a/models/request.py +++ b/models/request.py @@ -39,67 +39,6 @@ class SignRequest(object): def destination(self): return os.path.join(OUTPUT_PATH, self.req_id + '.pub') -class RequestLoader(object): - """ - Context manager that loads a request from a file - and return a Request type - """ - - def __init__(self, request_id): - self.request_id = request_id - self.request_dir = REQUESTS_PATH - - @property - def path(self): - return os.path.join(self.request_dir, self.request_id) - - def __enter__(self): - with open(self.path, 'r') as stream: - request_data = json.load( - stream, - ) - - requester = request_data.get('userName', None) or request_data.get('hostName', None) - root_requested = request_data.get('rootRequested', False) - key_data = request_data.get('keyData', None) - - # attribute cannot be read from - # json, must add after decoding - request_id = self.request_id - - values = request_data.values() - - if 'ssh_user' in values: - return UserSSHRequest( - request_id, - requester, - root_requested, - key_data, - ) - - elif 'ssh_host' in values: - return HostSSHRequest( - request_id, - requester, - key_data, - ) - - elif 'ssl_host' in values: - return HostSSLRequest( - request_id, - requester, - key_data, - ) - - else: - # ultimate error, cannot be decoded - return SignRequest(request_id) - - def __exit__(self, exc_type, exc_value, traceback): - if exc_type is not None: - print(exc_type, exc_value) - print(traceback) - @property def fields(self):