示例#1
0
文件: store.py 项目: pombreda/gofer
 def commit(self, sn):
     """
     The request referenced by the serial number has been completely
     processed and can be deleted from the journal.
     :param sn: A request serial number.
     :param sn: str
     """
     try:
         path = self.journal[sn]
         unlink(path)
         log.debug('%s committed', sn)
     except KeyError:
         log.warn('%s not found for commit', sn)
示例#2
0
 def commit(self, sn):
     """
     The request referenced by the serial number has been completely
     processed and can be deleted from the journal.
     :param sn: A request serial number.
     :param sn: str
     """
     try:
         path = self.journal.pop(sn)
         unlink(path)
         log.debug('%s committed', sn)
     except KeyError:
         log.warning('%s not found for commit', sn)
示例#3
0
 def _read(path):
     """
     Read a request.
     :param path: The path to the journal file.
     :type path: str
     :return: The read request.
     :rtype: Document
     """
     with open(path) as fp:
         try:
             request = Document()
             body = fp.read()
             request.load(body)
             log.debug('read [%s]: %s', path, body)
             return request
         except ValueError:
             log.error('%s corrupt (discarded)', path)
             unlink(path)
示例#4
0
 def test_not_exist(self, _unlink):
     path = '/tmp/file'
     exception = OSError()
     exception.errno = errno.ENOENT
     _unlink.side_effect = exception
     unlink(path)
示例#5
0
 def test_unlink(self, _unlink):
     path = '/tmp/file'
     unlink(path)
     _unlink.assert_called_once_with(path)
示例#6
0
 def test_not_exist(self, _unlink):
     path = '/tmp/file'
     exception = OSError()
     exception.errno = errno.ENOENT
     _unlink.side_effect = exception
     unlink(path)
示例#7
0
 def test_unlink(self, _unlink):
     path = '/tmp/file'
     unlink(path)
     _unlink.assert_called_once_with(path)