python-bareos 22.1.2__tar.gz → 23.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {python-bareos-22.1.2 → python-bareos-23.0.0}/PKG-INFO +1 -1
  2. python-bareos-23.0.0/bareos/VERSION.txt +1 -0
  3. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/directorconsole.py +23 -9
  4. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/filedaemon.py +5 -4
  5. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/lowlevel.py +27 -15
  6. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/util/__init__.py +3 -2
  7. python-bareos-23.0.0/bareos/util/version.py +35 -0
  8. {python-bareos-22.1.2 → python-bareos-23.0.0}/python_bareos.egg-info/PKG-INFO +1 -1
  9. {python-bareos-22.1.2 → python-bareos-23.0.0}/python_bareos.egg-info/SOURCES.txt +1 -0
  10. python-bareos-22.1.2/bareos/VERSION.txt +0 -1
  11. {python-bareos-22.1.2 → python-bareos-23.0.0}/LICENSE.txt +0 -0
  12. {python-bareos-22.1.2 → python-bareos-23.0.0}/README.rst +0 -0
  13. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/__init__.py +0 -0
  14. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/__init__.py +0 -0
  15. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/bsock.py +0 -0
  16. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/bsockjson.py +0 -0
  17. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/connectiontype.py +0 -0
  18. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/constants.py +0 -0
  19. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/directorconsolejson.py +0 -0
  20. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/protocolmessageids.py +0 -0
  21. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/protocolmessages.py +0 -0
  22. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/protocolversions.py +0 -0
  23. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/bsock/tlsversionparser.py +0 -0
  24. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/exceptions.py +0 -0
  25. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/util/bareosbase64.py +0 -0
  26. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/util/password.py +0 -0
  27. {python-bareos-22.1.2 → python-bareos-23.0.0}/bareos/util/path.py +0 -0
  28. {python-bareos-22.1.2 → python-bareos-23.0.0}/bin/bareos-fd-connect.py +0 -0
  29. {python-bareos-22.1.2 → python-bareos-23.0.0}/bin/bconsole-json.py +0 -0
  30. {python-bareos-22.1.2 → python-bareos-23.0.0}/bin/bconsole.py +0 -0
  31. {python-bareos-22.1.2 → python-bareos-23.0.0}/python_bareos.egg-info/dependency_links.txt +0 -0
  32. {python-bareos-22.1.2 → python-bareos-23.0.0}/python_bareos.egg-info/requires.txt +0 -0
  33. {python-bareos-22.1.2 → python-bareos-23.0.0}/python_bareos.egg-info/top_level.txt +0 -0
  34. {python-bareos-22.1.2 → python-bareos-23.0.0}/setup.cfg +0 -0
  35. {python-bareos-22.1.2 → python-bareos-23.0.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-bareos
3
- Version: 22.1.2
3
+ Version: 23.0.0
4
4
  Summary: Client library and tools for Bareos console access.
5
5
  Home-page: https://github.com/bareos/bareos/
6
6
  Author: Bareos Team
@@ -0,0 +1 @@
1
+ 23.0.0
@@ -1,6 +1,6 @@
1
1
  # BAREOS - Backup Archiving REcovery Open Sourced
2
2
  #
3
- # Copyright (C) 2016-2021 Bareos GmbH & Co. KG
3
+ # Copyright (C) 2016-2023 Bareos GmbH & Co. KG
4
4
  #
5
5
  # This program is Free Software; you can redistribute it and/or
6
6
  # modify it under the terms of version three of the GNU Affero General Public
@@ -93,11 +93,18 @@ class DirectorConsole(LowLevel):
93
93
  dest="BAREOS_address",
94
94
  )
95
95
 
96
+ argparser.add_argument(
97
+ "--timeout",
98
+ type=int,
99
+ help="Timeout (in seconds) for the connection to the Bareos Director.",
100
+ dest="BAREOS_timeout",
101
+ )
102
+
96
103
  argparser.add_argument(
97
104
  "--protocolversion",
98
105
  default=ProtocolVersions.last,
99
106
  type=int,
100
- help=u"Specify the Bareos console protocol version. Default: {0} (current).".format(
107
+ help="Specify the Bareos console protocol version. Default: {0} (current).".format(
101
108
  ProtocolVersions.last
102
109
  ),
103
110
  dest="BAREOS_protocolversion",
@@ -128,6 +135,7 @@ class DirectorConsole(LowLevel):
128
135
  self,
129
136
  address="localhost",
130
137
  port=9101,
138
+ timeout=None,
131
139
  dirname=None,
132
140
  name="*UserAgent*",
133
141
  password=None,
@@ -145,6 +153,9 @@ class DirectorConsole(LowLevel):
145
153
 
146
154
  port (int): Port number of the Bareos Director.
147
155
 
156
+ timeout (int, optional):
157
+ Timeout for the connection to the director. Default: OS dependent
158
+
148
159
  dirname (str, optional):
149
160
  Name of the Bareos Director. Deprecated, normally not required.
150
161
 
@@ -177,20 +188,23 @@ class DirectorConsole(LowLevel):
177
188
  self.pam_password = pam_password
178
189
  self.tls_psk_enable = tls_psk_enable
179
190
  self.tls_psk_require = tls_psk_require
191
+ self.timeout = timeout
180
192
  if tls_version is not None:
181
193
  self.tls_version = tls_version
182
- self.identity_prefix = u"R_CONSOLE"
194
+ self.identity_prefix = "R_CONSOLE"
183
195
  if protocolversion is not None:
184
196
  self.requested_protocol_version = int(protocolversion)
185
197
  self.protocol_messages.set_version(self.requested_protocol_version)
186
- self.connect(address, port, dirname, ConnectionType.DIRECTOR, name, password)
198
+ self.connect(
199
+ address, port, dirname, ConnectionType.DIRECTOR, name, password, timeout
200
+ )
187
201
  self._init_connection()
188
202
  self.max_reconnects = 1
189
203
 
190
204
  def _finalize_authentication(self):
191
205
  code, text = self.receive_and_evaluate_response_message()
192
206
 
193
- self.logger.debug(u"code: {0}".format(code))
207
+ self.logger.debug("code: {0}".format(code))
194
208
 
195
209
  #
196
210
  # Test if PAM is requested.
@@ -201,7 +215,7 @@ class DirectorConsole(LowLevel):
201
215
  # it will be evaluated with all protocol versions.
202
216
  #
203
217
  if code == ProtocolMessageIds.PamRequired:
204
- self.logger.debug(u"PAM request: {0}".format(text))
218
+ self.logger.debug("PAM request: {0}".format(text))
205
219
  if (not self.pam_username) or (not self.pam_password):
206
220
  raise bareos.exceptions.PamAuthenticationError(
207
221
  "PAM authentication is requested, but no PAM credentials given. Giving up.\n"
@@ -215,7 +229,7 @@ class DirectorConsole(LowLevel):
215
229
  code, text = self.receive_and_evaluate_response_message()
216
230
  except bareos.exceptions.ConnectionLostError as e:
217
231
  raise bareos.exceptions.PamAuthenticationError(
218
- u"PAM authentication failed."
232
+ "PAM authentication failed."
219
233
  )
220
234
  else:
221
235
  if (self.pam_username) or (self.pam_password):
@@ -227,7 +241,7 @@ class DirectorConsole(LowLevel):
227
241
  # Test if authentication has been accepted.
228
242
  #
229
243
  if code == ProtocolMessageIds.Ok:
230
- self.logger.info(u"Authentication: {0}".format(text))
244
+ self.logger.info("Authentication: {0}".format(text))
231
245
  self.auth_credentials_valid = True
232
246
  else:
233
247
  raise bareos.exceptions.AuthenticationError(
@@ -242,7 +256,7 @@ class DirectorConsole(LowLevel):
242
256
  #
243
257
  code, text = self.receive_and_evaluate_response_message()
244
258
  if code == ProtocolMessageIds.InfoMessage:
245
- self.logger.debug(u"Info: {0}".format(text))
259
+ self.logger.debug("Info: {0}".format(text))
246
260
  else:
247
261
  raise bareos.exceptions.AuthenticationError(
248
262
  "Received unexcepted message: {0} {1} (expecting info message)".format(
@@ -1,6 +1,6 @@
1
1
  # BAREOS - Backup Archiving REcovery Open Sourced
2
2
  #
3
- # Copyright (C) 2016-2021 Bareos GmbH & Co. KG
3
+ # Copyright (C) 2016-2023 Bareos GmbH & Co. KG
4
4
  #
5
5
  # This program is Free Software; you can redistribute it and/or
6
6
  # modify it under the terms of version three of the GNU Affero General Public
@@ -100,6 +100,7 @@ class FileDaemon(LowLevel):
100
100
  self,
101
101
  address="localhost",
102
102
  port=9102,
103
+ dirname=None,
103
104
  name=None,
104
105
  password=None,
105
106
  tls_psk_enable=True,
@@ -136,20 +137,20 @@ class FileDaemon(LowLevel):
136
137
  self.tls_version = tls_version
137
138
  # Well, we are not really a Director,
138
139
  # but using the interface provided for Directors.
139
- self.identity_prefix = u"R_DIRECTOR"
140
+ self.identity_prefix = "R_DIRECTOR"
140
141
  self.connect(address, port, dirname, ConnectionType.FILEDAEMON, name, password)
141
142
  self._init_connection()
142
143
 
143
144
  def _finalize_authentication(self):
144
145
  code, text = self.receive_and_evaluate_response_message()
145
146
 
146
- self.logger.debug(u"code: {0}".format(code))
147
+ self.logger.debug("code: {0}".format(code))
147
148
 
148
149
  #
149
150
  # Test if authentication has been accepted.
150
151
  #
151
152
  if code == ProtocolMessageIds.FdOk:
152
- self.logger.info(u"Authentication: {0}".format(text))
153
+ self.logger.info("Authentication: {0}".format(text))
153
154
  self.auth_credentials_valid = True
154
155
  else:
155
156
  raise bareos.exceptions.AuthenticationError(
@@ -1,6 +1,6 @@
1
1
  # BAREOS - Backup Archiving REcovery Open Sourced
2
2
  #
3
- # Copyright (C) 2015-2021 Bareos GmbH & Co. KG
3
+ # Copyright (C) 2015-2023 Bareos GmbH & Co. KG
4
4
  #
5
5
  # This program is Free Software; you can redistribute it and/or
6
6
  # modify it under the terms of version three of the GNU Affero General Public
@@ -55,7 +55,7 @@ try:
55
55
  import sslpsk
56
56
  except ImportError:
57
57
  warnings.warn(
58
- u"Connection encryption via TLS-PSK is not available, as the module sslpsk is not installed."
58
+ "Connection encryption via TLS-PSK is not available, as the module sslpsk is not installed."
59
59
  )
60
60
 
61
61
 
@@ -92,6 +92,7 @@ class LowLevel(object):
92
92
  self.logger.debug("init")
93
93
  self.status = None
94
94
  self.address = None
95
+ self.timeout = None
95
96
  self.password = None
96
97
  self.pam_username = None
97
98
  self.pam_password = None
@@ -110,14 +111,21 @@ class LowLevel(object):
110
111
  self.requested_protocol_version = None
111
112
  self.protocol_messages = ProtocolMessages()
112
113
  # identity_prefix have to be set in each class
113
- self.identity_prefix = u"R_NONE"
114
+ self.identity_prefix = "R_NONE"
114
115
  self.receive_buffer = b""
115
116
 
116
117
  def __del__(self):
117
118
  self.close()
118
119
 
119
120
  def connect(
120
- self, address, port, dirname, connection_type, name=None, password=None
121
+ self,
122
+ address,
123
+ port,
124
+ dirname,
125
+ connection_type,
126
+ name=None,
127
+ password=None,
128
+ timeout=None,
121
129
  ):
122
130
  """Establish a network connection and authenticate.
123
131
 
@@ -137,6 +145,9 @@ class LowLevel(object):
137
145
  password (str, bareos.util.Password):
138
146
  Credential password, in cleartext or as Password object.
139
147
 
148
+ timeout (int, optional):
149
+ Connection timeout in seconds. Default OS specific.
150
+
140
151
  Returns:
141
152
  bool: True, if the authentication succeeds. In earlier versions, authentication failures returned False. However, now an authentication failure raises an exception.
142
153
 
@@ -151,12 +162,11 @@ class LowLevel(object):
151
162
  self.dirname = dirname
152
163
  else:
153
164
  self.dirname = address
165
+ self.timeout = timeout
154
166
  self.connection_type = connection_type
155
167
  self.name = name
156
168
  if password is None:
157
- raise bareos.exceptions.ConnectionError(
158
- u"Parameter 'password' is required."
159
- )
169
+ raise bareos.exceptions.ConnectionError("Parameter 'password' is required.")
160
170
  if isinstance(password, Password):
161
171
  self.password = password
162
172
  else:
@@ -171,11 +181,11 @@ class LowLevel(object):
171
181
  if self.tls_psk_require:
172
182
  if not self.is_tls_psk_available():
173
183
  raise bareos.exceptions.ConnectionError(
174
- u"TLS-PSK is required, but sslpsk module not loaded/available."
184
+ "TLS-PSK is required, but sslpsk module not loaded/available."
175
185
  )
176
186
  if not self.tls_psk_enable:
177
187
  raise bareos.exceptions.ConnectionError(
178
- u"TLS-PSK is required, but not enabled."
188
+ "TLS-PSK is required, but not enabled."
179
189
  )
180
190
 
181
191
  if self.tls_psk_enable and self.is_tls_psk_available():
@@ -187,7 +197,7 @@ class LowLevel(object):
187
197
  raise
188
198
  else:
189
199
  self.logger.warning(
190
- u"Failed to connect via TLS-PSK. Trying plain connection."
200
+ "Failed to connect via TLS-PSK. Trying plain connection."
191
201
  )
192
202
  else:
193
203
  connected = True
@@ -229,6 +239,8 @@ class LowLevel(object):
229
239
  self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
230
240
  # initialize
231
241
  try:
242
+ if self.timeout:
243
+ self.socket.settimeout(self.timeout)
232
244
  self.socket.connect((self.address, self.port))
233
245
  except (socket.error, socket.gaierror) as e:
234
246
  self._handleSocketError(e)
@@ -253,7 +265,7 @@ class LowLevel(object):
253
265
  if isinstance(self.password, Password):
254
266
  password = self.password.md5()
255
267
  else:
256
- raise bareos.exceptions.ConnectionError(u"No password provided.")
268
+ raise bareos.exceptions.ConnectionError("No password provided.")
257
269
  self.logger.debug("identity = {0}, password = {1}".format(identity, password))
258
270
  try:
259
271
  self.socket = sslpsk.wrap_socket(
@@ -275,7 +287,7 @@ class LowLevel(object):
275
287
  name = str(self.name)
276
288
  if isinstance(self.name, bytes):
277
289
  name = self.name.decode("utf-8")
278
- result = u"{0}{1}{2}".format(
290
+ result = "{0}{1}{2}".format(
279
291
  self.identity_prefix, Constants.record_separator, name
280
292
  )
281
293
  return bytes(bytearray(result, "utf-8"))
@@ -478,7 +490,7 @@ class LowLevel(object):
478
490
  self.logger.debug("expecting {0} bytes.".format(length))
479
491
  submsg = self.socket.recv(length)
480
492
  if len(submsg) == 0:
481
- errormsg = u"Failed to retrieve data. Assuming the connection is lost."
493
+ errormsg = "Failed to retrieve data. Assuming the connection is lost."
482
494
  self._handleSocketError(errormsg)
483
495
  raise bareos.exceptions.ConnectionLostError(errormsg)
484
496
  length -= len(submsg)
@@ -600,7 +612,7 @@ class LowLevel(object):
600
612
  """
601
613
  msg = self.recv_bytes(length)
602
614
  if type(msg) is str:
603
- msg = bytearray(msg.decode("utf-8", 'replace'), "utf-8")
615
+ msg = bytearray(msg.decode("utf-8", "replace"), "utf-8")
604
616
  if type(msg) is bytes:
605
617
  msg = bytearray(msg)
606
618
  self.logger.debug(str(msg))
@@ -642,7 +654,7 @@ class LowLevel(object):
642
654
 
643
655
  def _show_result(self, msg):
644
656
  # print(msg.decode('utf-8'))
645
- sys.stdout.write(msg.decode("utf-8", 'replace'))
657
+ sys.stdout.write(msg.decode("utf-8", "replace"))
646
658
  # add a linefeed, if there isn't one already
647
659
  if len(msg) >= 2:
648
660
  if msg[-2] != ord(b"\n"):
@@ -1,6 +1,6 @@
1
1
  # BAREOS - Backup Archiving REcovery Open Sourced
2
2
  #
3
- # Copyright (C) 2015-2021 Bareos GmbH & Co. KG
3
+ # Copyright (C) 2015-2023 Bareos GmbH & Co. KG
4
4
  #
5
5
  # This program is Free Software; you can redistribute it and/or
6
6
  # modify it under the terms of version three of the GNU Affero General Public
@@ -24,5 +24,6 @@ Bareos utility classes.
24
24
  from bareos.util.bareosbase64 import BareosBase64
25
25
  from bareos.util.password import Password
26
26
  from bareos.util.path import Path
27
+ from bareos.util.version import Version
27
28
 
28
- __all__ = ["BareosBase64", "Password", "Path"]
29
+ __all__ = ["BareosBase64", "Password", "Path", "Version"]
@@ -0,0 +1,35 @@
1
+ # BAREOS - Backup Archiving REcovery Open Sourced
2
+ #
3
+ # Copyright (C) 2023-2023 Bareos GmbH & Co. KG
4
+ #
5
+ # This program is Free Software; you can redistribute it and/or
6
+ # modify it under the terms of version three of the GNU Affero General Public
7
+ # License as published by the Free Software Foundation and included
8
+ # in the file LICENSE.
9
+ #
10
+ # This program is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
+ # 02110-1301, USA.
19
+
20
+ import re
21
+
22
+
23
+ class Version(object):
24
+ def __init__(self, version):
25
+ self.version = version
26
+
27
+ def __str__(self):
28
+ return self.version
29
+
30
+ def as_python_version(self):
31
+ """
32
+ Translate a Bareos version number
33
+ into a version compatible with PEP 440.
34
+ """
35
+ return re.sub(r"~pre([0-9]+\.)", r".dev+\1", self.version)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-bareos
3
- Version: 22.1.2
3
+ Version: 23.0.0
4
4
  Summary: Client library and tools for Bareos console access.
5
5
  Home-page: https://github.com/bareos/bareos/
6
6
  Author: Bareos Team
@@ -21,6 +21,7 @@ bareos/util/__init__.py
21
21
  bareos/util/bareosbase64.py
22
22
  bareos/util/password.py
23
23
  bareos/util/path.py
24
+ bareos/util/version.py
24
25
  bin/bareos-fd-connect.py
25
26
  bin/bconsole-json.py
26
27
  bin/bconsole.py
@@ -1 +0,0 @@
1
- 22.1.2
File without changes
File without changes