当前位置: 首页>>代码示例>>Python>>正文


Python tracing.trace函数代码示例

本文整理汇总了Python中tracing.trace函数的典型用法代码示例。如果您正苦于以下问题:Python trace函数的具体用法?Python trace怎么用?Python trace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了trace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, allow_writes, fs, storedir):
        logging.debug('Initializing Journal for %s' % storedir)
        self.allow_writes = allow_writes
        self.fs = fs
        self.storedir = storedir
        if not self.storedir.endswith(os.sep):
            self.storedir += os.sep
        self.newdir = os.path.join(self.storedir, 'new/')
        self.deletedir = os.path.join(self.storedir, 'delete/')
        self.flag_file = os.path.join(self.storedir, self.flag_basename)
        self.new_flag = os.path.join(self.newdir, self.flag_basename)

        self.new_flag_seen = self.fs.exists(self.new_flag)
        tracing.trace('self.new_flag_seen: %s' % self.new_flag_seen)
        if self.allow_writes:
            if self.new_flag_seen:
                logging.debug('Automatically committing remaining changes')
                self.commit()
            else:
                logging.debug('Automatically rolling back remaining changes')
                self.rollback()
        else:
            logging.debug('Not committing/rolling back since read-only')
        self.new_files = set()
        self.deleted_files = set()
开发者ID:jensens,项目名称:larch,代码行数:25,代码来源:journal.py

示例2: _raw_unlock_client

 def _raw_unlock_client(self, client_name):
     tracing.trace('client_name=%s', client_name)
     client_id = self._get_client_id(client_name)
     client_dir = self._get_client_dir(client_id)
     self._lockmgr.unlock([client_dir])
     if client_name in self._open_client_infos:
         del self._open_client_infos[client_name]
开发者ID:hsivonen,项目名称:obnam,代码行数:7,代码来源:repo_fmt_6.py

示例3: chmod_symlink

 def chmod_symlink(self, pathname, mode):  # pragma: no cover
     tracing.trace('chmod_symlink %s %o', pathname, mode)
     if self.got_lchmod:
         lchmod = getattr(os, 'lchmod')
         lchmod(self.join(pathname), mode)
     else:
         self.lstat(pathname)
开发者ID:lukipuki,项目名称:obnam,代码行数:7,代码来源:vfs_local.py

示例4: backup_dir_contents

    def backup_dir_contents(self, root):
        '''Back up the list of files in a directory.'''

        tracing.trace('backup_dir: %s', root)
        if self.pretend:
            return

        new_basenames = self.fs.listdir(root)
        new_pathnames = [os.path.join(root, x) for x in new_basenames]
        if self.repo.file_exists(self.new_generation, root):
            old_pathnames = self.repo.get_file_children(
                    self.new_generation, root)
        else:
            old_pathnames = []

        for old in old_pathnames:
            if old not in new_pathnames:
                self.repo.remove_file(self.new_generation, old)
            else:
                try:
                    st = self.fs.lstat(old)
                except OSError:
                    pass
                else:
                    if not self.can_be_backed_up(old, st): 
                        self.repo.remove_file(self.new_generation, old)
开发者ID:rdparker,项目名称:obnam,代码行数:26,代码来源:backup_plugin.py

示例5: save_refcounts

    def save_refcounts(self):
        '''Save all modified refcounts.'''
        tracing.trace('saving refcounts (len(dirty) = %s)' % 
                            (len(self.dirty)))
        if self.dirty:
            dirname = os.path.join(self.node_store.dirname, self.refcountdir)
            if not self.node_store.journal.exists(dirname):
                self.node_store.journal.makedirs(dirname)
            ids = sorted(self.dirty)
            all_ids_in_memory = set(self.refcounts.keys())
            for start_id in range(self._start_id(ids[0]), 
                                  self._start_id(ids[-1]) + 1, 
                                  self.per_group):

                all_ids_in_group = set(
                    range(start_id, start_id + self.per_group))
                keys = all_ids_in_group.intersection(all_ids_in_memory)
                if keys:
                    encoded = encode_refcounts(
                        self.refcounts, start_id, self.per_group, keys)
                    filename = self._group_filename(start_id)
                    self.node_store.journal.overwrite_file(filename, encoded)

        # We re-initialize these so that they don't grow indefinitely.
        self.refcounts = dict()
        self.dirty = set()
开发者ID:jensens,项目名称:larch,代码行数:26,代码来源:refcountstore.py

示例6: put_chunk_only

    def put_chunk_only(self, data):
        '''Put chunk of data into repository.

        If the same data is already in the repository, it will be put there
        a second time. It is the caller's responsibility to check
        that the data is not already in the repository.

        Return the unique identifier of the new chunk.

        '''

        def random_chunkid():
            return random.randint(0, obnamlib.MAX_ID)

        self.require_started_generation()

        if self.prev_chunkid is None:
            self.prev_chunkid = random_chunkid()

        while True:
            chunkid = (self.prev_chunkid + 1) % obnamlib.MAX_ID
            filename = self._chunk_filename(chunkid)
            try:
                self.fs.write_file(filename, data)
            except OSError, e: # pragma: no cover
                if e.errno == errno.EEXIST:
                    self.prev_chunkid = random_chunkid()
                    continue
                raise
            else:
                tracing.trace('chunkid=%s', chunkid)
                break
开发者ID:bytearchive,项目名称:obnam,代码行数:32,代码来源:repo.py

示例7: lock_client

    def lock_client(self, client_name):
        '''Lock a client for exclusive write access.

        Raise obnamlib.LockFail if locking fails. Lock will be released
        by commit_client() or unlock_client().

        '''

        tracing.trace('client_name=%s', client_name)
        self.require_no_client_lock()
        self.require_no_shared_lock()

        self.check_format_version()
        client_id = self.clientlist.get_client_id(client_name)
        if client_id is None:
            raise LockFail('client %s does not exist' % client_name)

        client_dir = self.client_dir(client_id)
        if not self.fs.exists(client_dir):
            self.fs.mkdir(client_dir)
            self.hooks.call('repository-toplevel-init', self, client_dir)

        self.lockmgr.lock([client_dir])
        self.got_client_lock = True
        self.current_client = client_name
        self.current_client_id = client_id
        self.added_generations = []
        self.removed_generations = []
        self.client = obnamlib.ClientMetadataTree(self.fs, client_dir,
                                                  self.node_size,
                                                  self.upload_queue_size,
                                                  self.lru_size, self)
        self.client.init_forest()
开发者ID:bytearchive,项目名称:obnam,代码行数:33,代码来源:repo.py

示例8: do

 def do(self):
     tracing.trace("CheckForest: checking forest %s" % self.name )
     for tree in self.fsck.forest.trees:
         self.fsck.count(tree.root.id)
         root_node = self.get_node(tree.root.id)
         tracing.trace('root_node.id=%s' % root_node.id)
         yield CheckIndexNode(self.fsck, root_node)
开发者ID:obnam-mirror,项目名称:larch,代码行数:7,代码来源:fsck.py

示例9: get_repository_object

    def get_repository_object(self, create=False, repofs=None):
        '''Return an implementation of obnamlib.RepositoryInterface.'''

        logging.info('Opening repository: %s', self.settings['repository'])
        tracing.trace('create=%s', create)
        tracing.trace('repofs=%s', repofs)

        repopath = self.settings['repository']
        if repofs is None:
            repofs = self.fsf.new(repopath, create=create)
            if self.settings['crash-limit'] > 0:
                repofs.crash_limit = self.settings['crash-limit']
            repofs.connect()
        else:
            repofs.reinit(repopath)

        kwargs = {
            'lock_timeout': self.settings['lock-timeout'],
            'node_size': self.settings['node-size'],
            'upload_queue_size': self.settings['upload-queue-size'],
            'lru_size': self.settings['lru-size'],
            'idpath_depth': self.settings['idpath-depth'],
            'idpath_bits': self.settings['idpath-bits'],
            'idpath_skip': self.settings['idpath-skip'],
            'hooks': self.hooks,
            'current_time': self.time,
            'chunk_size': self.settings['chunk-size'],
            }

        if create:
            return self.repo_factory.create_repo(
                repofs, self.get_default_repository_class(), **kwargs)
        else:
            return self.repo_factory.open_existing_repo(repofs, **kwargs)
开发者ID:hsivonen,项目名称:obnam,代码行数:34,代码来源:app.py

示例10: _write_format_version

 def _write_format_version(self, version):
     '''Write the desired format version to the repository.'''
     tracing.trace('write format version')
     if not self.fs.exists('metadata'):
         self.fs.mkdir('metadata')
     self.fs.overwrite_file('metadata/format', '%s\n' % version,
                            runfilters=False)
开发者ID:bytearchive,项目名称:obnam,代码行数:7,代码来源:repo.py

示例11: _new_index

 def _new_index(self, keys, values):
     '''Create a new index node.'''
     index = larch.IndexNode(self._new_id(), keys, values)
     for child_id in values:
         self._increment(child_id)
     tracing.trace('id=%s' % index.id)
     return index
开发者ID:jensens,项目名称:larch,代码行数:7,代码来源:tree.py

示例12: remove_chunk_from_indexes

    def remove_chunk_from_indexes(self, chunk_id, client_id):
        tracing.trace('chunk_id=%s', chunk_id)

        self._require_chunk_indexes_lock()
        checksum = self._chunklist.get_checksum(chunk_id)
        self._chunksums.remove(checksum, chunk_id, client_id)
        self._chunklist.remove(chunk_id)
开发者ID:bytearchive,项目名称:obnam,代码行数:7,代码来源:repo_fmt_6.py

示例13: _write_to_tempfile

    def _write_to_tempfile(self, pathname, contents):
        path = self.join(pathname)
        dirname = os.path.dirname(path)
        if not os.path.exists(dirname):
            tracing.trace('os.makedirs(%s)' % dirname)
            try:
                os.makedirs(dirname)
            except OSError as e: # pragma: no cover
                # This avoids a race condition: another Obnam process
                # may have created the directory between our check and
                # creation attempt. If so, we ignore it. As long as
                # the directory exists, all's good.
                if e.errno != errno.EEXIST:
                    raise

        fd, tempname = tempfile.mkstemp(dir=dirname)
        os.close(fd)
        f = self.open(tempname, 'wb')

        pos = 0
        while pos < len(contents):
            chunk = contents[pos:pos+self.chunk_size]
            f.write(chunk)
            pos += len(chunk)
            self.bytes_written += len(chunk)
        f.close()
        return tempname
开发者ID:argv-minus-one,项目名称:obnam,代码行数:27,代码来源:vfs_local.py

示例14: remove_chunk

 def remove_chunk(self, chunk_id):
     tracing.trace('chunk_id=%s', chunk_id)
     filename = self._chunk_filename(chunk_id)
     try:
         self._fs.remove(filename)
     except OSError:
         raise obnamlib.RepositoryChunkDoesNotExist(str(chunk_id))
开发者ID:bytearchive,项目名称:obnam,代码行数:7,代码来源:repo_fmt_6.py

示例15: needs_backup

    def needs_backup(self, pathname, current):
        '''Does a given file need to be backed up?'''

        # Directories always require backing up so that backup_dir_contents
        # can remove stuff that no longer exists from them.
        if current.isdir():
            tracing.trace('%s is directory, so needs backup' % pathname)
            return True
        if self.pretend:
            gens = self.repo.list_generations()
            if not gens:
                return True
            gen = gens[-1]
        else:
            gen = self.repo.new_generation
        tracing.trace('gen=%s' % repr(gen))
        try:
            old = self.repo.get_metadata(gen, pathname)
        except obnamlib.Error, e:
            # File does not exist in the previous generation, so it
            # does need to be backed up.
            tracing.trace('%s not in previous gen, so needs backup' % pathname)
            tracing.trace('error: %s' % str(e))
            tracing.trace(traceback.format_exc())
            return True
开发者ID:bytearchive,项目名称:obnam,代码行数:25,代码来源:backup_plugin.py


注:本文中的tracing.trace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。