Skip to content

Commit

Permalink
Merge pull request #2694 from deniszh/DZ-1.1.8-prepare
Browse files Browse the repository at this point in the history
Backport changes for 1.1.8
  • Loading branch information
deniszh authored Apr 18, 2021
2 parents 3e5b9f6 + 1b202f2 commit b1aca46
Show file tree
Hide file tree
Showing 89 changed files with 4,410 additions and 3,436 deletions.
10 changes: 10 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version = 1

test_patterns = ["*/test/**"]

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
15 changes: 8 additions & 7 deletions bin/run-graphite-devel-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,35 @@
option_parser.add_option('--interface', default='0.0.0.0', action='store', help='Interface to listen on')
option_parser.add_option('--libs', default=None, help='Path to the directory containing the graphite python package')
option_parser.add_option('--noreload', action='store_true', help='Disable monitoring for changes')
option_parser.add_option('--settings', default='graphite.settings', help='configure alternative settings module')

(options, args) = option_parser.parse_args()

if not args:
option_parser.print_usage()
sys.exit(1)
option_parser.print_usage()
sys.exit(1)

graphite_root = args[0]

python_path = os.path.join(graphite_root, 'webapp')

if options.libs:
libdir = os.path.expanduser(options.libs)
print('Adding %s to your PYTHONPATH' % libdir)
os.environ['PYTHONPATH'] = libdir + ':' + os.environ.get('PYTHONPATH','')
libdir = os.path.expanduser(options.libs)
print('Adding %s to your PYTHONPATH' % libdir)
os.environ['PYTHONPATH'] = libdir + ':' + os.environ.get('PYTHONPATH','')

print("Running Graphite from %s under django development server\n" % graphite_root)

command = [
'django-admin.py',
'runserver',
'--pythonpath', python_path,
'--settings', 'graphite.settings',
'--settings', options.settings,
'%s:%d' % (options.interface, options.port)
]

if options.noreload:
command.append('--noreload')
command.append('--noreload')

print(' '.join(command))

Expand Down
146 changes: 82 additions & 64 deletions check-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,131 +3,149 @@
import sys

if sys.version_info <= (2,7):
# SystemExit defaults to returning 1 when printing a string to stderr
raise SystemExit("You are using python %s, but version 2.7 or greater is "
"required" % sys.version_info)
# SystemExit defaults to returning 1 when printing a string to stderr
raise SystemExit("You are using python %s, but version 2.7 or greater is "
"required" % sys.version_info)

required = 0
optional = 0


# Test for whisper
try:
import whisper
import whisper
except ImportError:
# No? test for ceres
try:
import ceres
# We imported ceres, but not whisper so it's an optional dependency
sys.stderr.write("[OPTIONAL] Unable to import the 'whisper' module. Without it the webapp will be unable to read .wsp files\n")
optional += 1
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'whisper' or 'ceres' modules, please download this package from the Graphite project page and install it.\n")
required += 1
# No? test for ceres
try:
import ceres
# We imported ceres, but not whisper so it's an optional dependency
sys.stderr.write("[OPTIONAL] Unable to import the 'whisper' module. "
"Without it the webapp will be unable to read .wsp files\n")
optional += 1
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'whisper' or 'ceres' modules, "
"please download this package from the Graphite project page and install it.\n")
required += 1


# Test for cairocffi or pycairo
try:
import cairocffi as cairo
import cairocffi as cairo
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'cairocffi' module, attempting to fall back to pycairo\n")
try:
import cairo
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'cairo' module, do you have pycairo installed for python %s?\n" % sys.version_info.major)
cairo = None
required += 1
sys.stderr.write("[REQUIRED] Unable to import the 'cairocffi' module, attempting to fall back to pycairo\n")
try:
import cairo
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'cairo' module, "
"do you have pycairo installed for python %s?\n" % sys.version_info.major)
cairo = None
required += 1


# Test that pycairo has the PNG backend
try:
if cairo:
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
del surface
if cairo:
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
del surface
except Exception:
sys.stderr.write("[REQUIRED] Failed to create an ImageSurface with cairo, you probably need to recompile cairo with PNG support\n")
required += 1
sys.stderr.write("[REQUIRED] Failed to create an ImageSurface with cairo, "
"you probably need to recompile cairo with PNG support\n")
required += 1


# Test that cairo can find fonts
try:
if cairo:
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
context = cairo.Context(surface)
context.font_extents()
del surface, context
if cairo:
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
context = cairo.Context(surface)
context.font_extents()
del surface, context
except Exception:
sys.stderr.write("[REQUIRED] Failed to create text with cairo, this probably means cairo cant find any fonts. Install some system fonts and try again\n")
sys.stderr.write("[REQUIRED] Failed to create text with cairo, "
"this probably means cairo cant find any fonts. "
"Install some system fonts and try again\n")


# Test for django
try:
import django
import django
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'django' module, do you have Django installed for python %s?\n" % sys.version_info.major)
django = None
required += 1
sys.stderr.write("[REQUIRED] Unable to import the 'django' module, "
"do you have Django installed for python %s?\n" % sys.version_info.major)
django = None
required += 1


# Test for pytz
try:
import pytz
import pytz
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'pytz' module, do you have pytz module installed for python %s?\n" % sys.version_info.major)
required += 1
sys.stderr.write("[REQUIRED] Unable to import the 'pytz' module, "
"do you have pytz module installed for python %s?\n" % sys.version_info.major)
required += 1


# Test for pyparsing
try:
import pyparsing
import pyparsing
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'pyparsing' module, do you have pyparsing module installed for python %s?\n" % sys.version_info.major)
required += 1
sys.stderr.write("[REQUIRED] Unable to import the 'pyparsing' module, "
"do you have pyparsing module installed for python %s?\n" % sys.version_info.major)
required += 1


# Test for django-tagging
try:
import tagging
import tagging
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'tagging' module, do you have django-tagging installed for python %s?\n" % sys.version_info.major)
required += 1
sys.stderr.write("[REQUIRED] Unable to import the 'tagging' module, "
"do you have django-tagging installed for python %s?\n" % sys.version_info.major)
required += 1


if django and django.VERSION[:2] < (1,8):
sys.stderr.write("[REQUIRED] You have django version %s installed, but version 1.8 or greater is required\n" % django.get_version())
required += 1
sys.stderr.write("[REQUIRED] You have django version %s installed, "
"but version 1.8 or greater is required\n" % django.get_version())
required += 1


# Test for python-memcached
try:
import memcache
import memcache
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'memcache' module, do you have python-memcached installed for python %s? This feature is not required but greatly improves performance.\n" % sys.version_info.major)
optional += 1
sys.stderr.write("[OPTIONAL] Unable to import the 'memcache' module, "
"do you have python-memcached installed for python %s? "
"This feature is not required but greatly improves performance.\n" % sys.version_info.major)
optional += 1


# Test for python-ldap
try:
import ldap
import ldap
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'ldap' module, do you have python-ldap installed for python %s? Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.\n" % sys.version_info.major)
optional += 1
sys.stderr.write("[OPTIONAL] Unable to import the 'ldap' module, "
"do you have python-ldap installed for python %s? "
"Without python-ldap, you will not be able to use "
"LDAP authentication in the graphite webapp.\n" % sys.version_info.major)
optional += 1


# Test for txamqp
try:
import txamqp
import txamqp
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'txamqp' module, this is required if you want to use AMQP as an input to Carbon. Note that txamqp requires python 2.5 or greater.\n")
optional += 1
sys.stderr.write("[OPTIONAL] Unable to import the 'txamqp' module, "
"this is required if you want to use AMQP as an input to Carbon. "
"Note that txamqp requires python 2.5 or greater.\n")
optional += 1


# Test for python-rrdtool
try:
import rrdtool
import rrdtool
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'python-rrdtool' module, this is required for reading RRD.\n")
optional += 1
sys.stderr.write("[OPTIONAL] Unable to import the 'python-rrdtool' module, this is required for reading RRD.\n")
optional += 1


# Test for whitenoise
Expand All @@ -147,15 +165,15 @@


if optional:
sys.stderr.write("%d optional dependencies not met. Please consider the optional items before proceeding.\n" % optional)
sys.stderr.write("%d optional dependencies not met. Please consider the optional items before proceeding.\n" % optional)
else:
print("All optional dependencies are met.")
print("All optional dependencies are met.")

if required:
sys.stderr.write("%d necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.\n" % required)
sys.exit(1)
sys.stderr.write("%d necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.\n" % required)
sys.exit(1)
else:
print("All necessary dependencies are met.")
print("All necessary dependencies are met.")


# suppress unused-import warnings
Expand Down
17 changes: 10 additions & 7 deletions contrib/test_aggregator_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

### Basic usage
if len(sys.argv) != 3:
print("Usage: %s 'aggregator rule' 'line item'" % (__file__))
print("\nSample invocation: %s %s %s" %
(__file__, "'<prefix>.<env>.<key>.sum.all (10) = sum <prefix>.<env>.<<key>>.sum.<node>'", 'stats.prod.js.ktime_sum.sum.host2' ))
sys.exit(42)
print("Usage: %s 'aggregator rule' 'line item'" % (__file__))
print("\nSample invocation: %s %s %s" % (
__file__,
"'<prefix>.<env>.<key>.sum.all (10) = sum <prefix>.<env>.<<key>>.sum.<node>'",
'stats.prod.js.ktime_sum.sum.host2'
))
sys.exit(42)

### cli arguments
me, raw_rule, raw_metric = sys.argv
Expand All @@ -36,8 +39,8 @@

print("Raw metric: %s" % raw_metric)
if match:
print("Match dict: %s" % match.groupdict())
print("Result: %s" % rule.output_template % match.groupdict())
print("Match dict: %s" % match.groupdict())
print("Result: %s" % rule.output_template % match.groupdict())

else:
print("ERROR: NO MATCH")
print("ERROR: NO MATCH")
22 changes: 11 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@
# Define a custom autodoc documenter for the render.functions module
# This will remove the requestContext parameter which doesnt make sense in the context of the docs
class RenderFunctionDocumenter(autodoc.FunctionDocumenter):
priority = 10 # Override FunctionDocumenter
priority = 10 # Override FunctionDocumenter

@classmethod
def can_document_member(cls, member, membername, isattr, parent):
return autodoc.FunctionDocumenter.can_document_member(member, membername, isattr, parent) and \
parent.name == 'graphite.render.functions'
@classmethod
def can_document_member(cls, member, membername, isattr, parent):
return autodoc.FunctionDocumenter.can_document_member(member, membername, isattr, parent) \
and parent.name == 'graphite.render.functions'

def format_args(self):
args = autodoc.FunctionDocumenter.format_args(self)
if args is not None:
# Really, a regex sub here is by far the easiest way
return re.sub('requestContext, ','',args)
def format_args(self):
args = autodoc.FunctionDocumenter.format_args(self)
if args is not None:
# Really, a regex sub here is by far the easiest way
return re.sub('requestContext, ','',args)


def setup(app):
app.add_autodocumenter(RenderFunctionDocumenter)
app.add_autodocumenter(RenderFunctionDocumenter)


# -- General configuration -----------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions docs/config-local-settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ LOG_CACHE_PERFORMANCE

Triggers the creation of ``cache.log`` which logs timings for remote calls to `carbon-cache` as well as Request Cache (memcached) hits and misses.

LOG_INFO_PERFORMANCE
`Default: True`

Triggers the creation of ``info.log`` which logs general logs. Enabled by default.


DEBUG = True
`Default: False`

Expand Down
Loading

0 comments on commit b1aca46

Please sign in to comment.