#632 introduced NameError: name 'cdist_object' is not defined #120

Closed
opened 2021-11-20 13:24:14 +00:00 by ungleich-gitea · 2 comments

Created by: asteven

The changes introduced in #632 introduced a bug.
Looking at the code/change it's obvious.

[14:52:08] crius:cdist% git show cf36aece cdist/core/explorer.py | cat 
commit cf36aece7df7661ac96a30928c6b4e3c5cdf9853
Author: Darko Poljak <darko.poljak@gmail.com>
Date:   Sun Feb 25 23:48:53 2018 +0100

    [BETA] bug: error info lost with parallel (option -j) #632

diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py
index c4708eac..072ca692 100644
--- a/cdist/core/explorer.py
+++ b/cdist/core/explorer.py
@@ -24,6 +24,7 @@ import logging
 import os
 import glob
 import multiprocessing
+import cdist
 from cdist.mputil import mp_pool_run
 from . import util
 
@@ -213,19 +214,22 @@ class Explorer(object):
     def transfer_type_explorers(self, cdist_type):
         """Transfer the type explorers for the given type to the
            remote side."""
-        if cdist_type.explorers:
-            if cdist_type.name in self._type_explorers_transferred:
-                self.log.trace("Skipping retransfer of type explorers for: %s",
-                               cdist_type)
-            else:
-                source = os.path.join(self.local.type_path,
-                                      cdist_type.explorer_path)
-                destination = os.path.join(self.remote.type_path,
-                                           cdist_type.explorer_path)
-                self.remote.mkdir(destination)
-                self.remote.transfer(source, destination)
-                self.remote.run(["chmod", "0700", "%s/*" % (destination)])
-                self._type_explorers_transferred.append(cdist_type.name)
+        try:
+            if cdist_type.explorers:
+                if cdist_type.name in self._type_explorers_transferred:
+                    self.log.trace(("Skipping retransfer of type explorers "
+                                    "for: %s"), cdist_type)
+                else:
+                    source = os.path.join(self.local.type_path,
+                                          cdist_type.explorer_path)
+                    destination = os.path.join(self.remote.type_path,
+                                               cdist_type.explorer_path)
+                    self.remote.mkdir(destination)
+                    self.remote.transfer(source, destination)
+                    self.remote.run(["chmod", "0700", "%s/*" % (destination)])
+                    self._type_explorers_transferred.append(cdist_type.name)
+        except cdist.Error as e:
+            raise cdist.CdistObjectError(cdist_object, e)
 
     def transfer_object_parameters(self, cdist_object):
         """Transfer the parameters for the given object to the remote side."""
[14:52:10] crius:cdist% 

cdist_object is not defined in the transfer_type_explorers method.

*Created by: asteven* The changes introduced in #632 introduced a bug. Looking at the code/change it's obvious. ``` [14:52:08] crius:cdist% git show cf36aece cdist/core/explorer.py | cat commit cf36aece7df7661ac96a30928c6b4e3c5cdf9853 Author: Darko Poljak <darko.poljak@gmail.com> Date: Sun Feb 25 23:48:53 2018 +0100 [BETA] bug: error info lost with parallel (option -j) #632 diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index c4708eac..072ca692 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -24,6 +24,7 @@ import logging import os import glob import multiprocessing +import cdist from cdist.mputil import mp_pool_run from . import util @@ -213,19 +214,22 @@ class Explorer(object): def transfer_type_explorers(self, cdist_type): """Transfer the type explorers for the given type to the remote side.""" - if cdist_type.explorers: - if cdist_type.name in self._type_explorers_transferred: - self.log.trace("Skipping retransfer of type explorers for: %s", - cdist_type) - else: - source = os.path.join(self.local.type_path, - cdist_type.explorer_path) - destination = os.path.join(self.remote.type_path, - cdist_type.explorer_path) - self.remote.mkdir(destination) - self.remote.transfer(source, destination) - self.remote.run(["chmod", "0700", "%s/*" % (destination)]) - self._type_explorers_transferred.append(cdist_type.name) + try: + if cdist_type.explorers: + if cdist_type.name in self._type_explorers_transferred: + self.log.trace(("Skipping retransfer of type explorers " + "for: %s"), cdist_type) + else: + source = os.path.join(self.local.type_path, + cdist_type.explorer_path) + destination = os.path.join(self.remote.type_path, + cdist_type.explorer_path) + self.remote.mkdir(destination) + self.remote.transfer(source, destination) + self.remote.run(["chmod", "0700", "%s/*" % (destination)]) + self._type_explorers_transferred.append(cdist_type.name) + except cdist.Error as e: + raise cdist.CdistObjectError(cdist_object, e) def transfer_object_parameters(self, cdist_object): """Transfer the parameters for the given object to the remote side.""" [14:52:10] crius:cdist% ``` cdist_object is not defined in the transfer_type_explorers method.
Author
Owner

Created by: asteven

Yes, agree. If we would want to explicitly handle any errors it should be done at a higher level.
But in this case I would just remove try/except as it wasn't there before either.

*Created by: asteven* Yes, agree. If we would want to explicitly handle any errors it should be done at a higher level. But in this case I would just remove try/except as it wasn't there before either.
Author
Owner

Created by: darko-poljak

@asteven Aaaahhh!
I would just remove try and except parts, do you agree?

*Created by: darko-poljak* @asteven Aaaahhh! I would just remove try and except parts, do you agree?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ungleich-public/cdist#120
No description provided.