1
1
mirror of https://github.com/chubin/cheat.sh.git synced 2024-11-23 02:25:53 +03:00
Commit Graph

34 Commits

Author SHA1 Message Date
Anatoli Babenia
fec99a7a54 Properly setup Flask logging to stderr
Sometimes there is nothing, sometimes lines are duplicated.

Duplicated lines problem appears, because Python root logger
handler and Flask's `werkzeug` logger handler both write the
same message. `cheat.sh` is hit, because it sets this root
logging handler.

Normally `werkzeug` doesn't setup its own handler if it sees
that there are some handlers that process its messages. This
in case of `cheat.sh` resulted in no stderr logging at all.
No Exceptions either. Because `werkzeug` catches the
exceptions and logs them.

Hovewer, sometimes `werkzeug` starts too early, befora app
is imported (https://github.com/pallets/werkzeug/issues/1969)
and sets its logger anyway, before the app itself, resulting
in duplicating lines. In that case app root handler needs to
skip lines from `werkzeug`.

Kudos to @brandon-rhodes for `logging_tree` awesomeness
2020-11-17 13:38:16 +03:00
Anatoli Babenia
277b45e83c Decouple Flask app from gevent monkeypatching 2020-11-16 12:02:12 +03:00
Anatoli Babenia
8caed28b53 Use flask run server for debugging
Because at least live reloading doesn't seem to work with `gevent`
2020-11-04 07:48:54 +03:00
Anatoli Babenia
b74707a109 Redis doesn't need to be Strict
https://github.com/andymccurdy/redis-py#client-classes-redis-and-strictredis
2020-08-01 06:10:03 +03:00
Anatoli Babenia
fbe5414e9c Write log as binary file in Python 3
Fixes

      File "bin/srv.py", line 101, in log_query
        my_file.write(log_entry.encode('utf-8')+"\n")
    TypeError: can't concat str to bytes
2020-07-29 14:55:08 +03:00
Anatoli Babenia
c9a959f087 Add --debug option to server to log tracebacks on failures
podman build . -t cheat.sh
    podman run -it --rm -p 8002 cheat.sh bin/srv.py --debug

https://stackoverflow.com/questions/26026148/how-to-run-wsgiserver-in-verbose-or-debug-mode
2020-07-28 23:08:04 +03:00
Anatoli Babenia
b89e7196f4 Show server port on startup 2020-07-28 18:32:32 +03:00
Dario Vladovic
3344c49bf3
Implement cht.sh release script 2020-06-21 18:27:40 +02:00
Igor Chubin
8f78c783fe utf-8 workaround for python 2.x 2019-07-07 11:02:09 +00:00
Igor Chubin
e21f53d87b bin/srv.py: minor fix 2019-05-01 21:19:30 +02:00
Igor Chubin
d94ca8458f switched to new configuration interface 2019-05-01 20:48:05 +02:00
Igor Chubin
c59bdab2f2 cheat_wrapper.py splitted into fmt/ and frontend/ 2019-02-16 20:11:34 +01:00
Igor Chubin
b404a29e10 added initial support for multilingual answers 2019-01-31 00:36:14 +00:00
Igor Chubin
7dfbd50d95 debug starting mode (with env variables) 2019-01-31 00:32:09 +00:00
Igor Chubin
7771269f49 fvaicon.ico may be anywhere 2018-09-23 19:11:16 +00:00
Vadim Zhukov
5a84c230af User agents are "normalized" to lower case, so make it "openbsd ftp" instead. 2018-08-17 19:14:56 +03:00
Igor Chubin
9bccb17bb4 moved SERVER_ADDRESS and SERVER_PORT to globals.py 2018-08-16 19:27:58 +03:00
Vadim Zhukov
a8348037ac Add OpenBSD ftp(1) to the list of plaintext user agents. 2018-08-15 02:51:03 +03:00
Brandon Lopez
22953bb109 Can now build a Docker image of the app with cheatsheets pulled in at build time and use Docker Compose to get it running with Redis 2018-07-29 23:51:41 -07:00
Brandon Lopez
3e5641470a FIx srv.bin to work -- listens on 0.0.0.0 2018-07-27 16:16:05 -07:00
Igor Chubin
7cb4d9dedd return text/plain always for :cht.sh (fixes #46) 2018-07-15 08:30:43 +00:00
Igor Chubin
912e77faa3
Merge pull request #58 from md2perpe/fix-mydir
Fix incorrect MYDIR
2018-07-14 21:35:17 +02:00
Per Persson
251256d418 Fix incorrect MYDIR 2018-07-13 23:59:01 +02:00
Per Persson
b8ab35db77 Move 'not'
I think that this small change makes the code somewhat more readable.
Logic: not any([ b1, b2, b3, ... ]) == all([ not b1, not b2, not b3, ... ])
2018-07-13 21:33:08 +02:00
Per Persson
6f36a5a360 Simplify logic
if <condition>:
    return False
return True

is equivalent to

return not <condition>
2018-07-13 21:31:45 +02:00
Igor Chubin
4e288f9c88 use malformed-response.html instead of high load failure 2018-07-12 20:40:39 +00:00
cclauss
ae9004bff2 Modernize Python 2 code to get ready for Python 3 2018-07-03 22:09:51 +02:00
Igor Chubin
c08b67f46d initiall /:shell/ support 2018-07-03 10:32:22 +00:00
Igor Chubin
dc14962f91 stateful queries support (/:last) 2018-05-19 21:03:16 +00:00
Igor Chubin
26e102fc16 bin/srv.py cleanup 2018-05-05 12:50:24 +00:00
Igor Chubin
3efec3d0dd added new options: c, C, Q 2018-05-04 22:57:50 +00:00
Igor Chubin
6491bfbe70 decode utf-8 before logging 2017-06-02 15:47:18 +00:00
Igor Chubin
0609f0fb23 queries logging, github buttons, ?T and ?q 2017-05-26 09:17:39 +00:00
Igor Chubin
4fe6640ea4 initial prealpha version: added bin/ and lib/ 2017-05-08 21:21:19 +00:00