From 1b496fa712ec22c365a14df6064a3b5f93e23f1f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 7 Mar 2014 14:01:34 +0530 Subject: [PATCH] Raise Forbidden if backup download is not allowed, verbose is default in cli.py --- .travis.yml | 6 +++--- frappe/cli.py | 4 ++-- frappe/utils/backups.py | 11 +++-------- frappe/utils/response.py | 5 +++-- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ccd9a1345..ab84d5d8cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,9 @@ install: script: cd ./test_sites/ && - frappe --reinstall -v test_site && - frappe -b -v test_site && - frappe --run_tests -v test_site + frappe --reinstall test_site && + frappe -b test_site && + frappe --run_tests test_site before_script: - mysql -e 'create database travis' && diff --git a/frappe/cli.py b/frappe/cli.py index a97da6f8d5..0995bcbf46 100755 --- a/frappe/cli.py +++ b/frappe/cli.py @@ -101,8 +101,8 @@ def setup_parser(): # common parser.add_argument("-f", "--force", default=False, action="store_true", help="Force execution where applicable (look for [-f] in help)") - parser.add_argument("-v", "--verbose", default=False, action="store_true", dest="verbose", - help="Show verbose output where applicable") + parser.add_argument("--quiet", default=True, action="store_false", dest="verbose", + help="Do not show verbose output (where applicable)") return parser.parse_args() diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py index 17c6831cf6..a7c5657123 100644 --- a/frappe/utils/backups.py +++ b/frappe/utils/backups.py @@ -1,15 +1,10 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt +"""This module handles the On Demand Backup utility""" + from __future__ import unicode_literals -""" - This module handles the On Demand Backup utility - - To setup in defs set: - backup_path: path where backups will be taken (for eg /backups) - backup_link_path: download link for backups (eg /var/www/frappe/backups) - backup_url: base url of the backup folder (eg http://mysite.com/backups) -""" + #Imports import os, frappe from datetime import datetime diff --git a/frappe/utils/response.py b/frappe/utils/response.py index 7ac620bf6f..6180ccc737 100644 --- a/frappe/utils/response.py +++ b/frappe/utils/response.py @@ -8,13 +8,14 @@ import gzip, cStringIO import mimetypes import os import frappe +from frappe import _ import frappe.utils import frappe.sessions import frappe.model.utils from werkzeug.local import LocalProxy from werkzeug.wsgi import wrap_file from werkzeug.wrappers import Response -from werkzeug.exceptions import NotFound, Unauthorized +from werkzeug.exceptions import NotFound, Forbidden def report_error(status_code): if status_code!=404 or frappe.conf.logging: @@ -123,7 +124,7 @@ def download_backup(path): try: frappe.only_for(("System Manager", "Administrator")) except frappe.PermissionError: - raise Unauthorized + raise Forbidden(_("You need to be logged in and have System Manager Role to be able to access backups.")) send_private_file(path) def send_private_file(path):