diff --git a/bin/srv.py b/bin/srv.py index e55fb46..ce646aa 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -6,7 +6,7 @@ Main server program. """ from __future__ import print_function -from gevent.wsgi import WSGIServer +from gevent.pywsgi import WSGIServer from gevent.monkey import patch_all patch_all() @@ -204,5 +204,5 @@ def answer(topic=None): return result return Response(result, mimetype='text/plain') -SRV = WSGIServer(("", 8002), app) # log=None) +SRV = WSGIServer(("0.0.0.0", 8002), app) # log=None) SRV.serve_forever() diff --git a/get-sheets.sh b/get-sheets.sh new file mode 100644 index 0000000..7145e54 --- /dev/null +++ b/get-sheets.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +## this doesn't error check, if it breaks and destroys things I'm sorry + +mkdir cheatsheets +cd cheatsheets +mkdir cheat tldr spool +git clone --recursive https://github.com/adambard/learnxinyminutes-docs +git clone --recursive https://github.com/chrisallenlane/cheat cheat-temp +mv cheat-temp/cheat/cheatsheets/* cheat +rm -rf cheat-temp +git clone --recursive http://github.com/tldr-pages/tldr tldr-temp +mv tldr-temp/pages/* tldr +rm -rf tldr-temp +git clone --recursive https://github.com/chubin/cheat.sheets.git +mv cheat.sheets/sheets . \ No newline at end of file diff --git a/lib/adapter_learnxiny.py b/lib/adapter_learnxiny.py index cd85426..eeb7ffc 100644 --- a/lib/adapter_learnxiny.py +++ b/lib/adapter_learnxiny.py @@ -5,6 +5,7 @@ from __future__ import print_function import os import re +from globals import MYDIR class LearnXYAdapter(object): @@ -12,7 +13,7 @@ class LearnXYAdapter(object): Parent class of all languages adapters """ - _learn_xy_path = "/home/igor/git/github.com/adambard/learnxinyminutes-docs" + _learn_xy_path = os.path.join(MYDIR, "cheatsheets/learnxinyminutes-docs") _replace_with = {} _filename = '' prefix = '' diff --git a/lib/get_answer.py b/lib/get_answer.py index 291ea0c..e4363cf 100644 --- a/lib/get_answer.py +++ b/lib/get_answer.py @@ -311,7 +311,7 @@ def _get_answer_for_question(topic): else: topic = [topic] - cmd = ["/home/igor/cheat.sh/bin/get-answer-for-question"] + topic + cmd = [os.path.join(MYDIR, "bin/get-answer-for-question")] + topic proc = Popen(cmd, stdout=PIPE, stderr=PIPE) answer = proc.communicate()[0].decode('utf-8') return answer diff --git a/lib/globals.py b/lib/globals.py index 5443e09..4cbcaef 100644 --- a/lib/globals.py +++ b/lib/globals.py @@ -18,10 +18,17 @@ TEMPLATES = os.path.join(MYDIR, 'share/templates') STATIC = os.path.join(MYDIR, 'share/static') PATH_VIM_ENVIRONMENT = os.path.join(MYDIR, 'share/vim') -PATH_TLDR_PAGES = "/home/igor/.tldr/cache/pages/*/*.md" -PATH_CHEAT_PAGES = "/usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/*" -PATH_CHEAT_SHEETS = "/home/igor/cheat.sheets/sheets/" -PATH_CHEAT_SHEETS_SPOOL = "/home/igor/cheat.sheets/spool/" +USE_OS_PACKAGES = True # change it False if you pull cheat sheets repositories from GitHub +if USE_OS_PACKAGES: + PATH_TLDR_PAGES = "/home/igor/.tldr/cache/pages/*/*.md" + PATH_CHEAT_PAGES = "/usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/*" + PATH_CHEAT_SHEETS = "/home/igor/cheat.sheets/sheets/" + PATH_CHEAT_SHEETS_SPOOL = "/home/igor/cheat.sheets/spool/" +else: + PATH_TLDR_PAGES = os.path.join(MYDIR, "cheatsheets/tldr/*/*.md") + PATH_CHEAT_PAGES = os.path.join(MYDIR, "cheatsheets/cheat/*") + PATH_CHEAT_SHEETS = os.path.join(MYDIR, "cheatsheets/sheets/") + PATH_CHEAT_SHEETS_SPOOL = os.path.join(MYDIR, "cheatsheets/spool/") COLOR_STYLES = sorted(list(get_all_styles())) diff --git a/lib/panela/panela_colors.py b/lib/panela/panela_colors.py index 4c1eaa2..ad5cd76 100644 --- a/lib/panela/panela_colors.py +++ b/lib/panela/panela_colors.py @@ -3,6 +3,7 @@ import sys import colored import itertools +from globals import MYDIR """ @@ -632,8 +633,9 @@ class Template(object): def main(): "Only for experiments" + pagepath = os.join.path(MYDIR, "share/firstpage-v2.pnl") template = Template() - template.read("/home/igor/cheat.sh/share/firstpage-v2.pnl") + template.read(pagepath) template.apply_mask() sys.stdout.write(template.show()) diff --git a/requirements.txt b/requirements.txt index 4308ef7..4e2da03 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,6 @@ fuzzywuzzy redis colored langdetect +cffi +polyglot +colorama \ No newline at end of file