فهرست منبع

Do not use log colors on Windows, as the console there doesn't support ANSI

Ask Solem 14 سال پیش
والد
کامیت
71312fdfab
3فایلهای تغییر یافته به همراه9 افزوده شده و 6 حذف شده
  1. 6 0
      celery/app/base.py
  2. 2 6
      celery/apps/worker.py
  3. 1 0
      celery/conf.py

+ 6 - 0
celery/app/base.py

@@ -1,4 +1,5 @@
 import sys
+import platform as _platform
 
 from datetime import timedelta
 from itertools import chain
@@ -74,6 +75,9 @@ class MultiDictView(AttributeDictMixin):
 
 class BaseApp(object):
     """Base class for apps."""
+    SYSTEM = _platform.system()
+    IS_OSX = SYSTEM == "Darwin"
+    IS_WINDOWS = SYSTEM == "Windows"
 
     def __init__(self, loader=None, backend=None, set_as_current=True):
         self.loader_cls = loader or "app"
@@ -259,6 +263,8 @@ class BaseApp(object):
         if c.get("CELERYD_LOG_COLOR") is None:
             c["CELERYD_LOG_COLOR"] = not c.CELERYD_LOG_FILE and \
                                         isatty(sys.stderr)
+            if self.IS_WINDOWS:  # windows console doesn't support ANSI colors
+                c["CELERYD_LOG_COLOR"] = False
         if isinstance(c.CELERY_TASK_RESULT_EXPIRES, int):
             c["CELERY_TASK_RESULT_EXPIRES"] = timedelta(
                     seconds=c.CELERY_TASK_RESULT_EXPIRES)

+ 2 - 6
celery/apps/worker.py

@@ -1,6 +1,5 @@
 import logging
 import multiprocessing
-import platform as _platform
 import os
 import socket
 import sys
@@ -14,9 +13,6 @@ from celery.utils import get_full_cls_name, LOG_LEVELS
 from celery.worker import WorkController
 
 
-SYSTEM = _platform.system()
-IS_OSX = SYSTEM == "Darwin"
-
 STARTUP_INFO_FMT = """
 Configuration ->
     . broker -> %(conninfo)s
@@ -178,7 +174,7 @@ class Worker(object):
 
     def install_platform_tweaks(self, worker):
         """Install platform specific tweaks and workarounds."""
-        if IS_OSX:
+        if self.app.IS_OSX:
             self.osx_proxy_detection_workaround()
 
         # Install signal handler so SIGHUP restarts the worker.
@@ -186,7 +182,7 @@ class Worker(object):
             # only install HUP handler if detached from terminal,
             # so closing the terminal window doesn't restart celeryd
             # into the background.
-            if IS_OSX:
+            if self.app.IS_OSX:
                 # OS X can't exec from a process using threads.
                 # See http://github.com/ask/celery/issues#issue/152
                 install_HUP_not_supported_handler(worker)

+ 1 - 0
celery/conf.py

@@ -1,3 +1,4 @@
+<<<<<<< HEAD
 """
 
 **DEPRECATED**