Skip to content

Commit fe8f7c5

Browse files
committed
Fix client download
1 parent 80c666e commit fe8f7c5

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Versions should comply with PEP440. For a discussion on single-sourcing
1717
# the version across setup.py and the project code, see
1818
# https://packaging.python.org/en/latest/single_source_version.html
19-
version='0.9',
19+
version='0.10',
2020

2121
description='Python wrapper to access and control an UrBackup server',
2222
long_description=long_description,

test/urbackup_api_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import urbackup_api
2+
from urbackup_api import installer_os
23
import datetime
34
import time
5+
import sys
46

57

68
server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")
@@ -45,7 +47,7 @@
4547

4648

4749
if not server.get_livelog():
48-
print("Failed to get livelog contents"
50+
print("Failed to get livelog contents")
4951

5052
settings = server.get_client_settings("Johnwin7test-PC2")
5153

@@ -76,3 +78,6 @@
7678

7779
#Get all image backups for a specified client id
7880
backups_image = server.get_clientimagebackups('8')
81+
82+
#Download a client installer
83+
server.download_installer("test.exe", "test", installer_os.Windows)

urbackup_api/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
import os
1010
import binascii
1111
import logging
12+
from enum import Enum
1213
logger = logging.getLogger('urbackup-server-python-api-wrapper')
1314

15+
class installer_os(Enum):
16+
Windows = "windows",
17+
Linux = "linux"
1418

1519
class urbackup_server:
1620

@@ -101,7 +105,7 @@ def _get_json(self, action, params = {}):
101105

102106
def _download_file(self, action, outputfn, params):
103107

104-
response = self.get_response(action, params, "GET");
108+
response = self._get_response(action, params, "GET");
105109

106110
if(response.status!=200):
107111
return False
@@ -190,13 +194,12 @@ def get_client_status(self, clientname):
190194
logger.warning("Could not find client status. No permission?")
191195
return None
192196

193-
def download_installer(self, installer_fn, new_clientname):
197+
def download_installer(self, installer_fn, new_clientname, e_installer_os):
194198

195199
if not self.login():
196200
return False
197-
198-
new_client = self._get_json("add_client", { "clientname": new_clientname})
199-
201+
202+
new_client = self._get_json("add_client", { "clientname": new_clientname })
200203
if "already_exists" in new_client:
201204

202205
status = self.get_client_status(new_clientname)
@@ -205,15 +208,17 @@ def download_installer(self, installer_fn, new_clientname):
205208
return False
206209

207210
return self._download_file("download_client", installer_fn,
208-
{"clientid": status["id"] })
211+
{"clientid": status["id"],
212+
"os": e_installer_os.value})
209213

210214

211215
if not "new_authkey" in new_client:
212216
return False
213217

214218
return self._download_file("download_client", installer_fn,
215219
{"clientid": new_client["new_clientid"],
216-
"authkey": new_client["new_authkey"]
220+
"authkey": new_client["new_authkey"],
221+
"os": e_installer_os.value
217222
})
218223

219224
def add_client(self, clientname):

0 commit comments

Comments
 (0)