From: William D. Jones Date: Sun, 10 Mar 2019 05:43:55 +0000 (-0500) Subject: Gate Unix-specific functionality from resources and fcntl. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=43c7db77d4ea5cc05ea1e6fb26baca3690bd7ebd;p=SymbiYosys.git Gate Unix-specific functionality from resources and fcntl. Signed-off-by: William D. Jones --- diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index e572f5c..1f56b1a 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -16,8 +16,10 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # -import os, re, resource, sys -import subprocess, fcntl +import os, re, sys +if os.name == "posix": + import resource, fcntl +import subprocess from shutil import copyfile from select import select from time import time, localtime @@ -91,8 +93,9 @@ class SbyTask: self.job.log("%s: starting process \"%s\"" % (self.info, self.cmdline)) self.p = subprocess.Popen(self.cmdline, shell=True, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=(subprocess.STDOUT if self.logstderr else None)) - fl = fcntl.fcntl(self.p.stdout, fcntl.F_GETFL) - fcntl.fcntl(self.p.stdout, fcntl.F_SETFL, fl | os.O_NONBLOCK) + if os.name == "posix": + fl = fcntl.fcntl(self.p.stdout, fcntl.F_GETFL) + fcntl.fcntl(self.p.stdout, fcntl.F_SETFL, fl | os.O_NONBLOCK) self.job.tasks_pending.remove(self) self.job.tasks_running.append(self) self.running = True @@ -161,8 +164,9 @@ class SbyJob: self.start_clock_time = time() - ru = resource.getrusage(resource.RUSAGE_CHILDREN) - self.start_process_time = ru.ru_utime + ru.ru_stime + if os.name == "posix": + ru = resource.getrusage(resource.RUSAGE_CHILDREN) + self.start_process_time = ru.ru_utime + ru.ru_stime self.summary = list() @@ -565,9 +569,12 @@ class SbyJob: total_clock_time = int(time() - self.start_clock_time) - ru = resource.getrusage(resource.RUSAGE_CHILDREN) - total_process_time = int((ru.ru_utime + ru.ru_stime) - self.start_process_time) - self.total_time = total_process_time + if os.name == "posix": + ru = resource.getrusage(resource.RUSAGE_CHILDREN) + total_process_time = int((ru.ru_utime + ru.ru_stime) - self.start_process_time) + self.total_time = total_process_time + else: + total_process_time = 0 self.summary = [ "Elapsed clock time [H:MM:SS (secs)]: %d:%02d:%02d (%d)" %