コード例 #1
0
ファイル: test_tac.py プロジェクト: iffy/grace
 def test_dne(self):
     """
     If the directory does not exist, it will create the directory and
     put a tac file in it.
     """
     tmp = FilePath(self.mktemp())
     setupDir(tmp.path, ('foo', 'bar'))
     self.assertTrue(tmp.exists(), "Should make the directory")
     tac = tmp.child('grace.tac')
     self.assertTrue(tac.exists(), "Should make the tac file")
     self.assertEqual(tac.getContent(), getTac(('foo', 'bar')),
                      "Should copy the tac template in")
コード例 #2
0
ファイル: test_tac.py プロジェクト: iffy/grace
 def test_exists(self):
     """
     If the directory and a file already exist, overwrite them
     """
     tmp = FilePath(self.mktemp())
     setupDir(tmp.path, ('ape', 'gorilla'))
     setupDir(tmp.path, ('foo', 'bar'))
     
     self.assertTrue(tmp.exists(), "Should make the directory")
     tac = tmp.child('grace.tac')
     self.assertTrue(tac.exists(), "Should make the tac file")
     self.assertEqual(tac.getContent(), getTac(('foo', 'bar')),
                      "Should copy the tac template in")
コード例 #3
0
ファイル: cli.py プロジェクト: iffy/grace
 def start(self, basedir, src, dst):
     """
     Start a grace forwarder.
     
     @param basedir: Directory to put the configuration, log and pid files.
     @param src: Listening endpoint
     @param dst: Connecting endpoint
     
     @return: C{Deferred} which fires with (out, err, code) tuple from
         running C{twistd} to start the process.
     """
     setupDir(basedir, (src, dst))
     r = self.twistd(['--logfile=grace.log', '--pidfile=grace.pid',
                      '--python=grace.tac'], env=None, path=basedir)
     
     def cb(result, basedir):
         socket = self._waitForFile(FilePath(basedir).child('grace.socket'))
         return socket.addCallback(lambda x:result)
     return r.addCallback(cb, basedir)