Skip to content

Commit

Permalink
Merge pull request #2 from mmokhi/python3
Browse files Browse the repository at this point in the history
Change python2 style to python3
  • Loading branch information
feraudet committed Mar 29, 2019
2 parents a031f39 + fd82865 commit e80408e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions check_duply
Expand Up @@ -3,12 +3,14 @@
# By Arne Schwabe <arne-nagios@rfc2549.org>
# LICENSE: BSD

from __future__ import print_function
from subprocess import Popen,PIPE
import sys
import time
import os
import argparse
import re
import future

version = '1'

Expand Down Expand Up @@ -56,8 +58,8 @@ def main():
okay = 2
msg = "CRITICAL: "

if err.find("does not resolve to a profile folder in") != -1:
print "UNKNOWN: Can't find duply configuration for %s" % repr(args.profile)
if err.find(b"does not resolve to a profile folder in") != -1:
print("UNKNOWN: Can't find duply configuration for %s" % repr(args.profile))
sys.exit(3)
else:
if not checkoutput(output):
Expand All @@ -69,7 +71,7 @@ def main():
# okay=2
# msg = "Unexpected output: %s, " % repr(err)

print msg, "last full %s ago, last incremential %s ago|lastfull=%d, lastinc=%d" % ( formattime(sincelastfull), formattime(sincelastinc), sincelastfull, sincelastinc)
print(msg, "last full %s ago, last incremential %s ago|lastfull=%d, lastinc=%d" % ( formattime(sincelastfull), formattime(sincelastinc), sincelastfull, sincelastinc))
sys.exit(okay)

def checkoutput(output):
Expand All @@ -92,7 +94,7 @@ def findlastdates(output):
lastfull = 0
lastinc = 0

for line in output.split("\n"):
for line in output.split(b"\n"):
parts = line.split()

# ['Incremental', 'Sun', 'Oct', '31', '03:00:04', '2010', '1']
Expand Down Expand Up @@ -129,7 +131,7 @@ class TimeException(Exception):

def intstringtoseconds(interval_string):
def error():
print (bad_interval_string % interval_string)
print((bad_interval_string % interval_string))
sys.exit(2)

if interval_string.isdigit():
Expand Down

0 comments on commit e80408e

Please sign in to comment.