def getAbsolutePath(self, filename, mustExist=True): """ Returns the absolute path of the given filename in the correct upload folder. Ensures that the file <ul> <li>has any of the extensions listed in SUPPORTED_EXTENSIONS</li> <li>exists and is a file (not a directory) if "mustExist" is set to True</li> </ul> @param filename the name of the file for which to determine the absolute path @param mustExist if set to true, the method also checks if the file exists and is a file @return the absolute path of the file or None if the file is not valid """ filename = self._getBasicFilename(filename) if not util.isAllowedFile(filename.lower(), set(self.SUPPORTED_EXTENSIONS)): return None # TODO: detect which type of file and add in the extra folder portion secure = os.path.join(self._uploadFolder, secure_filename(self._getBasicFilename(filename))) if mustExist and (not os.path.exists(secure) or not os.path.isfile(secure)): return None return secure
def deleteTimelapse(filename): if util.isAllowedFile(filename, {"mpg"}): secure = os.path.join(settings().getBaseFolder("timelapse"), secure_filename(filename)) if os.path.exists(secure): os.remove(secure) return getTimelapseData()
def getAbsolutePath(self, filename, mustExist=True): """ Returns the absolute path of the given filename in the correct upload folder. Ensures that the file <ul> <li>has any of the extensions listed in SUPPORTED_EXTENSIONS</li> <li>exists and is a file (not a directory) if "mustExist" is set to True</li> </ul> @param filename the name of the file for which to determine the absolute path @param mustExist if set to true, the method also checks if the file exists and is a file @return the absolute path of the file or None if the file is not valid """ filename = self._getBasicFilename(filename) if not util.isAllowedFile(filename.lower(), set(self.SUPPORTED_EXTENSIONS)): return None # TODO: detect which type of file and add in the extra folder portion secure = os.path.join( self._uploadFolder, secure_filename(self._getBasicFilename(filename))) if mustExist and (not os.path.exists(secure) or not os.path.isfile(secure)): return None return secure
def getAbsolutePath(self, filename, mustExist=True): """ Returns the absolute path of the given filename in the gcode upload folder. Ensures that the file <ul> <li>has the extension ".gcode"</li> <li>exists and is a file (not a directory) if "mustExist" is set to True</li> </ul> @param filename the name of the file for which to determine the absolute path @param mustExist if set to true, the method also checks if the file exists and is a file @return the absolute path of the file or None if the file is not valid """ filename = self._getBasicFilename(filename) if not util.isAllowedFile(filename, set(["gcode"])): return None secure = os.path.join( self._uploadFolder, secure_filename(self._getBasicFilename(filename))) if mustExist and (not os.path.exists(secure) or not os.path.isfile(secure)): return None return secure
def deleteTimelapse(filename): if util.isAllowedFile(filename, {"mpg"}): timelapse_folder = settings().getBaseFolder("timelapse") full_path = os.path.realpath(os.path.join(timelapse_folder, filename)) if full_path.startswith(timelapse_folder) and os.path.exists(full_path): os.remove(full_path) return getTimelapseData()
def deleteTimelapse(filename): if util.isAllowedFile(filename, {"mpg"}): secure = os.path.join( settings.getpath("timelapse"), secure_filename(filename)) if os.path.exists(secure): os.remove(secure) return getTimelapseData()
def getAbsolutePath(self, filename, mustExist=True): """ Returns the absolute path of the given filename in the gcode upload folder. Ensures that the file <ul> <li>has the extension ".gcode"</li> <li>exists and is a file (not a directory) if "mustExist" is set to True</li> </ul> @param filename the name of the file for which to determine the absolute path @param mustExist if set to true, the method also checks if the file exists and is a file @return the absolute path of the file or None if the file is not valid """ filename = self._getBasicFilename(filename) if not util.isAllowedFile(filename, set(["gcode"])): return None secure = os.path.join(self._uploadFolder, secure_filename(self._getBasicFilename(filename))) if mustExist and (not os.path.exists(secure) or not os.path.isfile(secure)): return None return secure
def deleteTimelapse(filename): if util.isAllowedFile(filename, set(["mpg"])): secure = os.path.join(settings().getBaseFolder("timelapse"), secure_filename(filename)) if os.path.exists(secure): os.remove(secure) return getTimelapseData()
def downloadTimelapse(filename): if util.isAllowedFile(filename, set(["mpg"])): return send_from_directory(settings().getBaseFolder("timelapse"), filename, as_attachment=True)