Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup whitespace

  • Loading branch information...
commit 767facb8474635d33f51a87635479a61991afc5a 1 parent 2e90e6f
@lirazsiri lirazsiri authored
View
14 backup.py
@@ -49,7 +49,7 @@ def _write_new_packages(dest, base_packages):
fh.close()
@staticmethod
- def _write_whatchanged(dest, dest_olist, dirindex, dirindex_conf,
+ def _write_whatchanged(dest, dest_olist, dirindex, dirindex_conf,
overrides=[]):
paths = read_paths(file(dirindex_conf))
paths += overrides
@@ -72,7 +72,7 @@ def _create_extras(cls, extras, profile, conf):
if not conf.backup_skip_files:
cls._write_whatchanged(extras.fsdelta, extras.fsdelta_olist,
- profile.dirindex, profile.dirindex_conf,
+ profile.dirindex, profile.dirindex_conf,
conf.overrides.fs)
if not conf.backup_skip_packages:
@@ -80,7 +80,7 @@ def _create_extras(cls, extras, profile, conf):
if not conf.backup_skip_database:
try:
- mysql.backup(extras.myfs, extras.etc.mysql,
+ mysql.backup(extras.myfs, extras.etc.mysql,
limits=conf.overrides.db)
except mysql.Error:
pass
@@ -111,13 +111,13 @@ def __init__(self, conf, force_cleanup=False):
if conf.verbose:
# files in /TKLBAM + /TKLBAM/fsdelta-olist
- fpaths= _fpaths(extras_paths.path)
+ fpaths= _fpaths(extras_paths.path)
if not conf.backup_skip_files:
fsdelta_olist = file(extras_paths.fsdelta_olist).read().splitlines()
fpaths += _filter_deleted(fsdelta_olist)
- size = sum([ os.lstat(fpath).st_size
+ size = sum([ os.lstat(fpath).st_size
for fpath in fpaths ])
if size > 1024 * 1024 * 1024:
@@ -159,7 +159,7 @@ def run(self, debug=False):
opts += [('exclude', '**')]
- args = [ '--s3-unencrypted-connection', '--allow-source-mismatch' ]
+ args = [ '--s3-unencrypted-connection', '--allow-source-mismatch' ]
if conf.simulate and conf.verbose:
args += [ '--dry-run' ]
@@ -176,7 +176,7 @@ def run(self, debug=False):
backup_command = duplicity.Command(opts, *args)
if conf.verbose:
- print "\n# PASSPHRASE=$(cat %s) %s" % (conf.secretfile,
+ print "\n# PASSPHRASE=$(cat %s) %s" % (conf.secretfile,
backup_command)
View
18 changes.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import os
from os.path import *
@@ -100,7 +100,7 @@ def __str__(self):
@classmethod
def parse(cls, line):
- op2class = dict((val.OP, val) for val in cls.__dict__.values()
+ op2class = dict((val.OP, val) for val in cls.__dict__.values()
if isinstance(val, types.ClassType))
op = line[0]
if op not in op2class:
@@ -119,7 +119,7 @@ class Changes(list):
"""
A list of Change instances, which we can load from a file and write
back to a file.
-
+
The smarts is in statfixes() and deleted() methods which compare the
list of changes to the current filesystem and yield Action() instances.
@@ -186,7 +186,7 @@ def deleted(self):
continue
yield self.Action(os.remove, change.path)
-
+
def emptydirs(self):
for change in self:
if not lexists(change.path) and change.OP == 's':
@@ -208,7 +208,7 @@ def __getitem__(self, key):
if change.OP == 'd':
continue
-
+
# optimization: if not remapped we can skip 'o' changes
if change.OP == 'o' and \
change.uid not in uidmap and change.gid not in gidmap:
@@ -218,7 +218,7 @@ def __getitem__(self, key):
if change.OP in ('s', 'o'):
if st.st_uid != uidmap[change.uid] or \
st.st_gid != gidmap[change.gid]:
- yield self.Action(os.lchown, change.path,
+ yield self.Action(os.lchown, change.path,
uidmap[change.uid], gidmap[change.gid])
if change.OP == 's':
View
8 cliwrapper.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import os
import re
import sys
View
16 cmd_backup.py
@@ -152,7 +152,7 @@ def main():
'debug',
'resume',
'logfile=',
- 'simulate', 'quiet',
+ 'simulate', 'quiet',
'profile=', 'secretfile=', 'address=',
'volsize=', 's3-parallel-uploads=', 'full-backup='])
except getopt.GetoptError, e:
@@ -236,12 +236,12 @@ def main():
try:
registry.credentials = hb.get_credentials()
except hb.Error, e:
- # asking for get_credentials() might fail if the hub is down.
+ # asking for get_credentials() might fail if the hub is down.
# But If we already have the credentials we can survive that.
-
+
if isinstance(e, hub.NotSubscribedError):
fatal(e)
-
+
if not registry.credentials:
pass
@@ -253,7 +253,7 @@ def main():
try:
registry.hbr = hb.get_backup_record(registry.hbr.backup_id)
except hb.Error, e:
- # if the Hub is down we can hope that the cached address
+ # if the Hub is down we can hope that the cached address
# is still valid and warn and try to backup anyway.
#
# But if we reach the Hub and it tells us the backup is invalid
@@ -266,8 +266,8 @@ def main():
warn(e)
if not registry.hbr:
- registry.hbr = hb.new_backup_record(registry.key,
- get_turnkey_version(),
+ registry.hbr = hb.new_backup_record(registry.key,
+ get_turnkey_version(),
get_server_id())
conf.address = registry.hbr.address
@@ -284,7 +284,7 @@ def main():
conf = registry.backup_resume_conf
- # implicit resume if we have a leftover session and
+ # implicit resume if we have a leftover session and
# the backup configuration is the same
if registry.backup_resume_conf == conf:
opt_resume = True
View
12 cmd_escrow.py
@@ -1,14 +1,14 @@
#!/usr/bin/python
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""Create a backup escrow key (Save this somewhere safe)
Arguments:
@@ -17,7 +17,7 @@
Options:
- -P --no-passphrase Don't encrypt escrow key with a passphrase
+ -P --no-passphrase Don't encrypt escrow key with a passphrase
-R --random-passphrase Choose a secure random passphrase (and print it)
"""
@@ -92,6 +92,6 @@ def _passphrase():
os.chmod(keyfile, 0600)
print >> fh, key
-
+
if __name__ == "__main__":
main()
View
8 cmd_init.py
@@ -1,14 +1,14 @@
#!/usr/bin/python
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""
Initialization (start here)
View
8 cmd_internal.py
@@ -1,14 +1,14 @@
#!/usr/bin/python
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""
Execute an internal command
"""
View
12 cmd_list.py
@@ -1,21 +1,21 @@
#!/usr/bin/python
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""
List backup records
By default uses a built-in format, unless a user-specified format is specified.
Format variables:
-
+
%id Backup id
%label Descriptive label
%turnkey_version Appliance version code
@@ -118,7 +118,7 @@ def main():
(hbr.backup_id, fmt_skpp(hbr.key),
hbr.created.strftime("%Y-%m-%d"),
- hbr.updated.strftime("%Y-%m-%d")
+ hbr.updated.strftime("%Y-%m-%d")
if hbr.updated else "-",
fmt_size(hbr.size),
View
12 cmd_passphrase.py
@@ -1,14 +1,14 @@
#!/usr/bin/python
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""Change passphrase of backup encryption key
Options:
@@ -58,8 +58,8 @@ def main():
key = keypacket.fmt(registry.secret, passphrase)
hbr = registry.hbr
-
- # after we setup a backup record
+
+ # after we setup a backup record
# only save key to registry if update_key works
if hbr:
try:
View
19 cmd_restore.py
@@ -1,14 +1,14 @@
#!/usr/bin/python
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""
Restore a backup
@@ -18,9 +18,9 @@
Options:
--time=TIME Time to restore from
-
+
TIME := YYYY-MM-DD | YYYY-MM-DDThh:mm:ss | <int>[mhDWMY]
-
+
2010-08-06 - 2010, August 6th, 00:00
2010-08-07T14:00 - 2010, August 7th 14:00 UTC
@@ -57,7 +57,7 @@
--force Disable sanity checking
--debug Run $$SHELL after Duplicity
-
+
Configurable options:
--restore-cache-size=SIZE The maximum size of the download cache
@@ -231,8 +231,8 @@ def main():
opt_debug = False
try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], 'h',
- ['limits=', 'address=', 'keyfile=',
+ opts, args = getopt.gnu_getopt(sys.argv[1:], 'h',
+ ['limits=', 'address=', 'keyfile=',
'logfile=',
'restore-cache-size=', 'restore-cache-dir=',
'force',
@@ -242,7 +242,6 @@ def main():
'debug',
'skip-files', 'skip-database', 'skip-packages',
'no-rollback'])
-
except getopt.GetoptError, e:
usage(e)
View
13 cmd_restore_rollback.py
@@ -1,14 +1,14 @@
#!/usr/bin/python
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""
Rollback last restore
@@ -36,9 +36,8 @@ def usage(e=None):
def main():
try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], 'h',
+ opts, args = getopt.gnu_getopt(sys.argv[1:], 'h',
['force', 'help'])
-
except getopt.GetoptError, e:
usage(e)
@@ -70,7 +69,7 @@ def main():
if answer.lower() != "yes":
print "You didn't answer 'yes'. Aborting!"
sys.exit(1)
-
+
rollback.rollback()
if __name__=="__main__":
View
18 cmd_status.py
@@ -1,14 +1,14 @@
#!/usr/bin/python
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""
Print a helpful status message
@@ -57,7 +57,7 @@ def usage(e=None):
def main():
try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], "h",
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "h",
[ "short", "help" ])
except getopt.GetoptError, e:
usage(e)
@@ -75,20 +75,20 @@ def main():
if status == Status.NO_APIKEY:
print "TKLBAM (Backup and Migration): NOT INITIALIZED"
if not opt_short:
- print
+ print
print ' To initialize TKLBAM, run the "tklbam-init" command to link this'
print ' system to your TurnKey Hub account. For details see the man page or'
print ' go to:'
- print
+ print
print ' http://www.turnkeylinux.org/tklbam'
elif status == Status.NO_BACKUP:
print "TKLBAM (Backup and Migration): NO BACKUPS"
if not opt_short:
- print
+ print
print ' To backup for the first time run the "tklbam-backup" command. For'
print ' details see the man page or go to:'
- print
+ print
print ' http://www.turnkeylinux.org/tklbam'
elif status == Status.OK:
View
28 dirindex.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import re
import os
import stat
@@ -20,7 +20,7 @@ class Error(Exception):
class DirIndex(dict):
class Record:
- def __init__(self, path, mod, uid, gid, size, mtime,
+ def __init__(self, path, mod, uid, gid, size, mtime,
symlink=None):
self.path = path
self.mod = mod
@@ -37,10 +37,10 @@ def frompath(cls, path):
symlink = os.readlink(path) \
if stat.S_ISLNK(st.st_mode) else None
- rec = cls(path,
- st.st_mode,
- st.st_uid, st.st_gid,
- st.st_size, st.st_mtime,
+ rec = cls(path,
+ st.st_mode,
+ st.st_uid, st.st_gid,
+ st.st_size, st.st_mtime,
symlink)
return rec
@@ -58,7 +58,7 @@ def fromline(cls, line):
return cls(path, *vals)
def fmt(self):
- vals = [ self.path ]
+ vals = [ self.path ]
for val in ( self.mod, self.uid, self.gid, self.size, self.mtime ):
vals.append("%x" % val)
@@ -77,7 +77,7 @@ def create(cls, path_index, paths):
di = cls()
di.walk(*paths)
di.save(path_index)
-
+
return di
def __init__(self, fromfile=None):
@@ -101,7 +101,7 @@ def _walk(dir):
path = join(dir, dentry)
if path in pathmap.excludes:
continue
-
+
dentries.append(dentry)
if not islink(path) and isdir(path):
@@ -177,14 +177,14 @@ def symlink_equal(a, b):
if not attrs_equal(('mod', 'uid', 'gid'), self[path], other[path]):
paths_stat.append(path)
-
+
return files_new, files_edited, paths_stat
create = DirIndex.create
def read_paths(fh):
paths = []
-
+
for line in fh.readlines():
path = re.sub(r'#.*', '', line).strip()
if not path:
View
14 dummyhub.py
@@ -20,7 +20,7 @@ class APIKey:
def __init__(self, apikey):
apikey = str(apikey)
self.encoded = apikey
-
+
padded = "A" * (20 - len(apikey)) + apikey
try:
uid, secret = struct.unpack("!L8s", base64.b32decode(padded + "=" * 4))
@@ -73,8 +73,8 @@ def subscribe(self):
producttoken = "{ProductToken}" + base64.b64encode("\x00" + os.urandom(2) + "AppTkn" + os.urandom(224))
usertoken = "{UserToken}" + base64.b64encode("\x00" + os.urandom(2) + "UserTkn" + os.urandom(288))
- self.credentials = Credentials({'accesskey': accesskey,
- 'secretkey': secretkey,
+ self.credentials = Credentials({'accesskey': accesskey,
+ 'secretkey': secretkey,
'producttoken': producttoken,
'usertoken': usertoken})
@@ -165,7 +165,7 @@ def __init__(self, backup_id, address, key, turnkey_version, server_id):
def update(self):
self.updated = datetime.now()
- path = self.address[len("file://"):]
+ path = self.address[len("file://"):]
self.sessions = _parse_duplicity_sessions(path)
self.size = sum([ session.size for session in self.sessions ])
@@ -230,7 +230,7 @@ def get_profile(self, turnkey_version):
class Backups:
# For simplicity's sake this implements a dummy version of both
# client-side and server-side operations.
- #
+ #
# When translating to a real implementation the interface should remain
# but the implementation will change completely as only client-side
# operations remain.
@@ -302,7 +302,7 @@ def new_backup_record(self, key, turnkey_version, server_id=None):
os.makedirs(path)
address = "file://" + path
- backup_record = self.user.new_backup(address, key,
+ backup_record = self.user.new_backup(address, key,
turnkey_version, server_id)
dummydb.save()
@@ -317,7 +317,7 @@ def get_backup_record(self, backup_id):
def list_backups(self):
backups = self.user.backups.values()
- return sorted(self.user.backups.values(),
+ return sorted(self.user.backups.values(),
lambda a,b: cmp(int(a.backup_id), int(b.backup_id)))
def updated_backup(self, address):
View
10 duplicity.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import os
from os.path import *
@@ -76,6 +76,6 @@ def run(self, passphrase, creds=None, debug=False):
exitcode = child.wait()
if exitcode != 0:
raise Error("non-zero exitcode (%d) from backup command: %s" % (exitcode, str(self)))
-
+
def __str__(self):
return " ".join(self.command)
View
10 hub.py
@@ -1,14 +1,14 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
# Copyright (c) 2010 Alon Swartz <alon@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
"""TurnKey Hub API - Backup
Notes:
@@ -150,7 +150,7 @@ def __init__(self, response):
self.size = int(response['size']) # in MBs
self.label = response['description']
- # no interface for this in tklbam, so not returned from hub
+ # no interface for this in tklbam, so not returned from hub
self.sessions = []
class Credentials(AttrDict):
View
16 keypacket.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import os
import hashlib
import base64
@@ -41,7 +41,7 @@ def _repeat(f, input, count):
return input
def _cipher_key(passphrase, repeats):
- cipher_key = _repeat(lambda k: hashlib.sha256(k).digest(),
+ cipher_key = _repeat(lambda k: hashlib.sha256(k).digest(),
passphrase, repeats)
return cipher_key
@@ -60,12 +60,12 @@ def fmt(secret, passphrase):
cipher_key = _cipher_key(passphrase, hash_repeats)
plaintext = salt + hashlib.sha1(secret).digest() + secret
- ciphertext = _repeat(lambda v: _cipher(cipher_key).encrypt(v),
+ ciphertext = _repeat(lambda v: _cipher(cipher_key).encrypt(v),
_pad(plaintext), cipher_repeats)
fingerprint = hashlib.sha1(secret).digest()[:FINGERPRINT_LEN]
- packet = struct.pack("!BHH", KEY_VERSION,
- hash_repeats / 1000,
+ packet = struct.pack("!BHH", KEY_VERSION,
+ hash_repeats / 1000,
cipher_repeats / 1000) + fingerprint + ciphertext
return base64.b64encode(packet)
View
16 mysql.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import sys
import os
@@ -46,7 +46,7 @@ def isreadable(path):
return " ".join([ "--" + opt for opt in opts ])
def mysqldump(**conf):
- opts = [ "all-databases", "skip-extended-insert", "single-transaction",
+ opts = [ "all-databases", "skip-extended-insert", "single-transaction",
"compact", "quick" ]
command = "mysqldump " + _mysql_opts(opts, **conf)
@@ -124,7 +124,7 @@ def __contains__(self, val):
database = val
if database in self.databases:
return True
-
+
return self.default
@@ -193,7 +193,7 @@ def fromfile(self, fh, callback=None):
callback(database)
else:
database = None
-
+
elif statement.startswith("CREATE TABLE"):
if not database:
continue
@@ -428,7 +428,7 @@ def func(val):
def backup(myfs, etc, **kws):
"""High level mysql backup command.
Arguments:
-
+
<myfs> Directory we create to save MySQL backup
<etc> Directory where we save required MySQL etc configuration files (e.g., debian.cnf)
"""
View
8 passphrase.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import os
import sys
import base64
View
8 pathmap.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import glob
from os.path import *
View
16 pkgman.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import sys
import os
import re
@@ -35,8 +35,8 @@ def parse_status(path):
packages = []
for control in parse_status("/var/lib/dpkg/status"):
- d = dict([ re.split(':\s*', line, 1)
- for line in control.split('\n')
+ d = dict([ re.split(':\s*', line, 1)
+ for line in control.split('\n')
if line and (':' in line) and (line[0] != ' ') ])
if "ok installed" in d['Status']:
@@ -77,8 +77,8 @@ def __init__(self, packages):
status = os.WEXITSTATUS(status)
if status not in (0, 100):
raise self.Error("execution failed (%d): %s\n%s" % (status, command, output))
-
- cached = [ line.split()[1]
+
+ cached = [ line.split()[1]
for line in output.split("\n") if
line.startswith("Package: ") ]
View
10 registry.py
@@ -1,15 +1,15 @@
# the registry is implemented as a virtual object with properties that are
# mapped directly to files.
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import sys
import os
@@ -104,7 +104,7 @@ def credentials(self, val=UNDEFINED):
return Credentials(retval)
credentials = property(credentials, credentials)
-
+
def hbr(self, val=UNDEFINED):
format = "%Y-%m-%d %H:%M:%S"
if val and val is not UNDEFINED:
View
16 restore.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import sys
import os
@@ -90,7 +90,7 @@ def _duplicity_restore(address, cache_size, cache_dir, credentials, secret, time
return tmpdir
- def __init__(self, address, secret, cache_size, cache_dir,
+ def __init__(self, address, secret, cache_size, cache_dir,
limits=[], time=None, credentials=None, rollback=True):
print "Restoring duplicity archive from " + address
backup_archive = self._duplicity_restore(address, cache_size, cache_dir, credentials, secret, time)
@@ -112,7 +112,7 @@ def database(self):
print "\n" + self._title("Restoring databases")
try:
- mysql.restore(self.extras.myfs, self.extras.etc.mysql,
+ mysql.restore(self.extras.myfs, self.extras.etc.mysql,
limits=self.limits.db, callback=mysql.cb_print())
except mysql.Error, e:
@@ -152,14 +152,14 @@ def packages(self):
def _userdb_merge(old_etc, new_etc):
old_passwd = join(old_etc, "passwd")
new_passwd = join(new_etc, "passwd")
-
+
old_group = join(old_etc, "group")
new_group = join(new_etc, "group")
def r(path):
return file(path).read()
- return userdb.merge(r(old_passwd), r(old_group),
+ return userdb.merge(r(old_passwd), r(old_group),
r(new_passwd), r(new_group))
@staticmethod
View
14 rollback.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import os
from os.path import *
@@ -32,8 +32,8 @@ class Rollback:
PATH = "/var/backups/tklbam-rollback"
class Paths(Paths):
- files = [ 'etc', 'etc/mysql',
- 'fsdelta', 'dirindex', 'originals',
+ files = [ 'etc', 'etc/mysql',
+ 'fsdelta', 'dirindex', 'originals',
'newpkgs', 'myfs' ]
@classmethod
@@ -124,7 +124,7 @@ def rollback_new_packages(self):
def rollback_database(self):
if exists(self.paths.myfs):
- mysql.restore(self.paths.myfs, self.paths.etc.mysql,
+ mysql.restore(self.paths.myfs, self.paths.etc.mysql,
add_drop_database=True)
def rollback(self):
View
6 squid.py
@@ -15,9 +15,9 @@ def _is_listening(localport):
sock.connect(('127.0.0.1', localport))
return True
except socket.error, e:
- if e.errno == errno.ECONNREFUSED:
+ if e.errno == errno.ECONNREFUSED:
return False
-
+
while True:
if _is_listening(port_from) is False:
return port_from
@@ -36,7 +36,7 @@ def start(self):
os.environ['TKLBAM_SQUID_CACHE_DIR'] = self.cache_dir
self.address = "127.0.0.1:%d" % _find_free_port(33128)
- self.command = command.Command(("/usr/local/sbin/tklbam-squid", self.address, self.cache_size),
+ self.command = command.Command(("/usr/local/sbin/tklbam-squid", self.address, self.cache_size),
setpgrp=True, pty=True)
View
8 userdb.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
class Error(Exception):
pass
View
10 utils.py
@@ -1,20 +1,20 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import os
from os.path import *
import shutil
def remove_any(path):
- """Remove a path whether it is a file or a directory.
+ """Remove a path whether it is a file or a directory.
Return: True if removed, False if nothing to remove"""
if not lexists(path):
View
8 version.py
@@ -1,13 +1,13 @@
-#
+#
# Copyright (c) 2010 Liraz Siri <liraz@turnkeylinux.org>
-#
+#
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
-#
+#
# TKLBAM is open source software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
-#
+#
import re
from executil import getoutput
Please sign in to comment.
Something went wrong with that request. Please try again.