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


Python Sync.setLocalDir方法代码示例

本文整理汇总了Python中sync.Sync.setLocalDir方法的典型用法代码示例。如果您正苦于以下问题:Python Sync.setLocalDir方法的具体用法?Python Sync.setLocalDir怎么用?Python Sync.setLocalDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sync.Sync的用法示例。


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

示例1: SyncWindow

# 需要导入模块: from sync import Sync [as 别名]
# 或者: from sync.Sync import setLocalDir [as 别名]

#.........这里部分代码省略.........
    
        QApplication.instance().lastWindowClosed.connect(self.syncThread.quit)
        self.loginRequested.emit(username, passwd)

    @Slot(bool, str)
    def onLoginCompleted(self, ok, msg):
        if not ok:
            self.showMessageBox(msg)
            self.failedLogIn.emit()

        else:
            self.syncView()
                
    @Slot()
    def onFileEventCompleted(self):
        # Workaround because there's an exception
        # when there's a file IO error
        # Ideally it should be managed elsewhere
        # But I don't know the code intimately enough yet.
        try:
          self.currentFile
        except AttributeError:
          self.currentFile = ''
        
        self.statusChanged.emit('Completed', self.currentFile, 100)

    @Slot(str)
    def onSync(self, localdir):
        """
        Slot. Triggers a server checkout.
        
        :param localdir: Absolute local directory path where to keep the files
        """
        self.sync.setLocalDir(localdir)
        self.sync.local.ioError.connect(self.onIOError)
        self.syncStarted.emit()
        self.setStatus('Syncing')
    
    def showMessageBox(self, msg):
        warning = QMessageBox(self)
        warning.setFont(View.labelsFont())
        warning.setStyleSheet('QMessageBox {background: white}')
        warning.setWindowTitle("Error")
        warning.setText(msg)
        warning.setIcon(QMessageBox.Warning)
        warning.addButton("Ok", QMessageBox.AcceptRole).setFont(View.editsFont())
        warning.exec_()
            
        
    @Slot(int, int)
    def onProgress(self, action, total, progress):
        """
        Slot. Triggers download progress update in the UI.
        
        :param total: Total size of the download in bytes
        :param progress: Current downdload progress in bytes
        """
        
        if progress <= 0:
            return
        else:
            percent = (progress * 100) / total
            self.statusChanged.emit(action, self.currentFile, percent)
        
    @Slot(str)
    def setStatus(self, msg):
开发者ID:ShareByLink,项目名称:iqbox-ftp,代码行数:70,代码来源:window.py


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