Simplify call
This commit is contained in:
parent
f84e226770
commit
e3796e6569
38
backup.py
38
backup.py
@ -24,25 +24,31 @@ class Backup:
|
|||||||
tarball_size = "50M"
|
tarball_size = "50M"
|
||||||
save_location = ""
|
save_location = ""
|
||||||
|
|
||||||
def __init__(self, key, bdd=None, save_mode=None, save_location=None, app_key_id=None, app_key=None, bucket_id=None):
|
def backblaze(self, key, bdd=None, app_key_id=None, app_key=None, bucket_id=None):
|
||||||
self.key = key
|
self.key = key
|
||||||
|
self.save_mode = BACKBLAZE
|
||||||
|
|
||||||
if save_mode is None:
|
if None in (app_key_id, app_key, bucket_id):
|
||||||
raise Exception("No save_mode")
|
raise Exception("Some arguments are not filled")
|
||||||
elif save_mode == BACKBLAZE:
|
self.b2 = B2Api()
|
||||||
if None in (app_key_id, app_key, bucket_id):
|
self.b2.authorize_account("production", app_key_id, app_key)
|
||||||
raise Exception("Some arguments are not filled")
|
self.buk = self.b2.get_bucket_by_id(bucket_id)
|
||||||
self.b2 = B2Api()
|
self.bdd = DataBase(bdd)
|
||||||
self.b2.authorize_account("production", app_key_id, app_key)
|
|
||||||
self.buk = self.b2.get_bucket_by_id(bucket_id)
|
return self
|
||||||
self.bdd = DataBase(bdd)
|
|
||||||
elif save_mode == LOCAL:
|
|
||||||
if None in (save_location, bdd):
|
def local(self, key, bdd=None, save_location=None):
|
||||||
raise Exception("Some arguments are not filled")
|
self.key = key
|
||||||
self.save_location = save_location
|
self.save_mode = LOCAL
|
||||||
self.bdd = DataBase(bdd)
|
|
||||||
|
if None in (save_location, bdd):
|
||||||
|
raise Exception("Some arguments are not filled")
|
||||||
|
self.save_location = save_location
|
||||||
|
self.bdd = DataBase(bdd)
|
||||||
|
|
||||||
|
return self
|
||||||
|
|
||||||
self.save_mode = save_mode
|
|
||||||
|
|
||||||
def save(self, path, recurse=True):
|
def save(self, path, recurse=True):
|
||||||
self.__save(path, recurse=recurse)
|
self.__save(path, recurse=recurse)
|
||||||
|
4
main.py
4
main.py
@ -20,8 +20,8 @@ bucket_id = '6a1a9000075465fe7cc4021a'
|
|||||||
|
|
||||||
bdd = "bdd.db"
|
bdd = "bdd.db"
|
||||||
|
|
||||||
# bck = Backup(key, save_mode=backup.BACKBLAZE, bdd=bdd, app_key_id=application_key_id, app_key=application_key, bucket_id=bucket_id)
|
#bck = Backup().backblaze(key, bdd=bdd, app_key_id=application_key_id, app_key=application_key, bucket_id=bucket_id)
|
||||||
bck = Backup(key, save_mode=backup.LOCAL, bdd=bdd, save_location="crypted")
|
bck = Backup().local(key, bdd=bdd, save_location="crypted")
|
||||||
|
|
||||||
rootdir = "test"
|
rootdir = "test"
|
||||||
bck.save(rootdir).save("share", recurse=False)
|
bck.save(rootdir).save("share", recurse=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user