Commit b0c36401956182207b3adaf7e87bfd3f9d9863d3
1 parent
d2d98e81
Exists in
master
and in
1 other branch
- disabled FileHandler because its not working
Showing
4 changed files
with
40 additions
and
32 deletions
Show diff stats
BUGS.md
1 | 1 | |
2 | 2 | # BUGS |
3 | 3 | |
4 | -- upgrade para tornado 5.0. | |
5 | -- servir imagens das perguntas | |
4 | +- servir imagens das perguntas não funciona. Necessario passar a ref da pergunta no link para poder ajustar o path no FileHandler | |
6 | 5 | - o eventloop está a bloquear. correção do teste é blocking. usar threadpoolexecutor? |
7 | 6 | - se submissão falhar (aluno desconectado da rede) nao pode sair da página para nao perder o teste. possiveis solucoes: |
8 | 7 | - botao submeter valida se esta online com um post willing_to_submit, se estiver online, mostra mensagem de confirmacao, caso contrario avisa que nao esta online. |
... | ... | @@ -46,6 +45,7 @@ |
46 | 45 | |
47 | 46 | # FIXED |
48 | 47 | |
48 | +- upgrade para tornado 5.0. | |
49 | 49 | - ctrl-c should ask for confirmation before exiting. |
50 | 50 | - md_to_html() nao usa o segundo argumento q. pode retirar-se dos templates? |
51 | 51 | - config/logger.yaml ainda é do cherrypy... | ... | ... |
serve.py
... | ... | @@ -88,7 +88,6 @@ class LoginHandler(BaseHandler): |
88 | 88 | class LogoutHandler(BaseHandler): |
89 | 89 | @tornado.web.authenticated |
90 | 90 | def get(self): |
91 | - # self.testapp.logout(self.current_user) | |
92 | 91 | self.clear_cookie('user') |
93 | 92 | self.redirect('/') |
94 | 93 | |
... | ... | @@ -104,36 +103,45 @@ class FileHandler(BaseHandler): |
104 | 103 | chunk_size = 4 * 1024 * 1024 # serve up to 4 MiB multiple times |
105 | 104 | |
106 | 105 | @tornado.web.authenticated |
107 | - async def get(self, filename): | |
106 | + def get(self, filename): | |
108 | 107 | uid = self.current_user |
109 | - # public_dir = self.learn.get_current_public_dir(uid) | |
110 | - filepath = path.expanduser(path.join(public_dir, filename)) | |
108 | + # ref = self.get_query_argument('ref') | |
109 | + # print(ref) | |
110 | + # questions_path = self.testapp.get_questions_path() | |
111 | + # p = path.join(questions_path, ref, 'public', filename) | |
112 | + # print(p) | |
113 | + logging.error(f'{uid} requested file but FileHandler is not working!!!') | |
114 | + self.write('image') | |
111 | 115 | |
112 | - try: | |
113 | - f = open(filepath, 'rb') | |
114 | - except FileNotFoundError: | |
115 | - logging.error(f'File not found: {filepath}') | |
116 | - except PermissionError: | |
117 | - logging.error(f'No permission: {filepath}') | |
118 | - else: | |
119 | - content_type = mimetypes.guess_type(filename) | |
120 | - self.set_header("Content-Type", content_type[0]) | |
121 | 116 | |
122 | - # divide the file into chunks and write one chunk at a time, so | |
123 | - # that the write does not block the ioloop for very long. | |
124 | - with f: | |
125 | - chunk = f.read(self.chunk_size) | |
126 | - while chunk: | |
127 | - try: | |
128 | - self.write(chunk) # write the cunk to response | |
129 | - await self.flush() # flush the current chunk to socket | |
130 | - except iostream.StreamClosedError: | |
131 | - break # client closed the connection | |
132 | - finally: | |
133 | - del chunk | |
134 | - await gen.sleep(0.000000001) # 1 nanosecond (hack) | |
135 | - # FIXME in the upcomming tornado 5.0 use `await asyncio.sleep(0)` instead | |
136 | - chunk = f.read(self.chunk_size) | |
117 | + # # public_dir = self.learn.get_current_public_dir(uid) | |
118 | + # filepath = path.expanduser(path.join(public_dir, filename)) | |
119 | + | |
120 | + # try: | |
121 | + # f = open(filepath, 'rb') | |
122 | + # except FileNotFoundError: | |
123 | + # logging.error(f'File not found: {filepath}') | |
124 | + # except PermissionError: | |
125 | + # logging.error(f'No permission: {filepath}') | |
126 | + # else: | |
127 | + # content_type = mimetypes.guess_type(filename) | |
128 | + # self.set_header("Content-Type", content_type[0]) | |
129 | + | |
130 | + # # divide the file into chunks and write one chunk at a time, so | |
131 | + # # that the write does not block the ioloop for very long. | |
132 | + # with f: | |
133 | + # chunk = f.read(self.chunk_size) | |
134 | + # while chunk: | |
135 | + # try: | |
136 | + # self.write(chunk) # write the cunk to response | |
137 | + # await self.flush() # flush the current chunk to socket | |
138 | + # except iostream.StreamClosedError: | |
139 | + # break # client closed the connection | |
140 | + # finally: | |
141 | + # del chunk | |
142 | + # await gen.sleep(0.000000001) # 1 nanosecond (hack) | |
143 | + # # FIXME in the upcomming tornado 5.0 use `await asyncio.sleep(0)` instead | |
144 | + # chunk = f.read(self.chunk_size) | |
137 | 145 | # ------------------------------------------------------------------------- |
138 | 146 | # FIXME checkit |
139 | 147 | # class FileHandler(BaseHandler): | ... | ... |
templates/question.html
tools.py
... | ... | @@ -128,7 +128,7 @@ class HighlightRenderer(mistune.Renderer): |
128 | 128 | |
129 | 129 | markdown = MarkdownWithMath(HighlightRenderer(escape=True)) # hard_wrap=True to insert <br> on newline |
130 | 130 | |
131 | -def md_to_html(text, q=None): | |
131 | +def md_to_html(text): | |
132 | 132 | return markdown(text) |
133 | 133 | |
134 | 134 | # --------------------------------------------------------------------------- | ... | ... |