{ "info": { "author": "Rob Eroh", "author_email": "rob@eroh.me", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Flask", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=================\nflask-geckoboard\n=================\n\nGeckoboard_ is a hosted, real-time status board serving up indicators\nfrom web analytics, CRM, support, infrastructure, project management,\nsales, etc. It can be connected to virtually any source of quantitative\ndata. This Flask_ plugin provides view decorators to help create\ncustom widgets.\n\n.. _Geckoboard: http://www.geckoboard.com/\n.. _Flask: http://flask.pocoo.org/\n\n\nInstallation\n============\n\nTo install flask-geckoboard, simply place the ``flask_geckoboard``\npackage somewhere on the Python path.\n\n\nLimiting access\n===============\n\nIf you want to protect the data you send to Geckoboard from access by\nothers, you can use an API key shared by Geckoboard and your widget\nviews. Set ``GECKOBOARD_API_KEY`` in the Flask config.\n\nIf you do not set an API key, anyone will be able to view the data by\nvisiting the widget URL.\n\n\nEncryption\n==========\n\nGeckoboard encryption allows encrypting data before it is sent to Geckoboard's \nservers. After entering the password used to encrypt the data when the Geckoboard\nis loaded, the data will be decrypted in the browser.\n\nTo use encryption, first set a ``GECKOBOARD_PASSWORD`` in the Flask config.\n\nNext, enable encryption for each widget using the decorator arguments::\n\n from flask import Flask\n from flask_geckoboard import Geckoboard\n\n app = Flask(__name__)\n geckoboard = Geckoboard(app)\n\n @app.route('/user-count')\n @geckoboard.number(encrypted=True)\n def user_count(request):\n return User.objects.count()\n\n\nCreating custom widgets\n=======================\n\nThe available custom widgets are described in the Geckoboard support\nsection, under `Geckoboard API`_. From the perspective of a Flask\nproject, a custom widget is just a view. The flask-geckoboard\napplication provides view decorators that render the correct response\nfor the different widgets.\n\nLet's say you want to add a widget to your dashboard that shows the\nnumber of number of comments posted today. First create a view, using a\nflask-geckoboard decorator::\n\n from datetime import date, time, datetime\n\n from flask import Flask\n from flask_geckoboard import Geckoboard\n\n app = Flask(__name__)\n geckoboard = Geckoboard(app)\n\n @app.route('/comment-count')\n @geckoboard.number\n def comment_count():\n midnight = datetime.combine(date.today(), time.min)\n return Comment.objects.filter(submit_date__gte=midnight).count()\n\n\nIf your widget has optional settings, you can pass them in the decorator\ndefinition::\n\n @app.route('/gecko/comment/count-absolute')\n @geckoboard.number(absolute='true')\n def comment_count(request):\n midnight = datetime.combine(date.today(), time.min)\n return Comment.objects.filter(submit_date__gte=midnight).count()\n\n\nThis is all the Flask code you need to display the comment count on\nyour dashboard. When you create a custom widget in Geckoboard, enter the\nfollowing information:\n\nEncryption\n Enable if the field is encrypted (see instructions above).\n\nURL data feed\n The view URL. In the example above this would be something like\n ``http://HOSTNAME/geckoboard/comment_count/``.\n\nAPI key\n The content of the ``GECKOBOARD_API_KEY`` setting, if you have set\n it.\n\nWidget type\n *Custom*\n\nFeed format\n Either *XML* or *JSON*. If you don't specify a format the decorators will\n automatically detect and output the correct format or default to XML \n if this is not enabled (by default the format isn't appended by \n Geckoboard as a parameter any more)\n\nRequest type\n Either *GET* or *POST*. The view decorators accept both.\n\n\nThe following decorators are available from the\n``flask_geckoboard.decorators`` module:\n\n\n``number``\n-----------------\n\nRender a *Number & Secondary Stat* widget.\n\nThe decorated view must return a tuple *(current, [previous],\n[prefix])* where the *current* parameter is the current value, optional\n*previous* parameter is the previous value of the measured quantity and\nthe optional parameter *prefix* is the prefix used in Geckoboard widget.\nIf there is only one parameter you do not need to return it in a tuple.\nFor example, to render a widget that shows the number of users and the\ndifference from last week::\n\n from datetime import datetime, timedelta\n\n @geckoboard.number\n def user_count(request):\n last_week = datetime.now() - timedelta(weeks=1)\n users = User.objects\n last_week_users = users.filter(date_joined__lt=last_week)\n return (users.count(), last_week_users.count())\n\n @geckoboard.number\n def users_count_with_prefix(request):\n last_week = datetime.now() - timedelta(weeks=1)\n users = User.objects\n last_week_users = users.filter(date_joined__lt=last_week)\n return (users.count(), last_week_users.count(), '$')\n\n\n``rag``\n--------------\n\nRender a *RAG Column & Numbers* or *RAG Numbers* widget.\n\nThe decorated view must return a tuple with three tuples *(value,\n[text])*. The *value* parameters are the numbers shown in red, amber\nand green (in that order). The optional *text* parameters will be\ndisplayed next to the respective values in the dashboard.\n\nFor example, to render a widget that shows the number of comments that\nwere approved or deleted by moderators in the last 24 hours::\n\n from datetime import datetime, timedelta\n\n @geckoboard.rag\n def comments(request):\n start_time = datetime.now() - timedelta(hours=24)\n comments = Comment.objects.filter(submit_date__gt=start_time)\n total_count = comments.count()\n approved_count = comments.filter(\n flags__flag=CommentFlag.MODERATOR_APPROVAL).count()\n deleted_count = Comment.objects.filter(\n flags__flag=CommentFlag.MODERATOR_DELETION).count()\n pending_count = total_count - approved_count - deleted_count\n return (\n (deleted_count, \"Deleted comments\"),\n (pending_count, \"Pending comments\"),\n (approved_count, \"Approved comments\"),\n )\n\n\n``text``\n---------------\n\nRender a *Text* widget.\n\nThe decorated view must return a list of tuples *(message, [type])*.\nThe *message* parameters are strings that will be shown in the widget.\nThe *type* parameters are optional and tell Geckoboard how to annotate\nthe messages. Use ``TEXT_INFO`` for informational messages,\n``TEXT_WARN`` for for warnings and ``TEXT_NONE`` for plain text (the\ndefault). If there is only one plain message, you can just return it\nwithout enclosing it in a list and tuple.\n\nFor example, to render a widget showing the latest Geckoboard twitter\nupdates, using Mike Verdone's `Twitter library`_::\n\n import twitter\n\n @geckoboard.text\n def twitter_status(request):\n twitter = twitter.Api()\n updates = twitter.GetUserTimeline('geckoboard')\n return [(u.text, TEXT_NONE) for u in updates]\n\n.. _`Twitter library`: http://pypi.python.org/pypi/twitter\n\n\n``pie_chart``\n-------------\n\nRender a *Pie chart* widget.\n\nThe decorated view must return an iterable over tuples *(value, label,\n[color])*. The optional *color* parameter is a string ``'RRGGBB[TT]'``\nrepresenting red, green, blue and optionally transparency.\n\nFor example, to render a widget showing the number of normal, staff and\nsuperusers::\n\n @geckoboard.pie_chart\n def user_types(request):\n users = User.objects.filter(is_active=True)\n total_count = users.count()\n superuser_count = users.filter(is_superuser=True).count()\n staff_count = users.filter(is_staff=True,\n is_superuser=False).count()\n normal_count = total_count = superuser_count - staff_count\n return [\n (normal_count, \"Normal users\", \"ff8800\"),\n (staff_count, \"Staff\", \"00ff88\"),\n (superuser_count, \"Superusers\", \"8800ff\"),\n ]\n\n\n``line_chart``\n--------------\n\nRender a *Line chart* widget.\n\nThe decorated view must return a tuple *(values, x_axis, y_axis,\n[color])*. The *values* parameter is a list of data points. The\n*x-axis* parameter is a label string or a list of strings, that will be\nplaced on the X-axis. The *y-axis* parameter works similarly for the\nY-axis. If there are more than one axis label, they are placed evenly\nalong the axis. The optional *color* parameter is a string\n``'RRGGBB[TT]'`` representing red, green, blue and optionally\ntransparency.\n\nFor example, to render a widget showing the number of comments per day\nover the last four weeks (including today)::\n\n from datetime import date, timedelta\n\n @geckoboard.line_chart\n def comment_trend(request):\n since = date.today() - timedelta(days=29)\n days = dict((since + timedelta(days=d), 0)\n for d in range(0, 29))\n comments = Comment.objects.filter(submit_date__gte=since)\n for comment in comments:\n days[comment.submit_date.date()] += 1\n return (\n days.values(),\n [days[i] for i in range(0, 29, 7)],\n \"Comments\",\n )\n\n\n``geck_o_meter``\n----------------\n\nRender a *Geck-O-Meter* widget.\n\nThe decorated view must return a tuple *(value, min, max)*. The *value*\nparameter represents the current value. The *min* and *max* parameters\nrepresent the minimum and maximum value respectively. They are either a\nvalue, or a tuple *(value, text)*. If used, the *text* parameter will\nbe displayed next to the minimum or maximum value.\n\nFor example, to render a widget showing the number of users that have\nlogged in in the last 24 hours::\n\n from datetime import datetime, timedelta\n\n @geckoboard.geck_o_meter\n def login_count(request):\n since = datetime.now() - timedelta(hours=24)\n users = User.objects.filter(is_active=True)\n total_count = users.count()\n logged_in_count = users.filter(last_login__gt=since).count()\n return (logged_in_count, 0, total_count)\n\n\n``funnel``\n----------\n\nRender a *Funnel* widget.\n\nThe decorated view must return a dictionary with at least an *items*\nkey. To render a funnel showing the breakdown of authenticated users\nvs. anonymous users::\n\n @geckoboard.funnel\n def user_breakdown(request):\n all_users = User.objects\n active_users =all_users.filter(is_active=True)\n staff_users = all_users.filter(is_staff=True)\n super_users = all_users.filter(is_superuser=True)\n return {\n \"items\": [\n (all_users.count(), 'All users'),\n (active_users.count(), 'Active users'),\n (staff_users.count(), 'Staff users'),\n (super_users.count(), 'Super users'),\n ],\n \"type\": \"standard\", # default, 'reverse' changes direction\n # of the colors.\n \"percentage\": \"show\", # default, 'hide' hides the percentage\n # values.\n \"sort\": False, # default, `True` orders the values\n # descending.\n }\n\n``bullet``\n----------\n\nRender a *Bullet* widget.\n\nThe decorated view must return a dictionary with at least keys *label*,\n*axis_points*, *current* and *comparative*. To render Geckoboard's own example\nat\nhttp://support.geckoboard.com/entries/274940-custom-chart-widget-type-definitions::\n\n @geckoboard.bullet\n def geckoboard_bullet_example(request):\n return = {\n 'label': 'Revenue 2011 YTD',\n 'axis_points': [0, 200, 400, 600, 800, 1000],\n 'current': 500,\n 'comparative': 600,\n 'sublabel': 'U.S. $ in thousands',\n 'red': [0, 400],\n 'amber': [401, 700],\n 'green': [701, 1000],\n 'projected': [100, 900],\n 'auto_scale': False,\n }\n\n.. _`Geckoboard API`: http://geckoboard.zendesk.com/forums/207979-geckoboard-api\n\n\nChangelog\n=========\n\nVersion 0.2.1\n-------------\n* Make `comparative` field in Bullet Widget optional.\n\nVersion 0.2.0\n-------------\n* Bug fix in Bullet Widget.\n* Allow Bullet Widget to return more than one Bullet Widget.\n\nVersion 0.1.0\n-------------\n* First release, split off from django-geckoboard_.\n\n.. _django-analytical: http://pypi.python.org/pypi/django-geckoboard", "description_content_type": null, "docs_url": null, "download_url": "http://github.com/PolymathVentures/flask-geckoboard/archives/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/PolymathVentures/flask-geckoboard", "keywords": "flask,geckoboard", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "Flask-Geckoboard", "package_url": "https://pypi.org/project/Flask-Geckoboard/", "platform": "any", "project_url": "https://pypi.org/project/Flask-Geckoboard/", "project_urls": { "Download": "http://github.com/PolymathVentures/flask-geckoboard/archives/master", "Homepage": "http://github.com/PolymathVentures/flask-geckoboard" }, "release_url": "https://pypi.org/project/Flask-Geckoboard/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Geckoboard custom widgets for Flask projects", "version": "0.2.1" }, "last_serial": 1236879, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "c8d7fce49ddaa13ce056121d065078b7", "sha256": "47843954b4fc270d145f27447ff19b4b863471e6b83835c0503abb0c4d801610" }, "downloads": -1, "filename": "Flask-Geckoboard-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c8d7fce49ddaa13ce056121d065078b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18045, "upload_time": "2014-09-04T21:03:11", "url": "https://files.pythonhosted.org/packages/54/22/5ac7053084c66772af78579558ea5388ee35d9f9dd321cfb6c257a6bf54a/Flask-Geckoboard-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "97faa53fc118f5f5cbccf491999ebc68", "sha256": "2937ab35e3ee805ce56b074729e01a5e4eda6ff89903b1d0efd85edce2bf93b3" }, "downloads": -1, "filename": "Flask-Geckoboard-0.2.0.tar.gz", "has_sig": false, "md5_digest": "97faa53fc118f5f5cbccf491999ebc68", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18158, "upload_time": "2014-09-17T23:28:07", "url": "https://files.pythonhosted.org/packages/55/ef/9d0daff5cfd1626210e2017c3ef6880917ced03009a3afd35889f71fa842/Flask-Geckoboard-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "d30189713a77fb24ad879a2d622a1f8d", "sha256": "49ee7c97f9966edf124045a3e18111b8111cd5297127907982523b2c4df408b5" }, "downloads": -1, "filename": "Flask-Geckoboard-0.2.1.tar.gz", "has_sig": false, "md5_digest": "d30189713a77fb24ad879a2d622a1f8d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18187, "upload_time": "2014-09-24T19:42:13", "url": "https://files.pythonhosted.org/packages/b6/c3/3dbe60d0a65f0673524b351110ee55d4dd5980c67f0bad31b59780541d56/Flask-Geckoboard-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d30189713a77fb24ad879a2d622a1f8d", "sha256": "49ee7c97f9966edf124045a3e18111b8111cd5297127907982523b2c4df408b5" }, "downloads": -1, "filename": "Flask-Geckoboard-0.2.1.tar.gz", "has_sig": false, "md5_digest": "d30189713a77fb24ad879a2d622a1f8d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18187, "upload_time": "2014-09-24T19:42:13", "url": "https://files.pythonhosted.org/packages/b6/c3/3dbe60d0a65f0673524b351110ee55d4dd5980c67f0bad31b59780541d56/Flask-Geckoboard-0.2.1.tar.gz" } ] }