Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
joergsteffens committed Jan 23, 2024
1 parent ca3c3ce commit 38719c0
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 46 deletions.
Expand Up @@ -8,7 +8,7 @@
"""

from __future__ import print_function
import argparse
import bareos.util.argparse as argparse
import bareos.bsock
import bareos.exceptions
import logging
Expand Down
8 changes: 3 additions & 5 deletions contrib/misc/triggerjob/bareos-triggerjob.py
@@ -1,8 +1,7 @@
#!/usr/bin/python3
#!/usr/bin/env python

from __future__ import print_function
#import argparse
import configargparse
import bareos.util.argparse as argparse
import bareos.bsock
import logging
import sys
Expand Down Expand Up @@ -58,7 +57,7 @@ def getArguments():
"""

argparser = configargparse.ArgumentParser(
argparser = argparse.ArgumentParser(
description=u"Trigger Bareos jobs.", epilog=epilog
)
argparser.add_argument(
Expand All @@ -78,7 +77,6 @@ def getArguments():
args = getArguments()
if args.debug:
logger.setLevel(logging.DEBUG)
args.format_values()

try:
options = ["address", "port", "dirname", "name"]
Expand Down
6 changes: 1 addition & 5 deletions python-bareos/bareos/bsock/directorconsole.py
Expand Up @@ -61,13 +61,9 @@ def argparser_add_default_command_line_arguments(argparser):
>>> director = DirectorConsole(**bareos_args)
Args:
argparser (ArgParser): ArgParser instance.
argparser (ArgParser or ConfigArgParser): (Config)ArgParser instance.
"""

argparser.add_argument(
"-c", "--config", is_config_file=True, help="config file path"
)

argparser.add_argument(
"--name",
default="*UserAgent*",
Expand Down
4 changes: 2 additions & 2 deletions python-bareos/bareos/bsock/lowlevel.py
@@ -1,6 +1,6 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2015-2023 Bareos GmbH & Co. KG
# Copyright (C) 2015-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -71,7 +71,7 @@ class LowLevel(object):
def argparser_get_bareos_parameter(args):
"""Extract arguments.
This method is usally used together with the method :py:func:`argparser_add_default_command_line_arguments`.
This method is usually used together with the method :py:func:`argparser_add_default_command_line_arguments`.
Args:
args (ArgParser.Namespace): Arguments retrieved by :py:func:`ArgumentParser.parse_args`.
Expand Down
1 change: 0 additions & 1 deletion python-bareos/bareos/bsock/tlsversionparser.py
Expand Up @@ -70,7 +70,6 @@ def get_protocol_version_from_string(self, tls_version):
try:
result = getattr(ssl, self.tls_version_options[tls_version.lower()])
except (KeyError, AttributeError) as exc:
raise
pass
return result

Expand Down
5 changes: 3 additions & 2 deletions python-bareos/bareos/util/__init__.py
@@ -1,6 +1,6 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2015-2023 Bareos GmbH & Co. KG
# Copyright (C) 2015-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -21,9 +21,10 @@
Bareos utility classes.
"""

import bareos.util.argparse
from bareos.util.bareosbase64 import BareosBase64
from bareos.util.password import Password
from bareos.util.path import Path
from bareos.util.version import Version

__all__ = ["BareosBase64", "Password", "Path", "Version"]
__all__ = ["argparse", "BareosBase64", "Password", "Path", "Version"]
33 changes: 33 additions & 0 deletions python-bareos/bareos/util/argparse.py
@@ -0,0 +1,33 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2024-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

have_configargparse = False
try:
import configargparse as argparse
have_configargparse = True
except ImportError:
import argparse

class ArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
super(ArgumentParser, self).__init__(*args, **kwargs)
if have_configargparse:
self.add_argument(
"-c", "--config", is_config_file=True, help="Config file path."
)
8 changes: 4 additions & 4 deletions python-bareos/bin/bareos-fd-connect.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
#
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2020 Bareos GmbH & Co. KG
# Copyright (C) 2019-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -18,8 +19,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.


import argparse
import bareos.util.argparse as argparse
import bareos.bsock
from bareos.bsock.filedaemon import FileDaemon
import logging
Expand Down Expand Up @@ -53,7 +53,7 @@ def getArguments():
logger.debug("options: %s" % (bareos_args))
try:
bsock = FileDaemon(**bareos_args)
except (bareos.exceptions.Error) as e:
except bareos.exceptions.Error as e:
print(str(e))
sys.exit(1)
logger.debug("authentication successful")
Expand Down
7 changes: 4 additions & 3 deletions python-bareos/bin/bareos-jsonrpc-server.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
#
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2020 Bareos GmbH & Co. KG
# Copyright (C) 2019-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -20,7 +21,7 @@


from __future__ import print_function
import argparse
import bareos.util.argparse as argparse
import bareos.bsock
import bareos.exceptions
import inspect
Expand Down Expand Up @@ -116,7 +117,7 @@ def getArguments():
logger.debug("options: %s" % (bareos_args))
try:
director = bareos.bsock.DirectorConsoleJson(**bareos_args)
except (bareos.exceptions.ConnectionError) as e:
except bareos.exceptions.ConnectionError as e:
print(str(e))
sys.exit(1)
logger.debug("authentication successful")
Expand Down
7 changes: 4 additions & 3 deletions python-bareos/bin/bconsole-json.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
#
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2020 Bareos GmbH & Co. KG
# Copyright (C) 2019-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -20,7 +21,7 @@


from __future__ import print_function
import argparse
import bareos.util.argparse as argparse
import bareos.bsock
import bareos.exceptions
import logging
Expand Down Expand Up @@ -53,7 +54,7 @@ def getArguments():
logger.debug("options: %s" % (bareos_args))
try:
director = bareos.bsock.DirectorConsoleJson(**bareos_args)
except (bareos.exceptions.Error) as e:
except bareos.exceptions.Error as e:
print(str(e))
sys.exit(1)

Expand Down
6 changes: 3 additions & 3 deletions python-bareos/bin/bconsole.py
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python
#
# BAREOS - Backup Archiving REcovery Open Sourced
#
Expand All @@ -19,15 +19,15 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

import configargparse
import bareos.util.argparse as argparse
import bareos.bsock
import bareos.exceptions
import logging
import sys


def getArguments():
argparser = configargparse.ArgumentParser(description="Console to Bareos Director.")
argparser = argparse.ArgumentParser(description="Console to Bareos Director.")
argparser.add_argument(
"-d", "--debug", action="store_true", help="enable debugging output"
)
Expand Down
3 changes: 2 additions & 1 deletion python-bareos/debian/control
Expand Up @@ -11,13 +11,14 @@ Standards-Version: 3.9.1
Package: python-bareos
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}
Recommends: python-configargparse
Description: Backup Archiving REcovery Open Sourced - python module (Python 2)
This packages contains a python module to interact with a Bareos backup system.
It also includes some tools based on this module.

Package: python3-bareos
Architecture: all
Depends: ${misc:Depends}, ${python3:Depends}
Depends: ${misc:Depends}, ${python3:Depends}, python3-configargparse
Description: Backup Archiving REcovery Open Sourced - python module (Python 3)
This packages contains a python module to interact with a Bareos backup system.
It also includes some tools based on this module.
14 changes: 4 additions & 10 deletions python-bareos/packaging/python-bareos.spec
Expand Up @@ -8,16 +8,6 @@
# https://pagure.io/packaging-committee/blob/ae14fdb50cc6665a94bc32f7d984906ce1eece45/f/guidelines/modules/ROOT/pages/Python_Appendix.adoc
#

#
# For current distribution, create
# python2-bareos and python3-bareos packages.
#
# CentOS 6 supports only Python2.
#
# CentOS <= 7 and SLES <= 12,
# the Python2 package is namend python-bareos (instead of python2-bareos).
#

%global srcname bareos

%define python3_build_requires python-rpm-macros python3-devel python3-setuptools
Expand Down Expand Up @@ -48,6 +38,10 @@ It also includes some tools based on this module.}
Summary: %{summary}
BuildRequires: %{python3_build_requires}
%{?python_provide:%python_provide python3-%{srcname}}
%if 0%{?fedora} || 0%{?rhel} >= 8 || 0%{?suse_version} || 0%{?sle_version}
# Recommends is not supported on RHEL <= 7.
Recommends: python3-configargparse
%endif

%description -n python3-%{srcname} %_description

Expand Down
9 changes: 3 additions & 6 deletions python-bareos/setup.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2023 Bareos GmbH & Co. KG
# Copyright (C) 2019-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -61,11 +61,8 @@ def get_version():
description="Client library and tools for Bareos console access.",
long_description=open("README.rst").read(),
long_description_content_type="text/x-rst",
# Python 2.6 is used by RHEL/Centos 6.
# When RHEL/Centos 6 is no longer supported (End of 2020),
# Python 2.6 will no longer be supported by python-bareos.
python_requires=">=2.6",
extras_require={"TLS-PSK": ["sslpsk"]},
python_requires=">=2.7",
extras_require={"TLS-PSK": ["sslpsk"], "configfile": ["configargparse"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU Affero General Public License v3",
Expand Down

0 comments on commit 38719c0

Please sign in to comment.