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


Python lib.dryrun_msg函数代码示例

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


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

示例1: set_permissions

    def set_permissions(self):
        '''set access permission bits equal to source'''

        verbose(dryrun_msg('  os.chmod(%s, %04o)' %
                           (self.name, self.stat.mode & 07777)))
        unix_out('chmod 0%o %s' % (self.stat.mode & 07777, self.name))
        if not synctool.lib.DRY_RUN:
            try:
                os.chmod(self.name, self.stat.mode & 07777)
            except OSError as err:
                error('failed to chmod %04o %s : %s' %
                      (self.stat.mode & 07777, self.name, err.strerror))
                terse(synctool.lib.TERSE_FAIL, 'mode %s' % self.name)
开发者ID:dot-Sean,项目名称:synctool,代码行数:13,代码来源:object.py

示例2: upgrade

    def upgrade(self):
        msg = 'upgrading packages'
        verbose(dryrun_msg(msg))

        # log the upgrade action ...
        # don't know which packages are upgraded here, sorry
        log(msg)
开发者ID:Linuxtester,项目名称:synctool,代码行数:7,代码来源:pkgclass.py

示例3: create

    def create(self):
        '''make a fifo'''

        verbose(dryrun_msg('  os.mkfifo(%s)' % self.name))
        unix_out('mkfifo %s' % self.name)
        terse(synctool.lib.TERSE_NEW, self.name)
        if not synctool.lib.DRY_RUN:
            try:
                os.mkfifo(self.name, self.stat.mode & 0777)
            except OSError as err:
                error('failed to create fifo %s : %s' % (self.name,
                                                         err.strerror))
                terse(TERSE_FAIL, 'fifo %s' % self.name)
开发者ID:afghanistanyn,项目名称:synctool,代码行数:13,代码来源:object.py

示例4: set_owner

    def set_owner(self):
        '''set ownership equal to source'''

        verbose(dryrun_msg('  os.chown(%s, %d, %d)' %
                           (self.name, self.stat.uid, self.stat.gid)))
        unix_out('chown %s.%s %s' % (self.stat.ascii_uid(),
                                     self.stat.ascii_gid(), self.name))
        if not synctool.lib.DRY_RUN:
            try:
                os.chown(self.name, self.stat.uid, self.stat.gid)
            except OSError as err:
                error('failed to chown %s.%s %s : %s' %
                      (self.stat.ascii_uid(), self.stat.ascii_gid(),
                       self.name, err.strerror))
                terse(synctool.lib.TERSE_FAIL, 'owner %s' % self.name)
开发者ID:dot-Sean,项目名称:synctool,代码行数:15,代码来源:object.py

示例5: move_saved

    def move_saved(self):
        '''move existing entry to .saved'''

        verbose(dryrun_msg('saving %s as %s.saved' % (self.name, self.name)))
        unix_out('mv %s %s.saved' % (self.name, self.name))

        if not synctool.lib.DRY_RUN:
            verbose('  os.rename(%s, %s.saved)' % (self.name, self.name))
            try:
                os.rename(self.name, '%s.saved' % self.name)
            except OSError as err:
                stderr('failed to save %s as %s.saved : %s' % (self.name,
                                                               self.name,
                                                               err.strerror))
                terse(synctool.lib.TERSE_FAIL, 'save %s.saved' % self.name)
开发者ID:dineshbhoopathy,项目名称:synctool,代码行数:15,代码来源:object.py

示例6: set_times

    def set_times(self):
        '''set access and modification times'''

        # only mtime is shown
        verbose(dryrun_msg('  os.utime(%s, %s)' %
                           (self.name, print_timestamp(self.stat.mtime))))
        # print timestamp in other format
        dt = datetime.datetime.fromtimestamp(self.stat.mtime)
        time_str = dt.strftime('%Y%m%d%H%M.%S')
        unix_out('touch -t %s %s' % (time_str, self.name))
        if not synctool.lib.DRY_RUN:
            try:
                os.utime(self.name, (self.stat.atime, self.stat.mtime))
            except OSError as err:
                error('failed to set utime on %s : %s' % (self.name,
                                                          err.strerror))
                terse(TERSE_FAIL, 'utime %s' % self.name)
开发者ID:afghanistanyn,项目名称:synctool,代码行数:17,代码来源:object.py

示例7: check_purge_timestamp

    def check_purge_timestamp(self):
        '''check timestamp between src and dest
        Returns True if same, False if not
        '''

        # This is only used for purge/
        # check() has already determined that the files are the same
        # Now only check the timestamp ...
        # FIXME have SyncStat time fields
        # Note that SyncStat objects do not know the timestamps;
        # they are not cached only to save memory
        # So now we have to os.stat() again to get the times; it is
        # not a big problem because this func is used for purge_single only

        # src_path is under $purge/
        # dest_path is in the filesystem

        try:
            src_stat = os.lstat(self.src_path)
        except OSError as err:
            error('stat(%s) failed: %s' % (self.src_path, err.strerror))
            return False

        try:
            dest_stat = os.lstat(self.dest_path)
        except OSError as err:
            error('stat(%s) failed: %s' % (self.dest_path, err.strerror))
            return False

        # FIXME set_times() should not be called for symlinks
        if src_stat.st_mtime > dest_stat.st_mtime:
            stdout('%s mismatch (only timestamp)' % self.dest_path)
            terse(synctool.lib.TERSE_WARNING,
                  '%s (only timestamp)' % self.dest_path)

            verbose(dryrun_msg('  os.utime(%s, %s)'
                               '' % (self.dest_path,
                                     time.ctime(src_stat.st_mtime))))
            unix_out('touch -r %s %s' % (self.src_path, self.dest_path))

            vnode = self.vnode_obj()
            vnode.set_times(src_stat.st_atime, src_stat.st_mtime)
            return False

        return True
开发者ID:dot-Sean,项目名称:synctool,代码行数:45,代码来源:object.py

示例8: create

    def create(self):
        # type: () -> None
        '''make a character device file'''

        major = os.major(self.src_stat.st_rdev)         # type: ignore
        minor = os.minor(self.src_stat.st_rdev)         # type: ignore
        verbose(dryrun_msg('  os.mknod(%s, CHR %d,%d)' % (self.name, major,
                                                          minor)))
        unix_out('mknod %s c %d %d' % (self.name, major, minor))
        terse(synctool.lib.TERSE_NEW, self.name)
        if not synctool.lib.DRY_RUN:
            try:
                os.mknod(self.name,
                         (self.src_stat.st_mode & 0777) | stat.S_IFCHR,
                         os.makedev(major, minor))
            except OSError as err:
                error('failed to create device %s : %s' % (self.name,
                                                           err.strerror))
                terse(TERSE_FAIL, 'device %s' % self.name)
开发者ID:walterdejong,项目名称:synctool,代码行数:19,代码来源:object.py

示例9: move_saved

    def move_saved(self):
        '''move existing entry to .saved'''

        # do not save files that already are .saved
        _, ext = os.path.splitext(self.name)
        if ext == '.saved':
            return

        verbose(dryrun_msg('saving %s as %s.saved' % (self.name, self.name)))
        unix_out('mv %s %s.saved' % (self.name, self.name))

        if not synctool.lib.DRY_RUN:
            verbose('  os.rename(%s, %s.saved)' % (self.name, self.name))
            try:
                os.rename(self.name, '%s.saved' % self.name)
            except OSError as err:
                error('failed to save %s as %s.saved : %s' % (self.name,
                                                              self.name,
                                                              err.strerror))
                terse(synctool.lib.TERSE_FAIL, 'save %s.saved' % self.name)
开发者ID:dot-Sean,项目名称:synctool,代码行数:20,代码来源:object.py


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