suppress a specific warning if we're running from cron, otherwise there's a lot of cron alerts.
This commit is contained in:
		
							parent
							
								
									dce40d7225
								
							
						
					
					
						commit
						fca5f12aa2
					
				@ -4,6 +4,7 @@ import pwd
 | 
				
			|||||||
import grp
 | 
					import grp
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import socket
 | 
					import socket
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
import warnings
 | 
					import warnings
 | 
				
			||||||
##
 | 
					##
 | 
				
			||||||
import psutil
 | 
					import psutil
 | 
				
			||||||
@ -17,6 +18,12 @@ from . import logger
 | 
				
			|||||||
_logger = logging.getLogger()
 | 
					_logger = logging.getLogger()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if os.isatty(sys.stdin.fileno()):
 | 
				
			||||||
 | 
					    _is_cron = False
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    _is_cron = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_owner(owner_xml):
 | 
					def get_owner(owner_xml):
 | 
				
			||||||
    owner = {}
 | 
					    owner = {}
 | 
				
			||||||
    user = owner_xml.find('user')
 | 
					    user = owner_xml.find('user')
 | 
				
			||||||
@ -269,7 +276,15 @@ class Distro(object):
 | 
				
			|||||||
                _logger.warning(warnmsg)
 | 
					                _logger.warning(warnmsg)
 | 
				
			||||||
                if proc:
 | 
					                if proc:
 | 
				
			||||||
                    _logger.warning('PID information: {0}'.format(vars(proc)))
 | 
					                    _logger.warning('PID information: {0}'.format(vars(proc)))
 | 
				
			||||||
 | 
					                # 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)
 | 
					                    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)
 | 
					                return(False)
 | 
				
			||||||
        if not self.mount.is_mounted:
 | 
					        if not self.mount.is_mounted:
 | 
				
			||||||
            _logger.error(('The mountpoint {0} for distro {1} is not mounted; '
 | 
					            _logger.error(('The mountpoint {0} for distro {1} is not mounted; '
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user