Logging, etc tweaks
This commit is contained in:
parent
d07636a5ff
commit
3eeda045bd
1 changed files with 19 additions and 14 deletions
|
@ -11,13 +11,10 @@
|
||||||
# accesskey = 'amazon aws access key'
|
# accesskey = 'amazon aws access key'
|
||||||
# sharedkey = 'amazon aws shared key'
|
# sharedkey = 'amazon aws shared key'
|
||||||
# gpgsymmetrickey = 'gpg symmetric key -- make it good, but do not lose it'
|
# gpgsymmetrickey = 'gpg symmetric key -- make it good, but do not lose it'
|
||||||
# speedfile = '/path/to/a/speed-limit-file'
|
|
||||||
|
|
||||||
import base64
|
|
||||||
import glob
|
import glob
|
||||||
import md5
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import secrets
|
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
@ -32,12 +29,21 @@ import boto.exception
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
|
||||||
logger = logging.getLogger('')
|
import secrets
|
||||||
loghandler = logging.handlers.SysLogHandler('/dev/log',
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
sysloghandler = logging.handlers.SysLogHandler('/dev/log',
|
||||||
facility=logging.handlers.SysLogHandler.LOG_DAEMON)
|
facility=logging.handlers.SysLogHandler.LOG_DAEMON)
|
||||||
logformatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
|
syslogformatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
|
||||||
loghandler.setFormatter(logformatter)
|
sysloghandler.setFormatter(syslogformatter)
|
||||||
logger.addHandler(loghandler)
|
logger.addHandler(sysloghandler)
|
||||||
|
|
||||||
|
consolehandler = logging.StreamHandler(sys.stdout)
|
||||||
|
consoleformatter = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
|
||||||
|
consolehandler.setFormatter(consoleformatter)
|
||||||
|
logger.addHandler(consolehandler)
|
||||||
|
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
def is_exe(fpath):
|
def is_exe(fpath):
|
||||||
|
@ -88,7 +94,7 @@ def open_s3(accesskey, sharedkey, host):
|
||||||
return bucket
|
return bucket
|
||||||
|
|
||||||
def handle_progress(transmitted, pending):
|
def handle_progress(transmitted, pending):
|
||||||
logger.debug('%i of %i bytes transmitted (%.2f%%)' % (transmitted, pending, (transmitted/float(pending))*100))
|
logger.info('%i of %i bytes transmitted (%.2f%%)' % (transmitted, pending, (transmitted/float(pending))*100))
|
||||||
|
|
||||||
def send_file(bucket, filename):
|
def send_file(bucket, filename):
|
||||||
basefilename = os.path.basename(filename)
|
basefilename = os.path.basename(filename)
|
||||||
|
@ -113,7 +119,7 @@ def encryption_worker(in_q, out_q):
|
||||||
result = encrypt_file(filename, gpgkey, comppath)
|
result = encrypt_file(filename, gpgkey, comppath)
|
||||||
out_q.put(result)
|
out_q.put(result)
|
||||||
logger.info("Finished encryption of %s in %i seconds.", filename, time.time()-cryptstart_time)
|
logger.info("Finished encryption of %s in %i seconds.", filename, time.time()-cryptstart_time)
|
||||||
logger.info("Encryption worker dying after %i tasks in %i seconds.", counter, time.time()-start_time)
|
logger.info("Finished processing %i items in encryption queue in %i seconds.", counter, time.time()-start_time)
|
||||||
out_q.put('STOP')
|
out_q.put('STOP')
|
||||||
|
|
||||||
def sending_worker(in_q, accesskey, sharedkey, host):
|
def sending_worker(in_q, accesskey, sharedkey, host):
|
||||||
|
@ -148,10 +154,9 @@ def sending_worker(in_q, accesskey, sharedkey, host):
|
||||||
logger.info("Finished sending of %s in %i seconds, transfer speed %i bytes/second.", filename, sending_seconds, bytespersecond)
|
logger.info("Finished sending of %s in %i seconds, transfer speed %i bytes/second.", filename, sending_seconds, bytespersecond)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Read in arguments
|
# Read in arguments, verify that they match the BackupPC standard exactly
|
||||||
if len(sys.argv) != 12:
|
if len(sys.argv) != 12:
|
||||||
sys.stderr.write("Usage: %s tarCreatePath splitPath parPath host bkupNum \
|
sys.stderr.write("Usage: %s tarCreatePath splitPath parPath host bkupNum compPath fileExt splitSize outLoc parFile share\n" % sys.argv[0])
|
||||||
compPath fileExt splitSize outLoc parFile share\n" % sys.argv[0])
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
tarCreate = sys.argv[1]
|
tarCreate = sys.argv[1]
|
||||||
|
|
Loading…
Reference in a new issue