From a500e233a51d1941deef7d4b37f429dfd038e7ec Mon Sep 17 00:00:00 2001 From: K mehant Date: Sun, 2 Jun 2019 09:40:02 +0530 Subject: [PATCH 1/4] Defined endpoints for file compression feature --- components/core/Server.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/core/Server.py b/components/core/Server.py index 7063f6dd..935583bf 100644 --- a/components/core/Server.py +++ b/components/core/Server.py @@ -68,3 +68,5 @@ def serve_ui1(): # file sending endpoints server.add_url_rule(rule='/api/file', endpoint='send_file_from_path', view_func=sender.send_file_from_path, methods=['GET']) +server.add_url_rule('/api/compress', 'start_compression', sender.start_compression, methods=['POST']) +server.add_url_rule('/api/compression-progress', 'get_compression_progress', sender.check_compression_progress, methods=['GET']) From 6221916b99396e395cb0187c0b6ade363dda0428 Mon Sep 17 00:00:00 2001 From: K mehant Date: Sun, 2 Jun 2019 09:43:24 +0530 Subject: [PATCH 2/4] Fixed imports in sender.py and fetch aria2c server link from configuration --- components/core/file_sender/sender.py | 3 +++ components/core/routes/Download.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/core/file_sender/sender.py b/components/core/file_sender/sender.py index 20a5c426..6b06255b 100644 --- a/components/core/file_sender/sender.py +++ b/components/core/file_sender/sender.py @@ -1,6 +1,9 @@ from flask import Response, request, send_file, jsonify from DownloadManager import get_id_from_gid, get_download_path, get_download_name_from_id, get_compression_progress import logging +import os +import subprocess +import json from utils.token_utils import token_validator diff --git a/components/core/routes/Download.py b/components/core/routes/Download.py index 7b51485e..fcb9943d 100644 --- a/components/core/routes/Download.py +++ b/components/core/routes/Download.py @@ -8,7 +8,7 @@ from utils.app_constants import SERVER_SECRET_KEY from utils.token_utils import token_validator from initializer import socketio - +conf = get_conf_reader("dl.conf") def start(): try: @@ -33,7 +33,8 @@ def kill(): p.join() jsonreq = json.dumps({'jsonrpc': '2.0', 'id': 'qwer', 'method': 'aria2.pauseAll'}) jsonreq = jsonreq.encode('ascii') - c = urllib.request.urlopen('http://localhost:6800/jsonrpc', jsonreq) + # c = urllib.request.urlopen('http://localhost:6800/jsonrpc', jsonreq) + c = urllib.request.urlopen(conf['aria_server'], jsonreq) if verbose: print(c) if not p.is_alive(): From 8fb08ef45e2ae05b0c9325fa2e323c5a4c050a0f Mon Sep 17 00:00:00 2001 From: K mehant Date: Tue, 4 Jun 2019 09:17:12 +0530 Subject: [PATCH 3/4] remove unnecessary comments --- components/core/routes/Download.py | 1 - 1 file changed, 1 deletion(-) diff --git a/components/core/routes/Download.py b/components/core/routes/Download.py index fcb9943d..6aa1cafa 100644 --- a/components/core/routes/Download.py +++ b/components/core/routes/Download.py @@ -33,7 +33,6 @@ def kill(): p.join() jsonreq = json.dumps({'jsonrpc': '2.0', 'id': 'qwer', 'method': 'aria2.pauseAll'}) jsonreq = jsonreq.encode('ascii') - # c = urllib.request.urlopen('http://localhost:6800/jsonrpc', jsonreq) c = urllib.request.urlopen(conf['aria_server'], jsonreq) if verbose: print(c) From 73967ef17c8ef82985d3d15ace564fadee2a7fa3 Mon Sep 17 00:00:00 2001 From: K mehant Date: Mon, 17 Jun 2019 01:17:34 +0530 Subject: [PATCH 4/4] Updated using function arguments --- components/core/Server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/core/Server.py b/components/core/Server.py index 935583bf..8ddc2c8a 100644 --- a/components/core/Server.py +++ b/components/core/Server.py @@ -68,5 +68,5 @@ def serve_ui1(): # file sending endpoints server.add_url_rule(rule='/api/file', endpoint='send_file_from_path', view_func=sender.send_file_from_path, methods=['GET']) -server.add_url_rule('/api/compress', 'start_compression', sender.start_compression, methods=['POST']) -server.add_url_rule('/api/compression-progress', 'get_compression_progress', sender.check_compression_progress, methods=['GET']) +server.add_url_rule(rule='/api/compress', endpoint='start_compression', view_func=sender.start_compression, methods=['POST']) +server.add_url_rule(rule='/api/compression-progress', endpoint='get_compression_progress', view_func=sender.check_compression_progress, methods=['GET'])