Bug 1416314 - Guard against psutil exceptions when generating system-info.log; r=jmaher

It seems psutil can throw a wide range of exceptions when accessing system
information on aws...intermittently, of course. Let's expect and discard
such exceptions so that test jobs are not dependent on creating system-info.log.
This commit is contained in:
Geoff Brown 2017-11-13 13:11:59 -07:00
Родитель f2ef09632b
Коммит c726c01120
1 изменённых файлов: 27 добавлений и 25 удалений

Просмотреть файл

@ -676,32 +676,34 @@ class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMix
"""
try:
import psutil
dir = self.query_abs_dirs()['abs_blob_upload_dir']
self.mkdir_p(dir)
path = os.path.join(dir, "system-info.log")
with open(path, "w") as f:
self._report_line(f, "System info collected at ", datetime.now())
self._report_line(f, "\nBoot time ",
datetime.fromtimestamp(psutil.boot_time()))
self._report_line(f, "\nVirtual memory: ", psutil.virtual_memory())
self._report_line(f, "\nDisk partitions: ", psutil.disk_partitions())
self._report_line(f, "\nDisk usage (/): ", psutil.disk_usage(os.path.sep))
self._report_line(f, "\nUsers: ", psutil.users())
self._report_line(f, "\nNetwork connections:", "")
try:
for nc in psutil.net_connections():
self._report_line(f, " ", nc)
except:
f.write("Exception getting network info: %s" % sys.exc_info()[0])
self._report_line(f, "\nProcesses:", "")
try:
for p in psutil.process_iter():
ctime = str(datetime.fromtimestamp(p.create_time()))
self._report_line(f, " PID", "%d %s %s created at %s" %
(p.pid, p.name(), str(p.cmdline()), ctime))
except:
f.write("Exception getting process info: %s" % sys.exc_info()[0])
except:
return
dir = self.query_abs_dirs()['abs_blob_upload_dir']
self.mkdir_p(dir)
path = os.path.join(dir, "system-info.log")
with open(path, "w") as f:
self._report_line(f, "System info collected at ", datetime.now())
self._report_line(f, "\nBoot time ", datetime.fromtimestamp(psutil.boot_time()))
self._report_line(f, "\nVirtual memory: ", psutil.virtual_memory())
self._report_line(f, "\nDisk partitions: ", psutil.disk_partitions())
self._report_line(f, "\nDisk usage (/): ", psutil.disk_usage(os.path.sep))
self._report_line(f, "\nUsers: ", psutil.users())
self._report_line(f, "\nNetwork connections:", "")
try:
for nc in psutil.net_connections():
self._report_line(f, " ", nc)
except:
f.write("Exception getting network info: %s" % sys.exc_info()[0])
self._report_line(f, "\nProcesses:", "")
try:
for p in psutil.process_iter():
ctime = str(datetime.fromtimestamp(p.create_time()))
self._report_line(f, " PID", "%d %s %s created at %s" %
(p.pid, p.name(), str(p.cmdline()), ctime))
except:
f.write("Exception getting process info: %s" % sys.exc_info()[0])
# psutil throws a variety of intermittent exceptions
self.info("Unable to complete system-info.log: %s" % sys.exc_info()[0])
# pull defined in VCSScript.
# preflight_run_tests defined in TestingMixin.