Fix client download

This commit is contained in:
Martin 2020-04-30 22:58:41 +02:00
parent 80c666e737
commit fe8f7c5300
3 changed files with 19 additions and 9 deletions

View File

@ -16,7 +16,7 @@ setup(
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.9',
version='0.10',
description='Python wrapper to access and control an UrBackup server',
long_description=long_description,

View File

@ -1,6 +1,8 @@
import urbackup_api
from urbackup_api import installer_os
import datetime
import time
import sys
server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")
@ -45,7 +47,7 @@ for client in clients:
if not server.get_livelog():
print("Failed to get livelog contents"
print("Failed to get livelog contents")
settings = server.get_client_settings("Johnwin7test-PC2")
@ -76,3 +78,6 @@ backups = server.get_clientbackups('8')
#Get all image backups for a specified client id
backups_image = server.get_clientimagebackups('8')
#Download a client installer
server.download_installer("test.exe", "test", installer_os.Windows)

View File

@ -9,8 +9,12 @@ import shutil
import os
import binascii
import logging
from enum import Enum
logger = logging.getLogger('urbackup-server-python-api-wrapper')
class installer_os(Enum):
Windows = "windows",
Linux = "linux"
class urbackup_server:
@ -101,7 +105,7 @@ class urbackup_server:
def _download_file(self, action, outputfn, params):
response = self.get_response(action, params, "GET");
response = self._get_response(action, params, "GET");
if(response.status!=200):
return False
@ -190,13 +194,12 @@ class urbackup_server:
logger.warning("Could not find client status. No permission?")
return None
def download_installer(self, installer_fn, new_clientname):
def download_installer(self, installer_fn, new_clientname, e_installer_os):
if not self.login():
return False
new_client = self._get_json("add_client", { "clientname": new_clientname})
new_client = self._get_json("add_client", { "clientname": new_clientname })
if "already_exists" in new_client:
status = self.get_client_status(new_clientname)
@ -205,7 +208,8 @@ class urbackup_server:
return False
return self._download_file("download_client", installer_fn,
{"clientid": status["id"] })
{"clientid": status["id"],
"os": e_installer_os.value})
if not "new_authkey" in new_client:
@ -213,7 +217,8 @@ class urbackup_server:
return self._download_file("download_client", installer_fn,
{"clientid": new_client["new_clientid"],
"authkey": new_client["new_authkey"]
"authkey": new_client["new_authkey"],
"os": e_installer_os.value
})
def add_client(self, clientname):