summaryrefslogtreecommitdiff
path: root/fbin-backup.py
diff options
context:
space:
mode:
Diffstat (limited to 'fbin-backup.py')
-rw-r--r--fbin-backup.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/fbin-backup.py b/fbin-backup.py
index 5ef3a87..84d7265 100644
--- a/fbin-backup.py
+++ b/fbin-backup.py
@@ -4,7 +4,7 @@ import os
from flask import Flask, Response
-from fbin.db import db, User, File
+from fbin.db import db, File
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--source-config-file', default='fbin/fbin.cfg')
@@ -13,6 +13,7 @@ parser.add_argument('--update-db', action='store_true', help='Update DB as well'
parser.add_argument('-n', '--dry-run', action='store_true', help='Do not update anything')
args = parser.parse_args()
+
class DummyFile:
def __init__(self, stream, filename, content_length):
self.stream = stream
@@ -20,10 +21,11 @@ class DummyFile:
self.content_length = content_length
def save(self, fp):
- chunk = self.stream.read(10*1024)
+ chunk = self.stream.read(10 * 1024)
while chunk:
fp.write(chunk)
- chunk = self.stream.read(10*1024)
+ chunk = self.stream.read(10 * 1024)
+
class IterStream:
def __init__(self, it):
@@ -35,11 +37,12 @@ class IterStream:
except StopIteration:
return None
+
def main():
- from fbin.file_storage.s3 import Storage as S3Storage
- from fbin.file_storage.filesystem import Storage as FSStorage
- source_storage = importlib.import_module(source_app.config.get('STORAGE_MODULE', '.file_storage.filesystem'), package='fbin').Storage(source_app)
- target_storage = importlib.import_module(target_app.config.get('STORAGE_MODULE', '.file_storage.filesystem'), package='fbin').Storage(target_app)
+ source_storage = importlib.import_module(source_app.config.get('STORAGE_MODULE', '.file_storage.filesystem'),
+ package='fbin').Storage(source_app)
+ target_storage = importlib.import_module(target_app.config.get('STORAGE_MODULE', '.file_storage.filesystem'),
+ package='fbin').Storage(target_app)
copy_list = []
with source_app.app_context():
db.init_app(source_app)
@@ -81,6 +84,7 @@ def main():
else:
target_storage.upload_file(df, f.hash, f.user)
+
source_app = Flask('source')
target_app = Flask('target')
with source_app.app_context():