示例#1
0
    def _POST(self, *param, **params):
        if not validates_icon(self):
            self.logger.debug("Create Icon is failed, Invalid input value")
            return web.badrequest(add_prefix(self.view.alert, "400"))

        icon_filevalue = self.input.multi_icon.value
        icon_filename = "%s.%s" % (uniq_filename(),
                                   imghdr.what(None, icon_filevalue))

        if is_path(icon_filename) is True:
            return web.badrequest("Not to include the path.")

        icon_realpath = ICON_DIR_TPL % (karesansui.dirname, icon_filename)
        icon_webpath = ICON_DIR_TPL % (web.ctx.homepath, icon_filename)

        if os.path.exists(icon_realpath):
            web.conflict(icon_webpath, add_prefix("icon already exists",
                                                  "409"))

        try:
            create_file(icon_realpath, icon_filevalue)
        except IOError, ioe:
            self.logger.error("Failed to write icon file. - filename=%s" %
                              icon_filename)
            return web.internalerror(
                add_prefix("Failed to create icon file.", "500"))
示例#2
0
文件: icon.py 项目: goura/karesansui
    def _DELETE(self, *param, **params):
        icon_filename = param[0]
        if is_path(icon_filename) is True:
            return web.badrequest("Not to include the path.")

        icon_realpath = ICON_DIR_TPL % (karesansui.dirname, icon_filename)

        if not os.path.exists(icon_realpath):
            return web.notfound("icon not exists")

        try:
            remove_file(icon_realpath)
        except OSError, ose:
            self.logger.error("Failed to remove icon file. - filename=%s" % icon_filename)
            raise  # return 500(Internal Server Error)
示例#3
0
    def _DELETE(self, *param, **params):
        icon_filename = param[0]
        if is_path(icon_filename) is True:
            return web.badrequest("Not to include the path.")

        icon_realpath = ICON_DIR_TPL % (karesansui.dirname, icon_filename)

        if not os.path.exists(icon_realpath):
            return web.notfound("icon not exists")

        try:
            remove_file(icon_realpath)
        except OSError, ose:
            self.logger.error("Failed to remove icon file. - filename=%s" %
                              icon_filename)
            raise  # return 500(Internal Server Error)
示例#4
0
文件: icon.py 项目: goura/karesansui
    def _POST(self, *param, **params):
        if not validates_icon(self):
            self.logger.debug("Create Icon is failed, Invalid input value")
            return web.badrequest(add_prefix(self.view.alert, "400"))

        icon_filevalue = self.input.multi_icon.value
        icon_filename = "%s.%s" % (uniq_filename(), imghdr.what(None, icon_filevalue))

        if is_path(icon_filename) is True:
            return web.badrequest("Not to include the path.")

        icon_realpath = ICON_DIR_TPL % (karesansui.dirname, icon_filename)
        icon_webpath = ICON_DIR_TPL % (web.ctx.homepath, icon_filename)

        if os.path.exists(icon_realpath):
            web.conflict(icon_webpath, add_prefix("icon already exists", "409"))

        try:
            create_file(icon_realpath, icon_filevalue)
        except IOError, ioe:
            self.logger.error("Failed to write icon file. - filename=%s" % icon_filename)
            return web.internalerror(add_prefix("Failed to create icon file.", "500"))