Manual 2to3 fixups.
authorMichael Vrable <vrable@cs.hmc.edu>
Tue, 28 Jan 2014 16:28:22 +0000 (08:28 -0800)
committerMichael Vrable <vrable@cs.hmc.edu>
Sat, 1 Feb 2014 17:18:56 +0000 (09:18 -0800)
15 files changed:
cumulus-store
cumulus-sync
cumulus-util
python/cumulus/__init__.py
python/cumulus/cmd_util.py
python/cumulus/config.py
python/cumulus/main.py
python/cumulus/metadata.py
python/cumulus/rebuild_database.py
python/cumulus/retention.py
python/cumulus/store/__init__.py
python/cumulus/store/file.py
python/cumulus/store/ftp.py
python/cumulus/store/s3.py
python/cumulus/store/sftp.py

index ac58c28..93a10d7 100755 (executable)
@@ -32,6 +32,8 @@
 # written to stdout, which is either "OK" (for success) or "ERR" (if an error
 # occurred).
 
 # written to stdout, which is either "OK" (for success) or "ERR" (if an error
 # occurred).
 
+from __future__ import division, print_function, unicode_literals
+
 import os, sys, traceback
 
 # Automatically set Python path, based on script directory.  This should be
 import os, sys, traceback
 
 # Automatically set Python path, based on script directory.  This should be
index 4953091..9f31a29 100755 (executable)
@@ -20,6 +20,8 @@
 
 # Tool for copying cumulus archives from one source to another.
 
 
 # Tool for copying cumulus archives from one source to another.
 
+from __future__ import division, print_function, unicode_literals
+
 import os, sys
 
 # Automatically set Python path, based on script directory.  This should be
 import os, sys
 
 # Automatically set Python path, based on script directory.  This should be
index 669efc7..7233f8d 100755 (executable)
@@ -20,6 +20,8 @@
 
 # Utility for managing Cumulus archives.
 
 
 # Utility for managing Cumulus archives.
 
+from __future__ import division, print_function, unicode_literals
+
 import os, sys
 
 # Automatically set Python path, based on script directory.  This should be
 import os, sys
 
 # Automatically set Python path, based on script directory.  This should be
index 8dc4c98..0e39d37 100644 (file)
@@ -26,19 +26,29 @@ various parts of a Cumulus archive:
   - reading and maintaining the local object database
 """
 
   - reading and maintaining the local object database
 """
 
+from __future__ import division, print_function, unicode_literals
 
 import hashlib
 import itertools
 import os
 import re
 import sqlite3
 
 import hashlib
 import itertools
 import os
 import re
 import sqlite3
+import sys
 import tarfile
 import tempfile
 import tarfile
 import tempfile
-import _thread
+try:
+    import _thread
+except ImportError:
+    import thread as _thread
 
 import cumulus.store
 import cumulus.store.file
 
 
 import cumulus.store
 import cumulus.store.file
 
+if sys.version < '3':
+    StringTypes = (str, unicode)
+else:
+    StringTypes = (str,)
+
 # The largest supported snapshot format that can be understood.
 FORMAT_VERSION = (0, 11)        # Cumulus Snapshot v0.11
 
 # The largest supported snapshot format that can be understood.
 FORMAT_VERSION = (0, 11)        # Cumulus Snapshot v0.11
 
@@ -264,7 +274,7 @@ class BackendWrapper(object):
 
         store may either be a Store object or URL.
         """
 
         store may either be a Store object or URL.
         """
-        if type(backend) in (str, str):
+        if type(backend) in StringTypes:
             if backend.find(":") >= 0:
                 self._backend = cumulus.store.open(backend)
             else:
             if backend.find(":") >= 0:
                 self._backend = cumulus.store.open(backend)
             else:
@@ -295,7 +305,7 @@ class BackendWrapper(object):
     def prefetch_generic(self):
         """Calls scan on directories to prefetch file metadata."""
         directories = set()
     def prefetch_generic(self):
         """Calls scan on directories to prefetch file metadata."""
         directories = set()
-        for typeinfo in list(SEARCH_PATHS.values()):
+        for typeinfo in SEARCH_PATHS.values():
             directories.update(typeinfo.directories())
         for d in directories:
             print("Prefetch", d)
             directories.update(typeinfo.directories())
         for d in directories:
             print("Prefetch", d)
@@ -566,7 +576,7 @@ class MetadataItem:
     @staticmethod
     def decode_device(s):
         """Decode a device major/minor number."""
     @staticmethod
     def decode_device(s):
         """Decode a device major/minor number."""
-        (major, minor) = list(map(MetadataItem.decode_int, s.split("/")))
+        (major, minor) = map(MetadataItem.decode_int, s.split("/"))
         return (major, minor)
 
     class Items: pass
         return (major, minor)
 
     class Items: pass
@@ -578,7 +588,7 @@ class MetadataItem:
         self.object_store = object_store
         self.keys = []
         self.items = self.Items()
         self.object_store = object_store
         self.keys = []
         self.items = self.Items()
-        for (k, v) in list(fields.items()):
+        for (k, v) in fields.items():
             if k in self.field_types:
                 decoder = self.field_types[k]
                 setattr(self.items, k, decoder(v))
             if k in self.field_types:
                 decoder = self.field_types[k]
                 setattr(self.items, k, decoder(v))
index 0827cb0..fa761b6 100644 (file)
@@ -18,6 +18,8 @@
 
 """Implementation of the Cumulus command-line utility program."""
 
 
 """Implementation of the Cumulus command-line utility program."""
 
+from __future__ import division, print_function, unicode_literals
+
 import getpass, os, stat, sys, time
 from optparse import OptionParser
 
 import getpass, os, stat, sys, time
 from optparse import OptionParser
 
index 32c20da..aeb24ae 100644 (file)
@@ -22,7 +22,12 @@ See the Cumulus documentation for a description of the configuration file
 format.
 """
 
 format.
 """
 
-import configparser
+from __future__ import division, print_function, unicode_literals
+
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 import datetime
 import re
 
 import datetime
 import re
 
index af50e26..8d4156c 100644 (file)
@@ -22,6 +22,8 @@ This implements maintenance functions and is a wrapper around the C++
 cumulus-backup program.
 """
 
 cumulus-backup program.
 """
 
+from __future__ import division, print_function, unicode_literals
+
 import datetime
 import re
 import sys
 import datetime
 import re
 import sys
index ac92ec4..af668c1 100644 (file)
@@ -23,6 +23,8 @@ underlying metadata log have been generated by a depth-first-search traversal
 of the filesystem, in sorted order.
 """
 
 of the filesystem, in sorted order.
 """
 
+from __future__ import division, print_function, unicode_literals
+
 import cumulus
 
 class Metadata:
 import cumulus
 
 class Metadata:
index a4af640..3f391d8 100755 (executable)
@@ -26,6 +26,8 @@ the local database.  This can be used to recover from a local database loss,
 given data from a previous backup.
 """
 
 given data from a previous backup.
 """
 
+from __future__ import division, print_function, unicode_literals
+
 import base64
 import hashlib
 import itertools
 import base64
 import hashlib
 import itertools
@@ -275,7 +277,7 @@ class DatabaseRebuilder(object):
 
     def insert_segment_info(self, segment, info):
         id = self.segment_to_id(segment)
 
     def insert_segment_info(self, segment, info):
         id = self.segment_to_id(segment)
-        for k, v in list(info.items()):
+        for k, v in info.items():
             self.cursor.execute("update segments set " + k + " = ? "
                                 "where segmentid = ?",
                                 (v, id))
             self.cursor.execute("update segments set " + k + " = ? "
                                 "where segmentid = ?",
                                 (v, id))
index e447b54..210b257 100644 (file)
@@ -23,6 +23,8 @@ for example keeping daily snapshots for short periods of time but retaining
 weekly snapshots going back further in time.
 """
 
 weekly snapshots going back further in time.
 """
 
+from __future__ import division, print_function, unicode_literals
+
 import calendar
 import datetime
 
 import calendar
 import datetime
 
index e368c57..e638bc5 100644 (file)
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-import exceptions, re, urllib.parse
+from __future__ import division, print_function, unicode_literals
+
+import re
+try:
+    from urllib.parse import urlparse
+except ImportError:
+    from urlparse import urlparse
 
 type_patterns = {
     'checksums': re.compile(r"^snapshot-(.*)\.(\w+)sums$"),
 
 type_patterns = {
     'checksums': re.compile(r"^snapshot-(.*)\.(\w+)sums$"),
@@ -24,7 +30,7 @@ type_patterns = {
     'snapshots': re.compile(r"^snapshot-(.*)\.(cumulus|lbs)$")
 }
 
     'snapshots': re.compile(r"^snapshot-(.*)\.(cumulus|lbs)$")
 }
 
-class NotFoundError(exceptions.KeyError):
+class NotFoundError(KeyError):
     """Exception thrown when a file is not found in a repository."""
 
     pass
     """Exception thrown when a file is not found in a repository."""
 
     pass
@@ -39,7 +45,7 @@ class Store (object):
         if cls != Store:
             return super(Store, cls).__new__(cls, url, **kw)
         (scheme, netloc, path, params, query, fragment) \
         if cls != Store:
             return super(Store, cls).__new__(cls, url, **kw)
         (scheme, netloc, path, params, query, fragment) \
-            = urllib.parse.urlparse(url)
+            = urlparse(url)
 
         try:
             cumulus = __import__('cumulus.store.%s' % scheme, globals())
 
         try:
             cumulus = __import__('cumulus.store.%s' % scheme, globals())
index 6d23a58..6aea58b 100644 (file)
@@ -16,6 +16,8 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
+from __future__ import division, print_function, unicode_literals
+
 import os, sys, tempfile
 
 import cumulus.store
 import os, sys, tempfile
 
 import cumulus.store
index ba2e4e7..3bd7104 100644 (file)
@@ -16,6 +16,8 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
+from __future__ import division, print_function, unicode_literals
+
 from ftplib        import FTP, all_errors, error_temp
 from netrc         import netrc, NetrcParseError
 from cumulus.store import Store, type_patterns, NotFoundError
 from ftplib        import FTP, all_errors, error_temp
 from netrc         import netrc, NetrcParseError
 from cumulus.store import Store, type_patterns, NotFoundError
index 4898583..ef40113 100644 (file)
@@ -18,6 +18,8 @@
 
 """Amazon S3 storage backend.  Uses a URL of the form s3://BUCKET/PATH/."""
 
 
 """Amazon S3 storage backend.  Uses a URL of the form s3://BUCKET/PATH/."""
 
+from __future__ import division, print_function, unicode_literals
+
 import os, sys, tempfile
 import boto
 from boto.exception import S3ResponseError
 import os, sys, tempfile
 import boto
 from boto.exception import S3ResponseError
index bbc4aff..6c8852c 100644 (file)
@@ -18,6 +18,7 @@
 
 #needed for python 2.5
 
 
 #needed for python 2.5
 
+from __future__ import division, print_function, unicode_literals
 
 from paramiko import Transport, SFTPClient, RSAKey, DSSKey
 from paramiko.config import SSHConfig
 
 from paramiko import Transport, SFTPClient, RSAKey, DSSKey
 from paramiko.config import SSHConfig