# 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
# 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
# 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
- 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 sys
import tarfile
import tempfile
-import _thread
+try:
+ import _thread
+except ImportError:
+ import thread as _thread
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
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:
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)
@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
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))
"""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
format.
"""
-import configparser
+from __future__ import division, print_function, unicode_literals
+
+try:
+ import configparser
+except ImportError:
+ import ConfigParser as configparser
import datetime
import re
cumulus-backup program.
"""
+from __future__ import division, print_function, unicode_literals
+
import datetime
import re
import sys
of the filesystem, in sorted order.
"""
+from __future__ import division, print_function, unicode_literals
+
import cumulus
class Metadata:
given data from a previous backup.
"""
+from __future__ import division, print_function, unicode_literals
+
import base64
import hashlib
import itertools
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))
weekly snapshots going back further in time.
"""
+from __future__ import division, print_function, unicode_literals
+
import calendar
import datetime
# 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$"),
'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
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())
# 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
# 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
"""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
#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