Permalink
Browse files

dj1.8 updates - prepare 2.0

  • Loading branch information...
mwolff44 committed Oct 14, 2016
1 parent d875f93 commit 911a57443620bcb355f5c62ac3c5417c00dc919c
Showing with 4,417 additions and 16,050 deletions.
  1. +73 −595 .gitignore
  2. 0 {customerportal/tests → config}/__init__.py
  3. 0 {pyfreebill/migrations → config/lib}/__init__.py
  4. +118 −0 config/lib/colorstreamhandler.py
  5. +1 −0 config/settings/__init__.py
  6. +383 −0 config/settings/base.py
  7. +82 −0 config/settings/local.py
  8. +1 −1 pyfreebilling/test_settings.py → config/settings/test.py
  9. +15 −4 {pyfreebilling → config}/urls.py
  10. +3 −3 {pyfreebilling → config}/wsgi.py
  11. 0 {doc → docs}/Makefile
  12. BIN {doc → docs}/build/doctrees/environment.pickle
  13. BIN {doc → docs}/build/doctrees/index.doctree
  14. 0 {doc → docs}/build/html/.buildinfo
  15. 0 {doc → docs}/build/html/_sources/index.txt
  16. BIN {doc → docs}/build/html/_static/ajax-loader.gif
  17. 0 {doc → docs}/build/html/_static/basic.css
  18. BIN {doc → docs}/build/html/_static/comment-bright.png
  19. BIN {doc → docs}/build/html/_static/comment-close.png
  20. BIN {doc → docs}/build/html/_static/comment.png
  21. 0 {doc → docs}/build/html/_static/default.css
  22. 0 {doc → docs}/build/html/_static/doctools.js
  23. BIN {doc → docs}/build/html/_static/down-pressed.png
  24. BIN {doc → docs}/build/html/_static/down.png
  25. BIN {doc → docs}/build/html/_static/file.png
  26. 0 {doc → docs}/build/html/_static/jquery.js
  27. BIN {doc → docs}/build/html/_static/minus.png
  28. BIN {doc → docs}/build/html/_static/plus.png
  29. 0 {doc → docs}/build/html/_static/pygments.css
  30. 0 {doc → docs}/build/html/_static/searchtools.js
  31. 0 {doc → docs}/build/html/_static/sidebar.js
  32. 0 {doc → docs}/build/html/_static/underscore.js
  33. BIN {doc → docs}/build/html/_static/up-pressed.png
  34. BIN {doc → docs}/build/html/_static/up.png
  35. 0 {doc → docs}/build/html/_static/websupport.js
  36. 0 {doc → docs}/build/html/genindex.html
  37. 0 {doc → docs}/build/html/index.html
  38. BIN {doc → docs}/build/html/objects.inv
  39. 0 {doc → docs}/build/html/search.html
  40. 0 {doc → docs}/build/html/searchindex.js
  41. 0 {doc → docs}/make.bat
  42. BIN {doc → docs}/source/_static/pyfreebilling-big.png
  43. BIN {doc → docs}/source/_static/pyfreebilling.png
  44. 0 {doc → docs}/source/_templates/layout.html
  45. 0 {doc → docs}/source/changelog.rst
  46. 0 {doc → docs}/source/conf.py
  47. 0 {doc → docs}/source/developer.rst
  48. 0 {doc → docs}/source/features.rst
  49. 0 {doc → docs}/source/index.rst
  50. 0 {doc → docs}/source/installation.rst
  51. 0 {doc → docs}/source/installation_freeswitch.rst
  52. 0 {doc → docs}/source/introduction.rst
  53. 0 {doc → docs}/source/license.rst
  54. 0 {doc → docs}/source/migration.rst
  55. +1 −1 manage.py
  56. 0 {pyfreebill/templatetags → pyfreebilling/apps}/__init__.py
  57. 0 { → pyfreebilling/apps}/customerportal/__init__.py
  58. +6 −0 pyfreebilling/apps/customerportal/apps.py
  59. 0 { → pyfreebilling/apps}/customerportal/forms.py
  60. 0 {switch/migrations → pyfreebilling/apps/customerportal/tests}/__init__.py
  61. 0 { → pyfreebilling/apps}/customerportal/tests/test.py
  62. 0 { → pyfreebilling/apps}/customerportal/urls.py
  63. +1 −1 { → pyfreebilling/apps}/customerportal/views.py
  64. 0 { → pyfreebilling/apps}/did/__init__.py
  65. 0 { → pyfreebilling/apps}/did/admin.py
  66. 0 { → pyfreebilling/apps}/did/admin/__init__.py
  67. +1 −1 { → pyfreebilling/apps}/did/admin/didAdmin.py
  68. 0 { → pyfreebilling/apps}/did/admin/ratesDidAdmin.py
  69. +6 −0 pyfreebilling/apps/did/apps.py
  70. 0 { → pyfreebilling/apps}/did/migrations/0001_initial.py
  71. 0 { → pyfreebilling/apps}/did/migrations/0002_auto_20161012_1448.py
  72. 0 { → pyfreebilling/apps}/did/migrations/__init__.py
  73. 0 { → pyfreebilling/apps}/did/models/__init__.py
  74. 0 { → pyfreebilling/apps}/did/models/did.py
  75. 0 { → pyfreebilling/apps}/did/models/ratesDid.py
  76. 0 { → pyfreebilling/apps}/did/models/routesDid.py
  77. 0 { → pyfreebilling/apps}/did/signals.py
  78. 0 { → pyfreebilling/apps}/did/tests.py
  79. 0 { → pyfreebilling/apps}/did/views.py
  80. 0 { → pyfreebilling/apps}/pyfreebill/__init__.py
  81. +1 −1 { → pyfreebilling/apps}/pyfreebill/admin.py
  82. 0 { → pyfreebilling/apps}/pyfreebill/admin_views.py
  83. +6 −0 pyfreebilling/apps/pyfreebill/apps.py
  84. 0 { → pyfreebilling/apps}/pyfreebill/base_modules.py
  85. 0 { → pyfreebilling/apps}/pyfreebill/fields.py
  86. 0 { → pyfreebilling/apps}/pyfreebill/fixtures/0001_fixtures_sipprofile.json
  87. 0 { → pyfreebilling/apps}/pyfreebill/fixtures/0001_initial_ReccurentTasks.json
  88. 0 { → pyfreebilling/apps}/pyfreebill/fixtures/0001_initial_SipProfile.json
  89. 0 { → pyfreebilling/apps}/pyfreebill/forms.py
  90. 0 { → pyfreebilling/apps}/pyfreebill/fsutil.py
  91. 0 { → pyfreebilling/apps}/pyfreebill/functions.py
  92. 0 { → pyfreebilling/apps}/pyfreebill/importer.py
  93. 0 { → pyfreebilling/apps}/pyfreebill/management/__init__.py
  94. 0 { → pyfreebilling/apps}/pyfreebill/management/commands/__init__.py
  95. 0 { → pyfreebilling/apps}/pyfreebill/management/commands/alertmessages.py
  96. 0 { → pyfreebilling/apps}/pyfreebill/management/commands/customstats.py
  97. 0 { → pyfreebilling/apps}/pyfreebill/management/commands/dailystats.py
  98. 0 { → pyfreebilling/apps}/pyfreebill/management/commands/dailystats.py.old
  99. 0 { → pyfreebilling/apps}/pyfreebill/management/commands/deleteoldcdr.py
  100. 0 { → pyfreebilling/apps}/pyfreebill/migrations/0001_initial.py
  101. 0 { → pyfreebilling/apps}/pyfreebill/migrations/0002_auto_20161012_1747.py
  102. 0 {switch/templatetags → pyfreebilling/apps/pyfreebill/migrations}/__init__.py
  103. +1 −1 { → pyfreebilling/apps}/pyfreebill/models.py
  104. 0 { → pyfreebilling/apps}/pyfreebill/modules.py
  105. 0 { → pyfreebilling/apps}/pyfreebill/reports.py
  106. 0 { → pyfreebilling/apps}/pyfreebill/resources.py
  107. 0 { → pyfreebilling/apps}/pyfreebill/tables.py
  108. 0 pyfreebilling/apps/pyfreebill/templatetags/__init__.py
  109. 0 { → pyfreebilling/apps}/pyfreebill/templatetags/admin_extras.py
  110. 0 { → pyfreebilling/apps}/pyfreebill/templatetags/dashboard_tags.py
  111. 0 { → pyfreebilling/apps}/pyfreebill/tests.py
  112. 0 { → pyfreebilling/apps}/pyfreebill/urls.py
  113. 0 { → pyfreebilling/apps}/pyfreebill/utils.py
  114. 0 { → pyfreebilling/apps}/pyfreebill/validators.py
  115. +1 −1 { → pyfreebilling/apps}/pyfreebill/views.py
  116. 0 { → pyfreebilling/apps}/switch/README.txt
  117. 0 { → pyfreebilling/apps}/switch/__init__.py
  118. 0 { → pyfreebilling/apps}/switch/admin.py
  119. 0 { → pyfreebilling/apps}/switch/admin/SwitchAdmin.py
  120. 0 { → pyfreebilling/apps}/switch/admin/__init__.py
  121. +6 −0 pyfreebilling/apps/switch/apps.py
  122. +9 −2 { → pyfreebilling/apps}/switch/esl.py
  123. +1 −0 { → pyfreebilling/apps}/switch/fields.py
  124. 0 { → pyfreebilling/apps}/switch/fixtures/0001_fixtures.json
  125. 0 { → pyfreebilling/apps}/switch/logger.py
  126. 0 { → pyfreebilling/apps}/switch/management/__init__.py
  127. 0 { → pyfreebilling/apps}/switch/management/commands/__init__.py
  128. 0 { → pyfreebilling/apps}/switch/migrations/0001_initial.py
  129. 0 pyfreebilling/apps/switch/migrations/__init__.py
  130. +3 −2 { → pyfreebilling/apps}/switch/models/Switch.py
  131. 0 { → pyfreebilling/apps}/switch/models/__init__.py
  132. 0 { → pyfreebilling/apps}/switch/psdash.py
  133. 0 pyfreebilling/apps/switch/templatetags/__init__.py
  134. 0 { → pyfreebilling/apps}/switch/templatetags/timestamp_to_time.py
  135. 0 { → pyfreebilling/apps}/switch/tests.py
  136. 0 { → pyfreebilling/apps}/switch/validators.py
  137. +1 −1 { → pyfreebilling/apps}/switch/views.py
  138. 0 pyfreebilling/extensions/__init__.py
  139. 0 pyfreebilling/fixtures/__init__.py
  140. BIN { → pyfreebilling}/locale/es/LC_MESSAGES/django.mo
  141. 0 { → pyfreebilling}/locale/es/LC_MESSAGES/django.po
  142. BIN { → pyfreebilling}/locale/fr_FR/LC_MESSAGES/django.mo
  143. 0 { → pyfreebilling}/locale/fr_FR/LC_MESSAGES/django.po
  144. BIN { → pyfreebilling}/locale/it/LC_MESSAGES/django.mo
  145. 0 { → pyfreebilling}/locale/it/LC_MESSAGES/django.po
  146. BIN { → pyfreebilling}/locale/pt_BR/LC_MESSAGES/django.mo
  147. 0 { → pyfreebilling}/locale/pt_BR/LC_MESSAGES/django.po
  148. BIN { → pyfreebilling}/locale/sq/LC_MESSAGES/django.mo
  149. 0 { → pyfreebilling}/locale/sq/LC_MESSAGES/django.po
  150. +0 −321 pyfreebilling/settings.py
  151. +0 −263 pyfreebilling/settings.py.origin
  152. +418 −0 pyfreebilling/static/css/bootstrap-datetimepicker.css
  153. +9 −0 pyfreebilling/static/css/bootstrap-tables2.css
  154. +418 −0 pyfreebilling/static/css/datetimepicker.css
  155. 0 { → pyfreebilling}/static/css/nv.d3.css
  156. +1,752 −0 pyfreebilling/static/js/bootstrap-datetimepicker.js
  157. 0 { → pyfreebilling}/static/js/d3.v3.js
  158. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ar.js
  159. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.bg.js
  160. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ca.js
  161. +19 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.cs.js
  162. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.da.js
  163. +18 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.de.js
  164. +18 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ee.js
  165. +15 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.el.js
  166. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.es.js
  167. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.fi.js
  168. +18 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.fr.js
  169. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.he.js
  170. +15 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.hr.js
  171. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.hu.js
  172. +15 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.id.js
  173. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.is.js
  174. +18 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.it.js
  175. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ja.js
  176. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ko.js
  177. +15 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.kr.js
  178. +18 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.lt.js
  179. +18 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.lv.js
  180. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ms.js
  181. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.nb.js
  182. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.nl.js
  183. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.no.js
  184. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.pl.js
  185. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.pt-BR.js
  186. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.pt.js
  187. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ro.js
  188. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.rs-latin.js
  189. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.rs.js
  190. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ru.js
  191. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.sk.js
  192. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.sl.js
  193. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.sv.js
  194. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.sw.js
  195. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.th.js
  196. +17 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.tr.js
  197. +15 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.ua.js
  198. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.uk.js
  199. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.zh-CN.js
  200. +16 −0 pyfreebilling/static/js/locales/bootstrap-datetimepicker.zh-TW.js
  201. 0 { → pyfreebilling}/static/js/nv.d3.min.js
  202. 0 { → pyfreebilling}/static/js/pfb.graphs.js
  203. +155 −0 pyfreebilling/templates/admin/_index.html
  204. 0 { → pyfreebilling}/templates/admin/admin_report.html
  205. 0 { → pyfreebilling}/templates/admin/admin_status.html
  206. 0 { → pyfreebilling}/templates/admin/customers_stats.html
  207. 0 { → pyfreebilling}/templates/admin/did/did/simple_import/import.html
  208. 0 { → pyfreebilling}/templates/admin/fs_status.html
  209. 0 { → pyfreebilling}/templates/admin/index.html
  210. 0 { → pyfreebilling}/templates/admin/list_models.html
  211. 0 { → pyfreebilling}/templates/admin/live_report.html
  212. 0 { → pyfreebilling}/templates/admin/pyfreebill/cdr/change_list.html
  213. 0 { → pyfreebilling}/templates/admin/pyfreebill/cdr/voip_report.html
  214. 0 { → pyfreebilling}/templates/admin/pyfreebill/company/change_form.html
  215. 0 { → pyfreebilling}/templates/admin/pyfreebill/customerdirectory/change_list.html
  216. 0 { → pyfreebilling}/templates/admin/pyfreebill/report.html
  217. 0 { → pyfreebilling}/templates/admin/pyfreebill/report.html.old
  218. 0 { → pyfreebilling}/templates/admin/pyfreebill/sofiagateway/change_list.html
  219. 0 { → pyfreebilling}/templates/admin/pyfreebill/stats/chart.html
  220. 0 { → pyfreebilling}/templates/admin/server_status.html
  221. 0 { → pyfreebilling}/templates/customer/404.html
  222. 0 { → pyfreebilling}/templates/customer/500.html
  223. 0 { → pyfreebilling}/templates/customer/balance.html
  224. 0 { → pyfreebilling}/templates/customer/base.html
  225. 0 { → pyfreebilling}/templates/customer/bootstrap3.html
  226. 0 { → pyfreebilling}/templates/customer/cdr_view.html
  227. 0 { → pyfreebilling}/templates/customer/home.html
  228. 0 { → pyfreebilling}/templates/customer/login.html
  229. 0 { → pyfreebilling}/templates/customer/rates.html
  230. 0 { → pyfreebilling}/templates/customer/register.html
  231. 0 { → pyfreebilling}/templates/customer/report.html
  232. 0 { → pyfreebilling}/templates/customer/sip_account.html
  233. 0 { → pyfreebilling}/templates/customer/stats.html
  234. 0 { → pyfreebilling}/templates/model_report/report.html
  235. 0 { → pyfreebilling}/templates/model_report/report_list.html
  236. 0 { → pyfreebilling}/templates/reporting/admin/index.html
  237. 0 { → pyfreebilling}/templates/simple_import/do_import.html
  238. 0 { → pyfreebilling}/templates/simple_import/match_columns.html
  239. 0 { → pyfreebilling}/templates/simple_import/match_relations.html
  240. 0 { → pyfreebilling}/templates/snippets/dashboard.html
  241. 0 { → pyfreebilling}/templates/snippets/general_stats.html
  242. 0 { → pyfreebilling}/templates/templated_email/balance.email
  243. 0 { → pyfreebilling}/templates/templated_email/lowbalance.email
  244. 0 { → pyfreebilling}/templates/templated_email/nobalance.email
  245. 0 { → pyfreebilling}/templates/xml/00_did.xml
  246. 0 { → pyfreebilling}/templates/xml/acl.conf.xml
  247. 0 { → pyfreebilling}/templates/xml/directory.conf.xml
  248. 0 { → pyfreebilling}/templates/xml/event_socket.conf.xml
  249. 0 { → pyfreebilling}/templates/xml/sofia.conf.xml
  250. +5 −0 requirements.txt
  251. +65 −0 requirements/base.in
  252. +7 −3 requirements/{requirements.txt → base.txt}
  253. +15 −0 requirements/dev.in
  254. +66 −0 requirements/dev.txt
  255. +2 −0 requirements/prod.in
  256. +51 −0 requirements/prod.txt
  257. +0 −3 requirements/requirements-dev.in
  258. +0 −21 requirements/requirements-dev.txt
  259. +0 −30 requirements/requirements.in
  260. +22 −0 requirements/test.in
  261. +0 −5 requirements/test.txt
  262. +3 −3 setup/apache/001-pyfreebilling
  263. +0 −36 setup/wsgi.py
  264. +0 −113 spec/intro.md
  265. +0 −196 static/css/c3.css
  266. +0 −1 static/css/nv.d3.min.css
  267. +0 −32 static/css/pyfreebilling.css
  268. BIN static/donate_button_red.jpg
  269. +0 −4 static/js/jquery-1.11.1.min.js
  270. +0 −14,368 static/js/nv.d3.js
  271. +0 −37 wsgi.py
View

Large diffs are not rendered by default.

Oops, something went wrong.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,118 @@
# Colored stream handler for python logging framework based on:
# http://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output/1336640#1336640
# Copyright (c) 2014 Markus Pointner
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import logging
class _AnsiColorStreamHandler(logging.StreamHandler):
DEFAULT = '\x1b[0m'
RED = '\x1b[31m'
GREEN = '\x1b[32m'
YELLOW = '\x1b[33m'
CYAN = '\x1b[36m'
CRITICAL = RED
ERROR = RED
WARNING = YELLOW
INFO = GREEN
DEBUG = CYAN
@classmethod
def _get_color(cls, level):
if level >= logging.CRITICAL: return cls.CRITICAL
elif level >= logging.ERROR: return cls.ERROR
elif level >= logging.WARNING: return cls.WARNING
elif level >= logging.INFO: return cls.INFO
elif level >= logging.DEBUG: return cls.DEBUG
else: return cls.DEFAULT
def __init__(self, stream=None):
logging.StreamHandler.__init__(self, stream)
def format(self, record):
text = logging.StreamHandler.format(self, record)
color = self._get_color(record.levelno)
return color + text + self.DEFAULT
class _WinColorStreamHandler(logging.StreamHandler):
# wincon.h
FOREGROUND_BLACK = 0x0000
FOREGROUND_BLUE = 0x0001
FOREGROUND_GREEN = 0x0002
FOREGROUND_CYAN = 0x0003
FOREGROUND_RED = 0x0004
FOREGROUND_MAGENTA = 0x0005
FOREGROUND_YELLOW = 0x0006
FOREGROUND_GREY = 0x0007
FOREGROUND_INTENSITY = 0x0008 # foreground color is intensified.
FOREGROUND_WHITE = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED
BACKGROUND_BLACK = 0x0000
BACKGROUND_BLUE = 0x0010
BACKGROUND_GREEN = 0x0020
BACKGROUND_CYAN = 0x0030
BACKGROUND_RED = 0x0040
BACKGROUND_MAGENTA = 0x0050
BACKGROUND_YELLOW = 0x0060
BACKGROUND_GREY = 0x0070
BACKGROUND_INTENSITY = 0x0080 # background color is intensified.
DEFAULT = FOREGROUND_WHITE
CRITICAL = BACKGROUND_YELLOW | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY
ERROR = FOREGROUND_RED | FOREGROUND_INTENSITY
WARNING = FOREGROUND_YELLOW | FOREGROUND_INTENSITY
INFO = FOREGROUND_GREEN
DEBUG = FOREGROUND_CYAN
@classmethod
def _get_color(cls, level):
if level >= logging.CRITICAL: return cls.CRITICAL
elif level >= logging.ERROR: return cls.ERROR
elif level >= logging.WARNING: return cls.WARNING
elif level >= logging.INFO: return cls.INFO
elif level >= logging.DEBUG: return cls.DEBUG
else: return cls.DEFAULT
def _set_color(self, code):
import ctypes
ctypes.windll.kernel32.SetConsoleTextAttribute(self._outhdl, code)
def __init__(self, stream=None):
logging.StreamHandler.__init__(self, stream)
# get file handle for the stream
import ctypes, ctypes.util
crtname = ctypes.util.find_msvcrt()
crtlib = ctypes.cdll.LoadLibrary(crtname)
self._outhdl = crtlib._get_osfhandle(stream.fileno())
def emit(self, record):
color = self._get_color(record.levelno)
self._set_color(color)
logging.StreamHandler.emit(self, record)
self._set_color(self.FOREGROUND_WHITE)
# select ColorStreamHandler based on platform
import platform
if platform.system() == 'Windows':
ColorStreamHandler = _WinColorStreamHandler
else:
ColorStreamHandler = _AnsiColorStreamHandler
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
Oops, something went wrong.

0 comments on commit 911a574

Please sign in to comment.