Changeset 6215ebd in trunk


Ignore:
Timestamp:
2010-02-01T00:44:29Z (15 years ago)
Author:
david-sarah <david-sarah@…>
Branches:
master
Children:
7d32fafc
Parents:
ea395437
Message:

cli: suppress DeprecationWarnings? emitted from importing nevow and twisted. Fixes #859

Location:
src/allmydata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/__init__.py

    rea395437 r6215ebd  
    66community web site: U{http://allmydata.org/}
    77"""
     8
     9# This is just to suppress DeprecationWarnings from nevow and twisted.
     10# See http://allmydata.org/trac/tahoe/ticket/859 and
     11# http://divmod.org/trac/ticket/2994 .
     12import warnings
     13warnings.filterwarnings("ignore", category=DeprecationWarning,
     14    message="object.__new__\(\) takes no parameters",
     15    append=True)
     16warnings.filterwarnings("ignore", category=DeprecationWarning,
     17    message="The popen2 module is deprecated.  Use the subprocess module.",
     18    append=True)
     19warnings.filterwarnings("ignore", category=DeprecationWarning,
     20    message="the md5 module is deprecated; use hashlib instead",
     21    append=True)
     22warnings.filterwarnings("ignore", category=DeprecationWarning,
     23    message="the sha module is deprecated; use the hashlib module instead",
     24    append=True)
     25try:
     26    import nevow
     27    from twisted.persisted import sob
     28    from twisted.python import filepath
     29    hush_pyflakes = (nevow, sob, filepath)
     30    del hush_pyflakes
     31finally:
     32    warnings.filters.pop()
     33    warnings.filters.pop()
     34    warnings.filters.pop()
     35    warnings.filters.pop()
    836
    937__version__ = "unknown"
     
    2755# http://allmydata.org/trac/tahoe/wiki/Versioning
    2856__full_version__ = __appname__ + '/' + str(__version__)
    29 
    30 hush_pyflakes = __version__
    31 del hush_pyflakes
    3257
    3358import _auto_deps
  • TabularUnified src/allmydata/test/test_runner.py

    rea395437 r6215ebd  
    356356    test_introducer.timeout = 480 # This hit the 120-second timeout on "François Lenny-armv5tel", then it hit a 240-second timeout on our feisty2.5 buildslave: http://allmydata.org/buildbot/builders/feisty2.5/builds/2381/steps/test/logs/test.log
    357357
     358    def test_client_no_noise(self):
     359        self.skip_if_cannot_daemonize()
     360        basedir = self.workdir("test_client_no_noise")
     361        c1 = os.path.join(basedir, "c1")
     362        HOTLINE_FILE = os.path.join(c1, "suicide_prevention_hotline")
     363        TWISTD_PID_FILE = os.path.join(c1, "twistd.pid")
     364        PORTNUMFILE = os.path.join(c1, "client.port")
     365
     366        d = utils.getProcessOutputAndValue(bintahoe, args=["--quiet", "create-client", "--basedir", c1, "--webport", "0"], env=os.environ)
     367        def _cb(res):
     368            out, err, rc_or_sig = res
     369            errstr = "cc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
     370            assert rc_or_sig == 0, errstr
     371            self.failUnlessEqual(rc_or_sig, 0)
     372            # By writing this file, we get forty seconds before the client will exit. This insures
     373            # that even if the 'stop' command doesn't work (and the test fails), the client should
     374            # still terminate.
     375            open(HOTLINE_FILE, "w").write("")
     376            open(os.path.join(c1, "introducer.furl"), "w").write("pb://xrndsskn2zuuian5ltnxrte7lnuqdrkz@127.0.0.1:55617/introducer\n")
     377            # now it's safe to start the node
     378        d.addCallback(_cb)
     379
     380        def _start(res):
     381            return utils.getProcessOutputAndValue(bintahoe, args=["--quiet", "start", c1], env=os.environ)
     382        d.addCallback(_start)
     383
     384        def _cb2(res):
     385            out, err, rc_or_sig = res
     386            errstr = "cc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
     387            open(HOTLINE_FILE, "w").write("")
     388            self.failUnlessEqual(rc_or_sig, 0, errstr)
     389            self.failUnlessEqual(out, "", errstr) # If you emit noise, you fail this test.
     390            self.failUnlessEqual(err, "", errstr)
     391
     392            # the parent (twistd) has exited. However, twistd writes the pid
     393            # from the child, not the parent, so we can't expect twistd.pid
     394            # to exist quite yet.
     395
     396            # the node is running, but it might not have made it past the
     397            # first reactor turn yet, and if we kill it too early, it won't
     398            # remove the twistd.pid file. So wait until it does something
     399            # that we know it won't do until after the first turn.
     400        d.addCallback(_cb2)
     401
     402        def _node_has_started():
     403            return os.path.exists(PORTNUMFILE)
     404        d.addCallback(lambda res: self.poll(_node_has_started))
     405
     406        # now we can kill it. TODO: On a slow machine, the node might kill
     407        # itself before we get a chance too, especially if spawning the
     408        # 'tahoe stop' command takes a while.
     409        def _stop(res):
     410            self.failUnless(os.path.exists(TWISTD_PID_FILE), (TWISTD_PID_FILE, os.listdir(os.path.dirname(TWISTD_PID_FILE))))
     411            return utils.getProcessOutputAndValue(bintahoe, args=["--quiet", "stop", c1], env=os.environ)
     412        d.addCallback(_stop)
     413        return d
     414
    358415    def test_client(self):
    359416        self.skip_if_cannot_daemonize()
Note: See TracChangeset for help on using the changeset viewer.