oops
This commit is contained in:
parent
a89a6ec94b
commit
7eee1c4658
@ -42,12 +42,12 @@ class log(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Make this non-fatal since we also log to journal for systemd?
|
# Make this non-fatal since we also log to journal for systemd?
|
||||||
raise e
|
raise e
|
||||||
self.systemd()
|
self.chkSystemd()
|
||||||
self.journald()
|
self.journald()
|
||||||
self.Logger.setLevel(self.loglvls[self.loglvl])
|
self.Logger.setLevel(self.loglvls[self.loglvl])
|
||||||
self.log_handlers()
|
self.log_handlers()
|
||||||
|
|
||||||
def systemd(self):
|
def chkSystemd(self):
|
||||||
# Add journald support if we're on systemd.
|
# Add journald support if we're on systemd.
|
||||||
# We probably are since we're most likely on Arch, but we don't want to
|
# We probably are since we're most likely on Arch, but we don't want to
|
||||||
# make assumptions.
|
# make assumptions.
|
||||||
|
@ -170,3 +170,33 @@ os.setegid(my_gid)
|
|||||||
os.setgroups(my_grps)
|
os.setgroups(my_grps)
|
||||||
os.umask(old_umask)
|
os.umask(old_umask)
|
||||||
subprocess.run(['touch', '/tmp/parenttest'])
|
subprocess.run(['touch', '/tmp/parenttest'])
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
Getting remote sshd version
|
||||||
|
|
||||||
|
stdlib:
|
||||||
|
----
|
||||||
|
import socket
|
||||||
|
|
||||||
|
try:
|
||||||
|
sock = socket.socket()
|
||||||
|
sock.settimeout(10)
|
||||||
|
sock.connect(('cylon', 22))
|
||||||
|
version = sock.recv(64).decode('utf-8').strip()
|
||||||
|
# version is a string like "SSH-2.0-OpenSSH_7.9"
|
||||||
|
sock.close()
|
||||||
|
except Exception as e:
|
||||||
|
# Obviously you can specify multiple exceptions to catch.
|
||||||
|
raise RuntimeError(e)
|
||||||
|
----
|
||||||
|
|
||||||
|
paramiko (does not require auth):
|
||||||
|
----
|
||||||
|
import paramiko
|
||||||
|
|
||||||
|
t = paramiko.Transport(('cylon', 22))
|
||||||
|
t.connect()
|
||||||
|
t.remote_version
|
||||||
|
----
|
||||||
|
@ -83,7 +83,10 @@ class Backup(object):
|
|||||||
if self.args['verbose']:
|
if self.args['verbose']:
|
||||||
handlers.append(logging.StreamHandler())
|
handlers.append(logging.StreamHandler())
|
||||||
if has_systemd:
|
if has_systemd:
|
||||||
|
try:
|
||||||
h = journal.JournalHandler()
|
h = journal.JournalHandler()
|
||||||
|
except AttributeError:
|
||||||
|
h = journal.JournaldLogHandler()
|
||||||
h.setFormatter(_journalfmt)
|
h.setFormatter(_journalfmt)
|
||||||
h.setLevel(loglvls[self.args['loglevel']])
|
h.setLevel(loglvls[self.args['loglevel']])
|
||||||
self.logger.addHandler(h)
|
self.logger.addHandler(h)
|
||||||
|
Loading…
Reference in New Issue
Block a user