How to add code that Waf always executes before exiting?

I want to make Waf generate a beep when it completes any command that took more than 10 seconds.

I do not know how to add this and assure that the code is executed when Waf exits.

This should be done for any Waf team, not just for assembly.

I checked the Waf book , but I could not find any directions on how to do this.

+3
source share
1 answer

In your module, wscriptyou can use the standard atexit Python library to register the calls you want to call when the process exits. For instance:

import atexit
import time

class MayBeep(object):
  def __init__(self, deadline=10.0):
    self.deadline = time.time() + deadline
  def __call__(self):
    if time.time() > self.deadline():
      print '\7'

atexit.register(MayBeep())

... rest of your wscript module ...

, - , print '\7' ( , , Python ), Q - , ".

+4

Source: https://habr.com/ru/post/1738646/


All Articles