Skip to content

Commit

Permalink
Error message if file cannot be parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
alneberg committed Oct 16, 2019
1 parent 28beefc commit ed77049
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions del_bupp_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ def main(args):
files = glob.glob("/home/bupp/other/*")
for f in files:
bn = os.path.basename(f)
file_date = None
if args.mode == 'github' and 'github' in f:
file_date = datetime.datetime.strptime(bn[13:23], "%Y-%m-%d")

if args.mode == 'zendesk' and 'github' not in f:
file_date = datetime.datetime.strptime(bn[0:10], "%Y-%m-%d")

if file_date is None:
sys.stderr.write("Error {} was not possible to parse.".format(file_date)
sys.exit(-1)

# Save backups from April, August, December
# Remove others older than 90 days
if ((datetime.datetime.now() - file_date).days > 90 and file_date.month % 4):
Expand All @@ -36,8 +41,6 @@ def main(args):
sys.stderr.write("Would have removed {}".format(f))




if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("mode", choices=['github', 'zendesk'])
Expand Down

0 comments on commit ed77049

Please sign in to comment.