cea-hpc / shine

Lustre administration tool
GNU General Public License v2.0
22 stars 9 forks source link

DeprecationWarning: the sets module is deprecated #81

Closed degremont closed 7 years ago

degremont commented 14 years ago

It makes dirty output ;-) DeprecationWarning: the sets module is deprecated

--- /usr/lib/python2.6/site-packages/Shine/Lustre/FileSystem.py.old     2010-09-21 17:16:18.806278532 +0200
+++ /usr/lib/python2.6/site-packages/Shine/Lustre/FileSystem.py 2010-09-21 17:18:31.276227236 +0200
@@ -24,8 +24,11 @@

 Represents a Lustre FS.
 """
+try :
+    set
+except NameError :
+    from sets import Set as set

-from sets import Set
 import socket
 import os
 import sys
@@ -430,7 +433,7 @@

         # Remember format launched, so we can check their status once
         # all operations are done.
-        format_launched = Set()
+        format_launched = set()

         # Get additional options for the FSProxyAction call
         addopts = kwargs.get('addopts', None)
@@ -461,7 +464,7 @@
     def fsck(self, **kwargs):
         # Remember fsck launched, so we can check their status once
         # all operations are done.
-        fsck_launched = Set()
+        fsck_launched = set()

         # Get additional options for the FSProxyAction call
         addopts = kwargs.get('addopts', None)
@@ -494,7 +497,7 @@
         Get status of filesystem.
         """

-        launched = Set()
+        launched = set()

         # Filter components depending on flags
         # XXX: Ugly test, implement something cleaner.
@@ -714,7 +717,7 @@
         for server, iter_comp in self.managed_components(group_attr="server", supports='label'):
             e_comps = list(iter_comp)
             if server.is_local():
-                types = Set()
+                types = set()
                 for t in e_comps:
                     types.add(type_map[t.TYPE])

--- /usr/lib/python2.6/site-packages/Shine/Configuration/Model.py.old   2010-09-21 17:13:04.216281592 +0200
+++ /usr/lib/python2.6/site-packages/Shine/Configuration/Model.py       2010-09-21 17:15:21.756279425 +0200
@@ -20,7 +20,10 @@

 from ModelFile import ModelFile, SubElement

-from sets import Set
+try :
+    set
+except NameError :
+    from sets import Set as set

 import re

@@ -168,7 +171,7 @@
         """
         Sort nodes and nids keys for a better understanding.
         """
-        keys = Set(self.keys.keys())
+        keys = set(self.keys.keys())
         elems = []
         for k in ('nodes','nids'):
             elems.append("%s%s%s" % (k, self.sep, self.get_one(k)))

Reported by: ohargoaa

degremont commented 14 years ago
        owner
          changed from st-cea to ad-cea

        status
            changed from new to accepted

        milestone
            set to 0.909

Thanks for the patches.

As Shine depends on ClusterShell and all recent ClusterShell releases require Python 2.4+, maybe we can simply drop the usage of sets module.

If not, do not forget to also clear the hack from 'shine' script:

import warnings warnings.simplefilter('ignore', DeprecationWarning)

Original comment by: degremont

degremont commented 14 years ago
        status
            changed from accepted to closed

        resolution
            set to fixed

This is fixed in SVN commit r292.

Warning filter in shine script was not removed because there is still other outstanding DeprecationWarnings? to be fixed.

Original comment by: degremont