示例#1
0
文件: ui.py 项目: salsa-dev/MiGBox
 def _mount(self):
     host = _vars["Connection"]["sftp_host"] 
     port = _vars["Connection"]["sftp_port"]
     port = int(port) if port else 0
     userkey = _vars["KeyAuth"]["userkey"]
     mountpath = _vars["Mount"]["mountpath"]
     if not self.isMount:
         if not os.path.isdir(mountpath):
             msgBox = QMessageBox.warning(self, "MiGBox - Mount",
                 "Not a valid mount path.", QMessageBox.Ok)
         try:
             mount(host, port, userkey, mountpath)
             self.dstFsModel = QFileSystemModel(self.dstTreeView)
             self.dstFsModel.setRootPath(mountpath)
             self.dstTreeView.setModel(self.dstFsModel)
             self.dstTreeView.setRootIndex(self.dstFsModel.index(mountpath))
             self.mountAction.setIcon(QIcon(os.path.join(self.icons_path, "unmount.png")))
             self.mountAction.setToolTip(QString("Unmount sftp sync folder"))
             self.tabs.setTabEnabled(2, True)
             self.isMount = True
         except Exception as e:
             msgBox = QMessageBox(self)
             msgBox.setWindowTitle("MiGBox - SFTP Mount Error")
             msgBox.setText("Could not mount via SFTP.")
             msgBox.setDetailedText(e.message)
             msgBox.exec_()
     else:
         unmount(mountpath)
         self.tabs.setTabEnabled(2, False)
         self.mountAction.setIcon(QIcon(os.path.join(self.icons_path, "mount.png")))
         self.mountAction.setToolTip(QString("Mount sftp sync folder"))
         self.isMount = False
示例#2
0
文件: ui.py 项目: bertl4398/MiGBox
 def _mount(self):
     host = _vars["Connection"]["sftp_host"] 
     port = _vars["Connection"]["sftp_port"]
     port = int(port) if port else 0
     userkey = _vars["KeyAuth"]["userkey"]
     mountpath = _vars["Mount"]["mountpath"]
     if not self.isMount:
         if not os.path.isdir(mountpath):
             msgBox = QMessageBox.warning(self, "MiGBox - Mount",
                 "Not a valid mount path.", QMessageBox.Ok)
         try:
             mount(host, port, userkey, mountpath)
             self.dstFsModel = QFileSystemModel(self.dstTreeView)
             self.dstFsModel.setRootPath(mountpath)
             self.dstTreeView.setModel(self.dstFsModel)
             self.dstTreeView.setRootIndex(self.dstFsModel.index(mountpath))
             self.mountAction.setIcon(QIcon(os.path.join(self.icons_path, "unmount.png")))
             self.mountAction.setToolTip(QString("Unmount sftp sync folder"))
             self.tabs.setTabEnabled(2, True)
             self.isMount = True
         except Exception as e:
             msgBox = QMessageBox(self)
             msgBox.setWindowTitle("MiGBox - SFTP Mount Error")
             msgBox.setText("Could not mount via SFTP.")
             msgBox.setDetailedText(e.message)
             msgBox.exec_()
     else:
         unmount(mountpath)
         self.tabs.setTabEnabled(2, False)
         self.mountAction.setIcon(QIcon(os.path.join(self.icons_path, "mount.png")))
         self.mountAction.setToolTip(QString("Mount sftp sync folder"))
         self.isMount = False
示例#3
0
文件: cli.py 项目: bertl4398/MiGBox
def run(mode, source, destination, sftp_host, sftp_port,
        hostkey, userkey, mountpath, logfile=None, loglevel='INFO'):

    event = threading.Event()    
    thread = threading.Thread(target=syncd.run, args=(mode, source, destination,
                 sftp_host, sftp_port, hostkey, userkey, logfile, loglevel, event))

    print header
    running = True

    while running:
        in_ = raw_input("> ")
        if in_ == 'start':
            event.clear()
            thread.start()
        if in_ == 'stop':
            event.set()
            thread.join()
        if in_ == 'mount':
            p = mount(sftp_host, sftp_port, userkey, mountpath)
            if not p:
                print "SFTP mount not supported."
        if in_ == 'unmount':
            unmount(mountpath)
        if in_ == 'exit':
            event.set()
            running = False

    if thread.isAlive():
        thread.join()