From: Stephen Soltesz Date: Tue, 25 Nov 2008 23:54:57 +0000 (+0000) Subject: Entry point for rpc server, view templates, rss feeds of node down times, X-Git-Tag: Monitor-2.0-0~27 X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=commitdiff_plain;h=66ef9d90a94833d30502006d1fcdafd5054086eb Entry point for rpc server, view templates, rss feeds of node down times, and other nice things. --- diff --git a/web/MonitorWeb/MonitorWeb.egg-info/PKG-INFO b/web/MonitorWeb/MonitorWeb.egg-info/PKG-INFO new file mode 100644 index 0000000..594b5b8 --- /dev/null +++ b/web/MonitorWeb/MonitorWeb.egg-info/PKG-INFO @@ -0,0 +1,15 @@ +Metadata-Version: 1.0 +Name: MonitorWeb +Version: 1.0 +Summary: UNKNOWN +Home-page: UNKNOWN +Author: UNKNOWN +Author-email: UNKNOWN +License: UNKNOWN +Description: UNKNOWN +Platform: UNKNOWN +Classifier: Development Status :: 3 - Alpha +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Topic :: Software Development :: Libraries :: Python Modules +Classifier: Framework :: TurboGears diff --git a/web/MonitorWeb/MonitorWeb.egg-info/SOURCES.txt b/web/MonitorWeb/MonitorWeb.egg-info/SOURCES.txt new file mode 100644 index 0000000..23d914d --- /dev/null +++ b/web/MonitorWeb/MonitorWeb.egg-info/SOURCES.txt @@ -0,0 +1,21 @@ +README.txt +setup.py +MonitorWeb.egg-info/PKG-INFO +MonitorWeb.egg-info/SOURCES.txt +MonitorWeb.egg-info/dependency_links.txt +MonitorWeb.egg-info/entry_points.txt +MonitorWeb.egg-info/not-zip-safe +MonitorWeb.egg-info/paster_plugins.txt +MonitorWeb.egg-info/requires.txt +MonitorWeb.egg-info/top_level.txt +monitorweb/__init__.py +monitorweb/commands.py +monitorweb/controllers.py +monitorweb/json.py +monitorweb/model.py +monitorweb/release.py +monitorweb/config/__init__.py +monitorweb/templates/__init__.py +monitorweb/tests/__init__.py +monitorweb/tests/test_controllers.py +monitorweb/tests/test_model.py \ No newline at end of file diff --git a/web/MonitorWeb/MonitorWeb.egg-info/dependency_links.txt b/web/MonitorWeb/MonitorWeb.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/web/MonitorWeb/MonitorWeb.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/web/MonitorWeb/MonitorWeb.egg-info/entry_points.txt b/web/MonitorWeb/MonitorWeb.egg-info/entry_points.txt new file mode 100644 index 0000000..49e72a2 --- /dev/null +++ b/web/MonitorWeb/MonitorWeb.egg-info/entry_points.txt @@ -0,0 +1,3 @@ +[console_scripts] +start-monitorweb = monitorweb.commands:start + diff --git a/web/MonitorWeb/MonitorWeb.egg-info/not-zip-safe b/web/MonitorWeb/MonitorWeb.egg-info/not-zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/web/MonitorWeb/MonitorWeb.egg-info/not-zip-safe @@ -0,0 +1 @@ + diff --git a/web/MonitorWeb/MonitorWeb.egg-info/paster_plugins.txt b/web/MonitorWeb/MonitorWeb.egg-info/paster_plugins.txt new file mode 100644 index 0000000..89bd761 --- /dev/null +++ b/web/MonitorWeb/MonitorWeb.egg-info/paster_plugins.txt @@ -0,0 +1 @@ +TurboGears diff --git a/web/MonitorWeb/MonitorWeb.egg-info/requires.txt b/web/MonitorWeb/MonitorWeb.egg-info/requires.txt new file mode 100644 index 0000000..ca77963 --- /dev/null +++ b/web/MonitorWeb/MonitorWeb.egg-info/requires.txt @@ -0,0 +1,3 @@ +TurboGears >= 1.0.7 +SQLAlchemy>=0.3.10 +Elixir>=0.4.0 \ No newline at end of file diff --git a/web/MonitorWeb/MonitorWeb.egg-info/top_level.txt b/web/MonitorWeb/MonitorWeb.egg-info/top_level.txt new file mode 100644 index 0000000..90cbb55 --- /dev/null +++ b/web/MonitorWeb/MonitorWeb.egg-info/top_level.txt @@ -0,0 +1 @@ +monitorweb diff --git a/web/MonitorWeb/README.txt b/web/MonitorWeb/README.txt new file mode 100644 index 0000000..03cdb8d --- /dev/null +++ b/web/MonitorWeb/README.txt @@ -0,0 +1,4 @@ +MonitorWeb + +This is a TurboGears (http://www.turbogears.org) project. It can be +started by running the start-monitorweb.py script. \ No newline at end of file diff --git a/web/MonitorWeb/dev.cfg b/web/MonitorWeb/dev.cfg new file mode 100644 index 0000000..f1e675b --- /dev/null +++ b/web/MonitorWeb/dev.cfg @@ -0,0 +1,76 @@ +[global] +# This is where all of your settings go for your development environment +# Settings that are the same for both development and production +# (such as template engine, encodings, etc.) all go in +# monitorweb/config/app.cfg + +# DATABASE + +# driver://username:password@host:port/database + +# pick the form for your database +# sqlalchemy.dburi="postgres://username@hostname/databasename" +# sqlalchemy.dburi="mysql://username:password@hostname:port/databasename" +# sqlalchemy.dburi="sqlite://%(current_dir_uri)s/devdata.sqlite" + +# If you have sqlite, here's a simple default to get you started +# in development +sqlalchemy.dburi="sqlite:///devdata.sqlite" + + +# SERVER + +# Some server parameters that you may want to tweak +# server.socket_port=8080 + +# Enable the debug output at the end on pages. +# log_debug_info_filter.on = False + +server.environment="development" +autoreload.package="monitorweb" + + +server.socket_host="127.0.0.1" +server.socket_port=8080 +server.webpath="/monitor/" +base_url_filter.on = False +base_url_filter.base_url = "http://127.0.0.1:8080/monitor" +base_url_filter.use_x_forwarded_host = True + +# Auto-Reload after code modification +# autoreload.on = True + +# Set to True if you'd like to abort execution if a controller gets an +# unexpected parameter. False by default +tg.strict_parameters = True + +# LOGGING +# Logging configuration generally follows the style of the standard +# Python logging module configuration. Note that when specifying +# log format messages, you need to use *() for formatting variables. +# Deployment independent log configuration is in monitorweb/config/log.cfg +[logging] + +[[loggers]] +[[[monitorweb]]] +level='DEBUG' +qualname='monitorweb' +handlers=['debug_out'] + +[[[allinfo]]] +level='INFO' +handlers=['debug_out'] + +[[[access]]] +level='INFO' +qualname='turbogears.access' +handlers=['access_out'] +propagate=0 + + +[[[database]]] +# Set to INFO to make SQLAlchemy display SQL commands +level='ERROR' +qualname='sqlalchemy.engine' +handlers=['debug_out'] +propagate=0 diff --git a/web/MonitorWeb/monitorweb/__init__.py b/web/MonitorWeb/monitorweb/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/MonitorWeb/monitorweb/commands.py b/web/MonitorWeb/monitorweb/commands.py new file mode 100644 index 0000000..9e75f08 --- /dev/null +++ b/web/MonitorWeb/monitorweb/commands.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +"""This module contains functions called from console script entry points.""" + +import sys +from os import getcwd +from os.path import dirname, exists, join + +import pkg_resources +pkg_resources.require("TurboGears>=1.0.7") + +import cherrypy +import turbogears + +cherrypy.lowercase_api = True + + +class ConfigurationError(Exception): + pass + + +def start(): + """Start the CherryPy application server.""" + + setupdir = dirname(dirname(__file__)) + curdir = getcwd() + + # First look on the command line for a desired config file, + # if it's not on the command line, then look for 'setup.py' + # in the current directory. If there, load configuration + # from a file called 'dev.cfg'. If it's not there, the project + # is probably installed and we'll look first for a file called + # 'prod.cfg' in the current directory and then for a default + # config file called 'default.cfg' packaged in the egg. + if len(sys.argv) > 1: + configfile = sys.argv[1] + elif exists(join(setupdir, "setup.py")): + configfile = join(setupdir, "dev.cfg") + elif exists(join(curdir, "prod.cfg")): + configfile = join(curdir, "prod.cfg") + else: + try: + configfile = pkg_resources.resource_filename( + pkg_resources.Requirement.parse("MonitorWeb"), + "config/default.cfg") + except pkg_resources.DistributionNotFound: + raise ConfigurationError("Could not find default configuration.") + + turbogears.update_config(configfile=configfile, + modulename="monitorweb.config") + + from monitorweb.controllers import Root + + turbogears.start_server(Root()) diff --git a/web/MonitorWeb/monitorweb/config/__init__.py b/web/MonitorWeb/monitorweb/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/MonitorWeb/monitorweb/config/app.cfg b/web/MonitorWeb/monitorweb/config/app.cfg new file mode 100644 index 0000000..8667126 --- /dev/null +++ b/web/MonitorWeb/monitorweb/config/app.cfg @@ -0,0 +1,71 @@ +[global] +# The settings in this file should not vary depending on the deployment +# environment. dev.cfg and prod.cfg are the locations for +# the different deployment settings. Settings in this file will +# be overridden by settings in those other files. + +# The commented out values below are the defaults + +# APPLICATION PACKAGE + +package = "monitorweb" + +# VIEW + +# which view (template engine) to use if one is not specified in the +# template name +# tg.defaultview = "kid" + +# The following Kid settings determine the settings used by the Kid serializer. + +# Kid output method (e.g. html, html-strict, xhtml, xhtml-strict, xml, json) +# and formatting (e.g. default, straight, compact, newlines, wrap, nice) +# kid.outputformat="html default" + +# kid.encoding="utf-8" + +# The sitetemplate is used for overall styling of a site that +# includes multiple TurboGears applications +# tg.sitetemplate="" + +# Allow every exposed function to be called as json, +# tg.allow_json = False + +# Suppress the inclusion of the shipped MochiKit version, which is rather outdated. +# Attention: setting this to True and listing 'turbogears.mochikit' in 'tg.include_widgets' +# is a contradiction. This option will overrule the default-inclusion to prevent version +# mismatch bugs. +# tg.mochikit_suppress = True + +# List of Widgets to include on every page. +# for example ['turbogears.mochikit'] +# tg.include_widgets = [] + +# Set to True if the scheduler should be started +# tg.scheduler = False + +# Set to True to allow paginate decorator redirects when page number gets +# out of bound. Useful for getting the real page id in the url +# paginate.redirect_on_out_of_range = True + +# Set to True to allow paginate decorator redirects when last page is requested. +# This is useful for getting the real last page id in the url +# paginate.redirect_on_last_page = True + +# Set session or cookie +# session_filter.on = True + + +# compress the data sends to the web browser +# [/] +# gzip_filter.on = True +# gzip_filter.mime_types = ["application/json", "application/x-javascript", +# "text/javascript", "text/html", "text/css", "text/plain"] + +[/static] +static_filter.on = True +static_filter.dir = "%(top_level_dir)s/static" + +[/favicon.ico] +static_filter.on = True +static_filter.file = "%(top_level_dir)s/static/images/favicon.ico" diff --git a/web/MonitorWeb/monitorweb/config/log.cfg b/web/MonitorWeb/monitorweb/config/log.cfg new file mode 100644 index 0000000..ce776f8 --- /dev/null +++ b/web/MonitorWeb/monitorweb/config/log.cfg @@ -0,0 +1,29 @@ +# LOGGING +# Logging is often deployment specific, but some handlers and +# formatters can be defined here. + +[logging] +[[formatters]] +[[[message_only]]] +format='*(message)s' + +[[[full_content]]] +format='*(asctime)s *(name)s *(levelname)s *(message)s' + +[[handlers]] +[[[debug_out]]] +class='StreamHandler' +level='DEBUG' +args='(sys.stdout,)' +formatter='full_content' + +[[[access_out]]] +class='StreamHandler' +level='INFO' +args='(sys.stdout,)' +formatter='message_only' + +[[[error_out]]] +class='StreamHandler' +level='ERROR' +args='(sys.stdout,)' diff --git a/web/MonitorWeb/monitorweb/controllers.py b/web/MonitorWeb/monitorweb/controllers.py new file mode 100644 index 0000000..8d9ced5 --- /dev/null +++ b/web/MonitorWeb/monitorweb/controllers.py @@ -0,0 +1,13 @@ +import turbogears as tg +from turbogears import controllers, expose, flash +# from monitorweb import model +# import logging +# log = logging.getLogger("monitorweb.controllers") + +class Root(controllers.RootController): + @expose(template="monitorweb.templates.welcome") + def index(self): + import time + # log.debug("Happy TurboGears Controller Responding For Duty") + flash("Your application is now running") + return dict(now=time.ctime()) diff --git a/web/MonitorWeb/monitorweb/json.py b/web/MonitorWeb/monitorweb/json.py new file mode 100644 index 0000000..66d5cfb --- /dev/null +++ b/web/MonitorWeb/monitorweb/json.py @@ -0,0 +1,10 @@ +# A JSON-based API(view) for your app. +# Most rules would look like: +# @jsonify.when("isinstance(obj, YourClass)") +# def jsonify_yourclass(obj): +# return [obj.val1, obj.val2] +# @jsonify can convert your objects to following types: +# lists, dicts, numbers and strings + +from turbojson.jsonify import jsonify + diff --git a/web/MonitorWeb/monitorweb/model.py b/web/MonitorWeb/monitorweb/model.py new file mode 100644 index 0000000..b570416 --- /dev/null +++ b/web/MonitorWeb/monitorweb/model.py @@ -0,0 +1,20 @@ +import pkg_resources +pkg_resources.require("SQLAlchemy>=0.3.10") +pkg_resources.require("Elixir>=0.4.0") +# import the basic Elixir classes and functions for declaring the data model +# (see http://elixir.ematia.de/trac/wiki/TutorialDivingIn) +from elixir import Entity, Field, OneToMany, ManyToOne, ManyToMany +from elixir import options_defaults, using_options, setup_all +# import some datatypes for table columns from Elixir +# (see http://www.sqlalchemy.org/docs/04/types.html for more) +from elixir import String, Unicode, Integer, DateTime + +options_defaults['autosetup'] = False + + +# your data model + +# class YourDataClass(Entity): +# pass + + diff --git a/web/MonitorWeb/monitorweb/release.py b/web/MonitorWeb/monitorweb/release.py new file mode 100644 index 0000000..21d4758 --- /dev/null +++ b/web/MonitorWeb/monitorweb/release.py @@ -0,0 +1,14 @@ +# Release information about MonitorWeb + +version = "1.0" + +# description = "Your plan to rule the world" +# long_description = "More description about your plan" +# author = "Your Name Here" +# email = "YourEmail@YourDomain" +# copyright = "Vintage 2006 - a good year indeed" + +# if it's open source, you might want to specify these +# url = "http://yourcool.site/" +# download_url = "http://yourcool.site/download" +# license = "MIT" diff --git a/web/MonitorWeb/monitorweb/static/css/style.css b/web/MonitorWeb/monitorweb/static/css/style.css new file mode 100644 index 0000000..c98d40e --- /dev/null +++ b/web/MonitorWeb/monitorweb/static/css/style.css @@ -0,0 +1,134 @@ +/* + * Quick mash-up of CSS for the TG quick start page. + */ + +html, body { + color: black; + background-color: #ddd; + font: x-small "Lucida Grande", "Lucida Sans Unicode", geneva, verdana, sans-serif; + margin: 0; + padding: 0; +} + +td, th {padding:3px;border:none;} +tr th {text-align:left;background-color:#f0f0f0;color:#333;} +tr.odd td {background-color:#edf3fe;} +tr.even td {background-color:#fff;} + +#header { + height: 80px; + width: 777px; + background: blue URL('../images/header_inner.png') no-repeat; + border-left: 1px solid #aaa; + border-right: 1px solid #aaa; + margin: 0 auto 0 auto; +} + +a.link, a, a.active { + color: #369; +} + + +#main_content { + color: black; + font-size: 127%; + background-color: white; + width: 757px; + margin: 0 auto 0 auto; + border-left: 1px solid #aaa; + border-right: 1px solid #aaa; + padding: 10px; +} + +#sidebar { + border: 1px solid #aaa; + background-color: #eee; + margin: 0.5em; + padding: 1em; + float: right; + width: 200px; + font-size: 88%; +} + +#sidebar h2 { + margin-top: 0; +} + +#sidebar ul { + margin-left: 1.5em; + padding-left: 0; +} + +h1,h2,h3,h4,h5,h6,#getting_started_steps { + font-family: "Century Schoolbook L", Georgia, serif; + font-weight: bold; +} + +h2 { + font-size: 150%; +} + +#getting_started_steps a { + text-decoration: none; +} + +#getting_started_steps a:hover { + text-decoration: underline; +} + +#getting_started_steps li { + font-size: 80%; + margin-bottom: 0.5em; +} + +#getting_started_steps h2 { + font-size: 120%; +} + +#getting_started_steps p { + font: 100% "Lucida Grande", "Lucida Sans Unicode", geneva, verdana, sans-serif; +} + +#footer { + border: 1px solid #aaa; + border-top: 0px none; + color: #999; + background-color: white; + padding: 10px; + font-size: 80%; + text-align: center; + width: 757px; + margin: 0 auto 1em auto; +} + +.code { + font-family: monospace; +} + +span.code { + font-weight: bold; + background: #eee; +} + +#status_block { + margin: 0 auto 0.5em auto; + padding: 15px 10px 15px 55px; + background: #cec URL('../images/ok.png') left center no-repeat; + border: 1px solid #9c9; + width: 450px; + font-size: 120%; + font-weight: bolder; +} + +.notice { + margin: 0.5em auto 0.5em auto; + padding: 15px 10px 15px 55px; + width: 450px; + background: #eef URL('../images/info.png') left center no-repeat; + border: 1px solid #cce; +} + +.fielderror { + color: red; + font-weight: bold; +} \ No newline at end of file diff --git a/web/MonitorWeb/monitorweb/static/images/favicon.ico b/web/MonitorWeb/monitorweb/static/images/favicon.ico new file mode 100644 index 0000000..332557b Binary files /dev/null and b/web/MonitorWeb/monitorweb/static/images/favicon.ico differ diff --git a/web/MonitorWeb/monitorweb/static/images/header_inner.png b/web/MonitorWeb/monitorweb/static/images/header_inner.png new file mode 100644 index 0000000..2b2d87d Binary files /dev/null and b/web/MonitorWeb/monitorweb/static/images/header_inner.png differ diff --git a/web/MonitorWeb/monitorweb/static/images/info.png b/web/MonitorWeb/monitorweb/static/images/info.png new file mode 100644 index 0000000..329c523 Binary files /dev/null and b/web/MonitorWeb/monitorweb/static/images/info.png differ diff --git a/web/MonitorWeb/monitorweb/static/images/ok.png b/web/MonitorWeb/monitorweb/static/images/ok.png new file mode 100644 index 0000000..fee6751 Binary files /dev/null and b/web/MonitorWeb/monitorweb/static/images/ok.png differ diff --git a/web/MonitorWeb/monitorweb/static/images/tg_under_the_hood.png b/web/MonitorWeb/monitorweb/static/images/tg_under_the_hood.png new file mode 100644 index 0000000..bc9c79c Binary files /dev/null and b/web/MonitorWeb/monitorweb/static/images/tg_under_the_hood.png differ diff --git a/web/MonitorWeb/monitorweb/static/images/under_the_hood_blue.png b/web/MonitorWeb/monitorweb/static/images/under_the_hood_blue.png new file mode 100644 index 0000000..90e84b7 Binary files /dev/null and b/web/MonitorWeb/monitorweb/static/images/under_the_hood_blue.png differ diff --git a/web/MonitorWeb/monitorweb/templates/.master.kid.swp b/web/MonitorWeb/monitorweb/templates/.master.kid.swp new file mode 100644 index 0000000..58f5330 Binary files /dev/null and b/web/MonitorWeb/monitorweb/templates/.master.kid.swp differ diff --git a/web/MonitorWeb/monitorweb/templates/__init__.py b/web/MonitorWeb/monitorweb/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/MonitorWeb/monitorweb/templates/login.kid b/web/MonitorWeb/monitorweb/templates/login.kid new file mode 100644 index 0000000..eb55735 --- /dev/null +++ b/web/MonitorWeb/monitorweb/templates/login.kid @@ -0,0 +1,114 @@ + + + + + + Login + + + + +
+

Login

+

${message}

+
+ + + + + + + + + + + + +
+ + + +
+ + + +
+ +
+ + + +
+ +
+
+
+ + diff --git a/web/MonitorWeb/monitorweb/templates/master.kid b/web/MonitorWeb/monitorweb/templates/master.kid new file mode 100644 index 0000000..ba39836 --- /dev/null +++ b/web/MonitorWeb/monitorweb/templates/master.kid @@ -0,0 +1,50 @@ + + + + + + + Your title goes here + + + + + + +
+ + Login + + + Welcome ${tg.identity.user.display_name or tg.identity.user.user_name}. + Logout + +
+ + + +
+
+
page content
+
+ + + + + diff --git a/web/MonitorWeb/monitorweb/templates/welcome.kid b/web/MonitorWeb/monitorweb/templates/welcome.kid new file mode 100644 index 0000000..9095267 --- /dev/null +++ b/web/MonitorWeb/monitorweb/templates/welcome.kid @@ -0,0 +1,47 @@ + + + + +Welcome to TurboGears + + + + +
+
    +
  1. +

    Model

    +

    Design models in the model.py.
    + Edit dev.cfg to use a different backend, or start with a pre-configured SQLite database.
    + Use script tg-admin sql create to create the database tables.

    +
  2. +
  3. +

    View

    +

    Edit html-like templates in the /templates folder;
    + Put all static contents in the /static folder.

    +
  4. +
  5. +

    Controller

    +

    Edit controllers.py and build your + website structure with the simplicity of Python objects.
    + TurboGears will automatically reload itself when you modify your project.

    +
  6. +
+
If you create something cool, please let people know, and consider contributing something back to the community.
+
+ + + diff --git a/web/MonitorWeb/monitorweb/tests/__init__.py b/web/MonitorWeb/monitorweb/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/MonitorWeb/monitorweb/tests/test_controllers.py b/web/MonitorWeb/monitorweb/tests/test_controllers.py new file mode 100644 index 0000000..74070a2 --- /dev/null +++ b/web/MonitorWeb/monitorweb/tests/test_controllers.py @@ -0,0 +1,32 @@ +import unittest +import turbogears +from turbogears import testutil +from monitorweb.controllers import Root +import cherrypy + +cherrypy.root = Root() + +class TestPages(unittest.TestCase): + + def setUp(self): + turbogears.startup.startTurboGears() + + def tearDown(self): + """Tests for apps using identity need to stop CP/TG after each test to + stop the VisitManager thread. + See http://trac.turbogears.org/turbogears/ticket/1217 for details. + """ + turbogears.startup.stopTurboGears() + + def test_method(self): + "the index method should return a string called now" + import types + result = testutil.call(cherrypy.root.index) + assert type(result["now"]) == types.StringType + + def test_indextitle(self): + "The indexpage should have the right title" + testutil.create_request("/") + response = cherrypy.response.body[0].lower() + assert "welcome to turbogears" in response + diff --git a/web/MonitorWeb/monitorweb/tests/test_model.py b/web/MonitorWeb/monitorweb/tests/test_model.py new file mode 100644 index 0000000..02e4d43 --- /dev/null +++ b/web/MonitorWeb/monitorweb/tests/test_model.py @@ -0,0 +1,22 @@ +# If your project uses a database, you can set up database tests +# similar to what you see below. Be sure to set the db_uri to +# an appropriate uri for your testing database. sqlite is a good +# choice for testing, because you can use an in-memory database +# which is very fast. + +from turbogears import testutil, database +# from monitorweb.model import YourDataClass, User + +# database.set_db_uri("sqlite:///:memory:") + +# class TestUser(testutil.DBTest): +# def get_model(self): +# return User +# def test_creation(self): +# "Object creation should set the name" +# obj = User(user_name = "creosote", +# email_address = "spam@python.not", +# display_name = "Mr Creosote", +# password = "Wafer-thin Mint") +# assert obj.display_name == "Mr Creosote" + diff --git a/web/MonitorWeb/sample-prod.cfg b/web/MonitorWeb/sample-prod.cfg new file mode 100644 index 0000000..be2bdb2 --- /dev/null +++ b/web/MonitorWeb/sample-prod.cfg @@ -0,0 +1,77 @@ +[global] +# This is where all of your settings go for your production environment. +# You'll copy this file over to your production server and provide it +# as a command-line option to your start script. +# Settings that are the same for both development and production +# (such as template engine, encodings, etc.) all go in +# monitorweb/config/app.cfg + +# DATABASE + +# driver://username:password@host:port/database + +# pick the form for your database +# sqlalchemy.dburi="postgres://username@hostname/databasename" +# sqlalchemy.dburi="mysql://username:password@hostname:port/databasename" +# sqlalchemy.dburi="sqlite:///file_name_and_path" + +# If you have sqlite, here's a simple default to get you started +# in development +sqlalchemy.dburi="sqlite:///%(current_dir_uri)s/devdata.sqlite" + + +# SERVER + +server.environment="production" + +# Sets the number of threads the server uses +# server.thread_pool = 1 + +# if this is part of a larger site, you can set the path +# to the TurboGears instance here +# server.webpath="" + +# Set to True if you are deploying your App behind a proxy +# e.g. Apache using mod_proxy +# base_url_filter.on = False + +# Set to True if your proxy adds the x_forwarded_host header +# base_url_filter.use_x_forwarded_host = True + +# If your proxy does not add the x_forwarded_host header, set +# the following to the *public* host url. +# (Note: This will be overridden by the use_x_forwarded_host option +# if it is set to True and the proxy adds the header correctly. +# base_url_filter.base_url = "http://www.example.com" + +# Set to True if you'd like to abort execution if a controller gets an +# unexpected parameter. False by default +# tg.strict_parameters = False + +# LOGGING +# Logging configuration generally follows the style of the standard +# Python logging module configuration. Note that when specifying +# log format messages, you need to use *() for formatting variables. +# Deployment independent log configuration is in monitorweb/config/log.cfg +[logging] + +[[handlers]] + +[[[access_out]]] +# set the filename as the first argument below +args="('server.log',)" +class='FileHandler' +level='INFO' +formatter='message_only' + +[[loggers]] +[[[monitorweb]]] +level='ERROR' +qualname='monitorweb' +handlers=['error_out'] + +[[[access]]] +level='INFO' +qualname='turbogears.access' +handlers=['access_out'] +propagate=0 diff --git a/web/MonitorWeb/setup.py b/web/MonitorWeb/setup.py new file mode 100644 index 0000000..fb2ed15 --- /dev/null +++ b/web/MonitorWeb/setup.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- + +from setuptools import setup, find_packages +from turbogears.finddata import find_package_data + +import os +execfile(os.path.join("monitorweb", "release.py")) + +packages=find_packages() +package_data = find_package_data(where='monitorweb', + package='monitorweb') +if os.path.isdir('locales'): + packages.append('locales') + package_data.update(find_package_data(where='locales', + exclude=('*.po',), only_in_packages=False)) + +setup( + name="MonitorWeb", + version=version, + # uncomment the following lines if you fill them out in release.py + #description=description, + #author=author, + #author_email=email, + #url=url, + #download_url=download_url, + #license=license, + + install_requires=[ + "TurboGears >= 1.0.7", + "SQLAlchemy>=0.3.10", + "Elixir>=0.4.0", + ], + zip_safe=False, + packages=packages, + package_data=package_data, + keywords=[ + # Use keywords if you'll be adding your package to the + # Python Cheeseshop + + # if this has widgets, uncomment the next line + # 'turbogears.widgets', + + # if this has a tg-admin command, uncomment the next line + # 'turbogears.command', + + # if this has identity providers, uncomment the next line + # 'turbogears.identity.provider', + + # If this is a template plugin, uncomment the next line + # 'python.templating.engines', + + # If this is a full application, uncomment the next line + # 'turbogears.app', + ], + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Framework :: TurboGears', + # if this is an application that you'll distribute through + # the Cheeseshop, uncomment the next line + # 'Framework :: TurboGears :: Applications', + + # if this is a package that includes widgets that you'll distribute + # through the Cheeseshop, uncomment the next line + # 'Framework :: TurboGears :: Widgets', + ], + test_suite='nose.collector', + entry_points = { + 'console_scripts': [ + 'start-monitorweb = monitorweb.commands:start', + ], + }, + # Uncomment next line and create a default.cfg file in your project dir + # if you want to package a default configuration in your egg. + #data_files = [('config', ['default.cfg'])], + ) diff --git a/web/MonitorWeb/start-monitorweb.py b/web/MonitorWeb/start-monitorweb.py new file mode 100755 index 0000000..b68edbf --- /dev/null +++ b/web/MonitorWeb/start-monitorweb.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +"""Start script for the MonitorWeb TurboGears project. + +This script is only needed during development for running from the project +directory. When the project is installed, easy_install will create a +proper start script. +""" + +import sys +from monitorweb.commands import start, ConfigurationError + +if __name__ == "__main__": + try: + start() + except ConfigurationError, exc: + sys.stderr.write(str(exc)) + sys.exit(1) diff --git a/web/MonitorWeb/test.cfg b/web/MonitorWeb/test.cfg new file mode 100644 index 0000000..e99d1a9 --- /dev/null +++ b/web/MonitorWeb/test.cfg @@ -0,0 +1,32 @@ +[global] +# You can place test-specific configuration options here (like test db uri, etc) + +# DATABASE + +sqlalchemy.dburi = "sqlite:///:memory:" + +# LOGGING + +[logging] + +[[formatters]] +[[[full_content]]] +format='*(asctime)s *(name)s *(levelname)s *(message)s' + +[[handlers]] +[[[test_out]]] +class='StreamHandler' +level='DEBUG' +args='(sys.stdout,)' +formatter='full_content' + +[[loggers]] +[[[monitorweb]]] +level='DEBUG' +qualname='monitorweb' +handlers=['test_out'] + +[[[turbogears]]] +level='INFO' +qualname='turbogears' +handlers=['test_out'] diff --git a/web/monitorweb-httpd.conf b/web/monitorweb-httpd.conf new file mode 100644 index 0000000..ee84b73 --- /dev/null +++ b/web/monitorweb-httpd.conf @@ -0,0 +1,33 @@ +NameVirtualHost 128.112.139.116:80 + + + ServerName pl-virtual-06.cs.princeton.edu + ServerAdmin soltesz@cs.princeton.edu + UseCanonicalName Off + ServerSignature Off + + DocumentRoot /usr/share/monitor/tgweb/MonitorWeb/monitorweb + + + Options Indexes FollowSymLinks + AllowOverride None + Order allow,deny + Allow from all + + + Errorlog /var/log/httpd/monitorwebapp-error_log + Customlog /var/log/httpd/monitorwebapp-access_log common + + AddDefaultCharset utf-8 + + # Load everything out of the DocumentRoot that is static + ProxyPass /monitor/static ! + + ProxyPass /monitor http://127.0.0.1:8080/ + ProxyPassReverse /monitor http://127.0.0.1:8080/ + ProxyPass /monitor/ http://127.0.0.1:8080/ + ProxyPassReverse /monitor/ http://127.0.0.1:8080/ + ProxyPreserveHost On + ProxyRequests Off + +