Пример #1
0
    def OnBrowser(self, evt):
        # In this case we include a "New directory" button.
        dlg = wx.DirDialog(self, "Choose a directory:",
                          style=wx.DD_DEFAULT_STYLE
                           #| wx.DD_DIR_MUST_EXIST
                           #| wx.DD_CHANGE_DIR
                           )

        # If the user selects OK, then we process the dialog's data.
        # This is done by getting the path data from the dialog - BEFORE
        # we destroy it.
        add_path = ''
        if dlg.ShowModal() == wx.ID_OK:
            add_path = dlg.GetPath().replace('\\','/')
            self.scan_path.SetValue(add_path)

        # Only destroy a dialog after you're done with it.
        dlg.Destroy()

        if add_path:
            strSql = 'replace into folders(type, partpath, path, needScan, scanning) values(?,?,?,1,0)'
            SqliteFunc.execSql(strSql, ('all', UtilFunc.getDiskPath(add_path), add_path))
            ProfileFunc.addToLibrary(add_path, True, 'all', True)
            #ProfileFunc.getMainServer().scanFolderMoniter.setMediaFolder([{'folder':add_path,'type':'all'}],[])
            time.sleep(0.5)
            self.file_panels.showList()
Пример #2
0
    def run(self):
        dirName = self.dirPath
        hdir = win32file.CreateFile(
            dirName, GENERIC_READ | GENERIC_WRITE,
            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
            win32security.SECURITY_ATTRIBUTES(), OPEN_EXISTING,
            FILE_FLAG_BACKUP_SEMANTICS, 0)

        filter = FILE_NOTIFY_CHANGE_FILE_NAME | \
                        FILE_NOTIFY_CHANGE_DIR_NAME \
                        | FILE_NOTIFY_CHANGE_ATTRIBUTES | \
                        FILE_NOTIFY_CHANGE_LAST_WRITE | \
                        FILE_NOTIFY_CHANGE_SIZE

        win32Handle = win32file.FindFirstChangeNotification(
            dirName, True, filter)

        while UtilFunc.programIsRunning():
            results =  win32file.ReadDirectoryChangesW(
                hdir,
                819600,
                True,
                FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | \
                FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE | \
                FILE_NOTIFY_CHANGE_CREATION,
                #                FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_LAST_ACCESS |FILE_NOTIFY_CHANGE_SECURITY
                None,
                None
                )

            for action, file in results:
                path = file
                if path == 'Thumbs.db':
                    continue

                path = os.path.join(dirName, path)
                path = path.replace('\\', '/')
                if '/.popoCloud/' in path or os.path.basename(
                        path) == '.popoCloud':
                    continue


#                print str(action) + " " + path

                if action == 1 or action == 5:
                    if os.path.isdir(path):
                        ProfileFunc.addToLibrary(path)
                    else:
                        ProfileFunc.addFileCache(path)
                elif action == 2 or action == 4:
                    ProfileFunc.delFileCache(path)
                elif action == 3:
                    if not os.path.isdir(path):
                        ProfileFunc.delFileCache(path)
                        ProfileFunc.addFileCache(path)

            win32file.FindNextChangeNotification(win32Handle)
Пример #3
0
    def _add(self, folders, flag=False, type='all'):
        for subfolder in folders:
            subfolderdict = json.loads(subfolder)
            fullpath, type = subfolderdict['folder'], subfolderdict['type']
            need_scan_path = UtilFunc.getSiteRoot(fullpath)
            if flag:
                ProfileFunc._execSql(ProfileFunc.getConfDb(UtilFunc.getDiskPath(fullpath)),\
                        "replace into selectfolder(url) values(?)", (need_scan_path, ))

            if not self.stop_flag:
                ProfileFunc._execSql(
                    ProfileFunc.getConfDb(UtilFunc.getDiskPath(fullpath)),
                    'replace into \
                mediafolder(url, type) values(?, ?)', (
                        need_scan_path,
                        type,
                    ))
                ProfileFunc.addToLibrary(fullpath, flag, type)
            else:
                break