Lint fixes
This commit is contained in:
parent
8539d69810
commit
8670a5e903
|
@ -28,6 +28,7 @@ def parse_qs():
|
|||
class HTTPBasicAuth:
|
||||
username = None
|
||||
password = None
|
||||
|
||||
def __str__(self):
|
||||
return "<HTTPBasicAuth object username='%s' password='%s'>" % (self.username, self.password)
|
||||
|
||||
|
|
12
get_backup
12
get_backup
|
@ -2,11 +2,11 @@
|
|||
|
||||
import traceback
|
||||
import os
|
||||
from sys import exit,stdin,stdout
|
||||
from sys import exit, stdout
|
||||
from os.path import join as pathjoin
|
||||
from os.path import exists, getsize
|
||||
from common.cgi import parse_qs, parse_auth, start_response
|
||||
from common.datadb import DATADB_ROOT, DATADB_TMP, DATADB_DIR_TIMESTAMP_FORMAT
|
||||
from common.datadb import DATADB_ROOT, DATADB_DIR_TIMESTAMP_FORMAT
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
|
@ -28,7 +28,8 @@ def get_backup_dir(backup_name):
|
|||
|
||||
def handle_head(backup_name):
|
||||
try:
|
||||
backup_path = get_backup_dir(backup_name)
|
||||
# backup_path = get_backup_dir(backup_name)
|
||||
# TODO appropriate content-length for HEAD
|
||||
start_response(extra_headers=['Content-length: 0'])
|
||||
except:
|
||||
start_response(status_code=("404", "Not Found",), extra_headers=['Content-length: 0'])
|
||||
|
@ -52,7 +53,8 @@ def handle_get_archive(backup_name):
|
|||
backup_path = pathjoin(get_backup_dir(backup_name), 'backup.tar.gz')
|
||||
|
||||
with open(backup_path, 'rb') as f:
|
||||
start_response(content_type="application/x-gzip", extra_headers=["Content-length: %s" % getsize(backup_path),
|
||||
start_response(content_type="application/x-gzip",
|
||||
extra_headers=["Content-length: %s" % getsize(backup_path),
|
||||
"Content-Disposition: attachment; filename=\"backup.tar.gz\""])
|
||||
while True:
|
||||
data = f.read(8192)
|
||||
|
@ -69,7 +71,7 @@ def handle_req():
|
|||
params = parse_qs()
|
||||
|
||||
for param_name in ["proto", "name"]:
|
||||
if not param_name in params:
|
||||
if param_name not in params:
|
||||
raise Exception("Missing parameter: %s" % param_name)
|
||||
|
||||
if os.environ['REQUEST_METHOD'] == "GET" and params["proto"] == "rsync":
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os,sys,cgi
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
from os import mkdir,rename,unlink,rmdir,utime,makedirs
|
||||
from os import mkdir, rename, unlink, rmdir, utime
|
||||
from os.path import exists
|
||||
from os.path import join as pathjoin
|
||||
from common.cgi import parse_qs, parse_auth, start_response
|
||||
|
@ -204,7 +205,7 @@ def handle_req():
|
|||
params = parse_qs()
|
||||
|
||||
for param_name in ["proto", "name"]:
|
||||
if not param_name in params:
|
||||
if param_name not in params:
|
||||
raise Exception("Missing parameter: %s" % param_name)
|
||||
|
||||
max_backups = int(params["keep"]) if "keep" in params else 5
|
||||
|
|
Loading…
Reference in New Issue