summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrent s <bts@square-r00t.net>2020-06-17 13:46:58 -0400
committerbrent s <bts@square-r00t.net>2020-06-17 13:46:58 -0400
commitfca5f12aa2cad7f6d4a885da34be66700fb18c12 (patch)
tree769c5cb9703078a5c2f88d2be2e36549a4cd0214
parentdce40d7225c3844bdde731378f87a6d256c314d8 (diff)
downloadRepoMirror-fca5f12aa2cad7f6d4a885da34be66700fb18c12.tar.xz
suppress a specific warning if we're running from cron, otherwise there's a lot of cron alerts.
-rw-r--r--repomirror/sync.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/repomirror/sync.py b/repomirror/sync.py
index 4da4286..3f0d643 100644
--- a/repomirror/sync.py
+++ b/repomirror/sync.py
@@ -4,6 +4,7 @@ import pwd
import grp
import os
import socket
+import sys
import warnings
##
import psutil
@@ -17,6 +18,12 @@ from . import logger
_logger = logging.getLogger()
+if os.isatty(sys.stdin.fileno()):
+ _is_cron = False
+else:
+ _is_cron = True
+
+
def get_owner(owner_xml):
owner = {}
user = owner_xml.find('user')
@@ -269,7 +276,15 @@ class Distro(object):
_logger.warning(warnmsg)
if proc:
_logger.warning('PID information: {0}'.format(vars(proc)))
- warnings.warn(warnmsg)
+ # This is *really* annoying if you're running from cron and get emailed output.
+ # So we suppress it if in cron.
+ if not _is_cron:
+ warnings.warn(warnmsg)
+ if proc:
+ proc_info = {k.lstrip('_'):v for k, v in vars(proc) if k not in ('_lock', '_proc')}
+ import pprint
+ print('Process information:')
+ pprint.pprint(proc_info)
return(False)
if not self.mount.is_mounted:
_logger.error(('The mountpoint {0} for distro {1} is not mounted; '