def getFolderContents(self, folder, sendResponse): if folder == '/': sendResponse({ 'folderContents': externalDriveManager().getRemovableDrives() }) else: folderSearchStr = "%s/*" % folder sendResponse({ 'folderContents': externalDriveManager().getFolderContents( folderSearchStr.replace('//', '/')) })
def eject(self, data, sendResponse): ejection = externalDriveManager().eject(data['drive']) if ejection['result']: sendResponse({'success': 'no error'}) else: sendResponse(ejection['error'], True)
def copyFileToLocal(self, data, sendResponse): copiedFilename = externalDriveManager().copyFileToLocal( data['origin'], data['destination'], data['observerId']) if copiedFilename: sendResponse({'target_filename': copiedFilename}) else: sendResponse({'error': 'copy print file to local folder failed'}, True)
def folderContents(): location = request.args.get('location') externalDriveMgr = externalDriveManager() if location == '/': return jsonify(externalDriveMgr.getRemovableDrives()) else: return jsonify(externalDriveMgr.getFolderContents("%s/*" % location))
def localFileExists(self, data, sendResponse): if not externalDriveManager().localFileExists(data['filename']): sendResponse({'success': 'no_error'}) else: sendResponse({'error': 'local file already exists'}, True)
def getBaseFolder(self, key, sendResponse): sendResponse({'baseFolder': externalDriveManager().getBaseFolder(key)})
def getFileBrowsingExtensions(self, sendResponse): sendResponse({ 'fileBrowsingExtensions': externalDriveManager().getFileBrowsingExtensions() })
def copyFileToLocal(): externalDriveMgr = externalDriveManager() return jsonify({'filename': externalDriveMgr.copyFileToLocal(request.values.get('file'),externalDriveMgr.getBaseFolder('uploads'),request.values.get('observerId'))})
def localFileExists(filename): return jsonify({'response': externalDriveManager().localFileExists(filename)})
def eject(): return jsonify(externalDriveManager().eject(request.values.get('drive')))
def getRemovableDrives(): return jsonify([d["name"] for d in externalDriveManager().getRemovableDrives()])
def getFileBrowsingExtensions(): return jsonify(externalDriveManager().getFileBrowsingExtensions())