本文整理汇总了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):