Skip to content

Commit

Permalink
apply changes from bareos-check-sources
Browse files Browse the repository at this point in the history
  • Loading branch information
arogge authored and BareosBot committed Aug 24, 2023
1 parent 3a96786 commit d5eb26b
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 61 deletions.
33 changes: 11 additions & 22 deletions core/src/plugins/dird/python/python-dir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,8 @@ static bRC handlePluginEvent(PluginContext* plugin_ctx,

Bareosdir_set_plugin_context(plugin_ctx);

/*
* First handle some events internally before calling python if it
* want to do some special handling on the event triggered.
*/
/* First handle some events internally before calling python if it
* want to do some special handling on the event triggered. */
switch (event->eventType) {
case bDirEventNewPluginOptions:
event_dispatched = true;
Expand All @@ -314,19 +312,15 @@ static bRC handlePluginEvent(PluginContext* plugin_ctx,
break;
}

/*
* See if we have been triggered in the previous switch if not we have to
/* See if we have been triggered in the previous switch if not we have to
* always dispatch the event. If we already processed the event internally
* we only do a dispatch to the python entry point when that internal
* processing was successful (e.g. retval == bRC_OK).
*/
* processing was successful (e.g. retval == bRC_OK). */
if (!event_dispatched || retval == bRC_OK) {
PyEval_AcquireThread(plugin_priv_ctx->interpreter);

/*
* Now dispatch the event to Python.
* First the calls that need special handling.
*/
/* Now dispatch the event to Python.
* First the calls that need special handling. */
switch (event->eventType) {
case bDirEventNewPluginOptions:
// See if we already loaded the Python modules.
Expand All @@ -341,11 +335,9 @@ static bRC handlePluginEvent(PluginContext* plugin_ctx,
}
break;
default:
/*
* Handle the generic events e.g. the ones which are just passed on.
/* Handle the generic events e.g. the ones which are just passed on.
* We only try to call Python when we loaded the right module until
* that time we pretend the call succeeded.
*/
* that time we pretend the call succeeded. */
if (plugin_priv_ctx->python_loaded) {
retval = Bareosdir_PyHandlePluginEvent(plugin_ctx, event, value);
} else {
Expand Down Expand Up @@ -382,10 +374,8 @@ static bRC parse_plugin_definition(PluginContext* plugin_ctx,

if (!value) { return bRC_Error; }

/*
* Parse the plugin definition.
* Make a private copy of the whole string.
*/
/* Parse the plugin definition.
* Make a private copy of the whole string. */
PmStrcpy(plugin_definition, (char*)value);

bp = strchr(plugin_definition.c_str(), ':');
Expand All @@ -404,8 +394,7 @@ static bRC parse_plugin_definition(PluginContext* plugin_ctx,
while (bp) {
if (strlen(bp) == 0) { break; }

/*
* Each argument is in the form:
/* Each argument is in the form:
* <argument> = <argument_value>
*
* So we setup the right pointers here, argument to the beginning
Expand Down
39 changes: 13 additions & 26 deletions core/src/plugins/stored/python/python-sd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ static bRC newPlugin(PluginContext* plugin_ctx)
plugin_priv_ctx->interpreter = Py_NewInterpreter();
PyEval_ReleaseThread(plugin_priv_ctx->interpreter);

/*
* Always register some events the python plugin itself can register
* any other events it is interested in.
*/
/* Always register some events the python plugin itself can register
* any other events it is interested in. */
bareos_core_functions->registerBareosEvents(plugin_ctx, 1,
bSdEventNewPluginOptions);

Expand Down Expand Up @@ -303,10 +301,8 @@ static bRC handlePluginEvent(PluginContext* plugin_ctx,

if (!plugin_priv_ctx) { goto bail_out; }

/*
* First handle some events internally before calling python if it
* want to do some special handling on the event triggered.
*/
/* First handle some events internally before calling python if it
* want to do some special handling on the event triggered. */
switch (event->eventType) {
case bSdEventNewPluginOptions:
event_dispatched = true;
Expand All @@ -316,19 +312,15 @@ static bRC handlePluginEvent(PluginContext* plugin_ctx,
break;
}

/*
* See if we have been triggered in the previous switch if not we have to
/* See if we have been triggered in the previous switch if not we have to
* always dispatch the event. If we already processed the event internally
* we only do a dispatch to the python entry point when that internal
* processing was successful (e.g. retval == bRC_OK).
*/
* processing was successful (e.g. retval == bRC_OK). */
if (!event_dispatched || retval == bRC_OK) {
PyEval_AcquireThread(plugin_priv_ctx->interpreter);

/*
* Now dispatch the event to Python.
* First the calls that need special handling.
*/
/* Now dispatch the event to Python.
* First the calls that need special handling. */
switch (event->eventType) {
case bSdEventNewPluginOptions:
// See if we already loaded the Python modules.
Expand All @@ -343,11 +335,9 @@ static bRC handlePluginEvent(PluginContext* plugin_ctx,
}
break;
default:
/*
* Handle the generic events e.g. the ones which are just passed on.
/* Handle the generic events e.g. the ones which are just passed on.
* We only try to call Python when we loaded the right module until
* that time we pretend the call succeeded.
*/
* that time we pretend the call succeeded. */
if (plugin_priv_ctx->python_loaded) {
retval = Bareossd_PyHandlePluginEvent(plugin_ctx, event, value);
} else {
Expand Down Expand Up @@ -383,10 +373,8 @@ static bRC parse_plugin_definition(PluginContext* plugin_ctx,

if (!value) { return bRC_Error; }

/*
* Parse the plugin definition.
* Make a private copy of the whole string.
*/
/* Parse the plugin definition.
* Make a private copy of the whole string. */
PmStrcpy(plugin_definition, (char*)value);

bp = strchr(plugin_definition.c_str(), ':');
Expand All @@ -405,8 +393,7 @@ static bRC parse_plugin_definition(PluginContext* plugin_ctx,
while (bp) {
if (strlen(bp) == 0) { break; }

/*
* Each argument is in the form:
/* Each argument is in the form:
* <argument> = <argument_value>
*
* So we setup the right pointers here, argument to the beginning
Expand Down
15 changes: 11 additions & 4 deletions systemtests/tests/py3plug-dir/python-modules/BareosDirTest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2021 Bareos GmbH & Co. KG
# Copyright (C) 2019-2023 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 @@ -56,7 +56,15 @@ def handle_plugin_event(self, event):
job_name = repr(bareosdir.GetValue(bareosdir.bDirVarJobName))
job_id = repr(bareosdir.GetValue(bareosdir.bDirVarJobId))
microtime = round(time() * 1000)
msg_f = "%s Job:" + job_name + " JobId: " + job_id + " Time: " + repr(microtime) + "\n"
msg_f = (
"%s Job:"
+ job_name
+ " JobId: "
+ job_id
+ " Time: "
+ repr(microtime)
+ "\n"
)

if event == bareosdir.bDirEventJobStart:
self.toFile(msg_f % "bDirEventJobStart")
Expand All @@ -75,8 +83,7 @@ def handle_plugin_event(self, event):
def toFile(self, text):
bareosdir.DebugMessage(
100,
"Writing string '%s' to '%s'\n"
% (text, self.outputfile),
"Writing string '%s' to '%s'\n" % (text, self.outputfile),
)
doc = open(self.outputfile, "a")
doc.write(text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2021 Bareos GmbH & Co. KG
# Copyright (C) 2019-2023 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2021-2022 Bareos GmbH & Co. KG
# Copyright (C) 2021-2023 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2022-2022 Bareos GmbH & Co. KG
# Copyright (C) 2022-2023 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2022-2022 Bareos GmbH & Co. KG
# Copyright (C) 2022-2023 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2014-2020 Bareos GmbH & Co. KG
# Copyright (C) 2014-2023 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2014-2020 Bareos GmbH & Co. KG
# Copyright (C) 2014-2023 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
2 changes: 1 addition & 1 deletion systemtests/tests/py3plug-fd-vmware/reset_cbt.sh.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2020-2020 Bareos GmbH & Co. KG
# Copyright (C) 2020-2023 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2021 Bareos GmbH & Co. KG
# Copyright (C) 2019-2023 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2021 Bareos GmbH & Co. KG
# Copyright (C) 2019-2023 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

0 comments on commit d5eb26b

Please sign in to comment.