Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add in setup page

  • Loading branch information...
commit 7a36086b7407b9f9dd3ad3abfbfc171d4fc41b17 1 parent 8f3e9d1
Andy McKay authored
View
48 README
@@ -2,50 +2,6 @@ This is the open source Arecibo client that allows you to record errors on your
This is an App Engine project that you can upload to App Engine and run this application, then point all your sites to use that system.
-Creating an App Engine instance
------------------------
+Documentation is available in the listener/docs folder.
-- create an App Engine instance at https://appengine.google.com/ (this is free)
-
-- the name of your instance is used in the next step, examples could be my-company-arecibo which would give you an App Engine instance at http://my-company-arecibo.appspot.com
-
-Download the App Engine API
------------------------
-
-- if you don't already have it, you need to download the App Engine API: http://code.google.com/appengine/downloads.html
-
-Creating your App Engine site
------------------------
-
-- grab a copy of this site, from github http://github.com/andymckay/arecibo/, eg: git clone git://github.com/andymckay/arecibo.git
-
-- in the listener/app_engine directory:
-
- - copy local_settings.py.example to local_settings.py. Set whatever key you would like for ARECIBO_PUBLIC_ACCOUNT_NUMBER or ARECIBO_PRIVATE_ACCOUNT_NUMBER. The ARECIBO_PUBLIC_ACCOUNT_NUMBER is what you send from your websites
-
- - copy app.yaml.example to app.yaml and set the application: to match the name of the application you've created on App Engine
-
-Deploy your app
------------------------
-
-- in the listener/app_engine directory:
-
- - appcfg.py update .
-
-Congrats, your Arecibo app has now been deployed.
-
-Logging in users
------------------------
-
-- any user with a Google account can login to your Arecibo account, however they cannot view anything at all until you give them access.
-
-- as the admin go to your App Engine admin console http://code.google.com/appengine/docs/theadminconsole.html, go to your app > datastore viewer > select user from the drop down > find user > and set "is_staff" to True
-
-- if you got Google Apps already for your domain, then you can restrict the login just to your domain in App Engine
-
-Send errors to your app
------------------------
-
-To send errors to the app, you just to send HTTP posts to http://my-company-arecibo.appspot.com/v/1/
-
-The API key must match what you set in local_settings, otherwise Arecibo will just reject the post.
+If you'd like to read the up to date documentation in HTML format, please visit http://areciboapp.com/docs.
View
27 clients/python/arecibo.py
@@ -11,16 +11,20 @@
from urllib import urlencode
from urlparse import urlparse
-from socket import gethostname, getdefaulttimeout, setdefaulttimeout
+try:
+ from socket import gethostname, getdefaulttimeout, setdefaulttimeout
+except ImportError:
+ # App Engine doesn't have these
+ # so here are a some replacements
+ def gethostname(): return "unknown"
+ def getdefaulttimeout(): return 60
+ def setdefaulttimeout(num): pass
+
from email.Utils import formatdate
import smtplib
import simplejson
-posturl = "http://www.areciboapp.com/v/1/"
-postaddress = "arecibo@clearwind.ca"
-url = urlparse(posturl)
-
keys = ["account", "ip", "priority", "uid",
"type", "msg", "traceback", "user_agent",
"url", "status", "server", "timestamp",
@@ -29,11 +33,13 @@
required = [ "account", ]
class post:
- def __init__(self):
+ def __init__(self, url, address):
self._data = {}
self.transport = "http"
self.smtp_server = "localhost"
self.smtp_from = "noreply@clearwind.ca"
+ self.post_url = urlparse(url)
+ self.post_address = address
self.set("server", gethostname())
self.set("timestamp", formatdate())
@@ -80,9 +86,9 @@ def _send_smtp(self):
def _send_http(self):
if self.transport == "https" and has_https:
- h = HTTPSConnection(url[1])
+ h = HTTPSConnection(self.post_url[1])
else:
- h = HTTPConnection(url[1])
+ h = HTTPConnection(self.post_url[1])
headers = {
"Content-type": 'application/x-www-form-urlencoded; charset="utf-8"',
"Accept": "text/plain"}
@@ -90,7 +96,7 @@ def _send_http(self):
oldtimeout = getdefaulttimeout()
try:
setdefaulttimeout(10)
- h.request("POST", url[2], data, headers)
+ h.request("POST", self.post_url[2], data, headers)
reply = h.getresponse()
if reply.status != 200:
@@ -99,8 +105,7 @@ def _send_http(self):
setdefaulttimeout(oldtimeout)
if __name__=='__main__':
- new = post()
- #new.transport = "https"
+ new = post(url="http://test-areciboapp.appspot.com")
new.set("account", "YOUR KEY HERE")
new.set("priority", 4)
new.set("user_agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X...")
View
9 listener/app_engine/404.html
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block content %}
+<div class="span-22 prepend-2 last">
+<h2>Page not found</h2>
+<p>Oops.</p>
+</div>
+
+{% endblock %}
View
9 listener/app_engine/500.html
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block content %}
+<div class="span-22 prepend-2 last">
+<h2>Application error.</h2>
+<p>Oops.</p>
+</div>
+
+{% endblock %}
View
3  listener/app_engine/app/context.py
@@ -1,8 +1,11 @@
from urllib import urlencode
+from django.conf import settings
def context(request):
data = {}
data["user"] = request.user
+ data["public_key"] = settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER
+ data["private_key"] = settings.ARECIBO_PRIVATE_ACCOUNT_NUMBER
ignore = ["page",]
qs = request.GET.copy()
View
1  listener/app_engine/app/templates/base.html
@@ -30,6 +30,7 @@
{% else %}
<a href="{% url error-list %}" {% ifequal nav.selected "list" %}class="selected"{% endifequal %}>List</a>
<a href="{% url notification-list %}" {% ifequal nav.selected "notifications" %}class="selected"{% endifequal %}>Notifications</a>
+ <a href="{% url setup %}" {% ifequal nav.selected "setup" %}class="selected"{% endifequal %}>Setup</a>
<a href="{% url logout %}">Logout</a>
{% endif %}
</div>
View
14 listener/app_engine/app/templates/setup.html
@@ -0,0 +1,14 @@
+{% extends "base.html" %}
+{% block content %}
+<h2>Setup</h2>
+<p>The following are your API keys:</p>
+<dl>
+<dt>Public key</dt>
+<dd>{{ public_key }}
+ <p class="help">Use this in your error reporting</p>
+</dd>
+<dt>Private key</dt>
+<dd>{{ private_key }}</dd>
+</dl>
+
+{% endblock %}
View
1  listener/app_engine/app/urls.py
@@ -6,4 +6,5 @@
url(r'^lib/error-compress.js', 'app.views.javascript_client', name="error-javascript-compressed"),
url(r'^accounts/login/$', 'app.views.login', name="login"),
url(r'^accounts/logout/$', 'app.views.logout', name="logout"),
+ url(r'^setup$', 'app.views.setup', name="setup")
)
View
5 listener/app_engine/app/views.py
@@ -12,6 +12,11 @@ def index(request):
return HttpResponseRedirect(reverse("error-list"))
return direct_to_template(request, "index.html")
+def setup(request):
+ return direct_to_template(request, "setup.html", extra_context={
+ "nav": {"selected": "setup"}
+ })
+
def javascript_client(request):
return direct_to_template(request, "error.js", extra_context={"domain":urlparse(settings.SITE_URL)[1]})
View
6 listener/app_engine/index.yaml
@@ -137,6 +137,12 @@ indexes:
- name: timestamp
direction: desc
+- kind: Error
+ properties:
+ - name: uid
+ - name: timestamp
+ direction: desc
+
- kind: Notification
properties:
- name: tried
View
6 listener/app_engine/media/css/site.css
@@ -70,4 +70,8 @@ table.listing thead th {
border-collapse: collapse;
}
-h1, h2, h3 { font-family: 'Droid Serif', arial, serif; }
+h1, h2, h3 { font-family: 'Droid Serif', arial, serif; }
+
+.help {
+ color: grey;
+}
View
12 listener/app_engine/notifications/models.py
@@ -1,5 +1,6 @@
from datetime import datetime
+from google.appengine.api import memcache
from appengine_django.models import BaseModel
from appengine_django.auth.models import User
@@ -31,4 +32,13 @@ def save(self):
notification_created.send(sender=self.__class__, instance=self)
def user_list(self):
- return [ User.get(key) for key in self.user ]
+ users = []
+ for key in self.user:
+ data = memcache.get(key)
+ if data:
+ users.append(data)
+ else:
+ user = User.get(key)
+ users.append(user)
+ memcache.set(key, user, 60)
+ return users
View
2  listener/app_engine/notifications/templates/notification_list.html
@@ -17,7 +17,7 @@
<tr class="{% cycle 'odd' 'even' %}">
<td><abbr title="{{ notification.timestamp|date:"d M, Y P" }}">{{ notification.timestamp|timesince }}</abbr></td>
<td><a href="{% url error-view notification.error.id %}">{{ notification.error.title }}</td>
- <td><abbr title="{{ notification.user_list|join:', ' }}">{{ notification.user_list.0.username }}{% if notification.user_list.count > 1 %}...{% endif %}</abbr></td>
+ <td>{% with notification.user_list as list %}<abbr title="{{ list|join:', ' }}">{{ list.0.username }}{% if list.count > 1 %}...{% endif %}{% endwith %}</abbr></td>
<td>{{ notification.tried|yesno }}</td>
<td>{{ notification.completed|yesno }}</td>
<td>{% if notification.error_msg %}{{ notification.error_msg }}{% endif %}</td>
View
4 listener/app_engine/notifications/views.py
@@ -18,7 +18,9 @@
@user_passes_test(lambda u: u.is_staff)
def notifications_list(request):
queryset = Notification.all().order("-timestamp")
- paginated = Paginator(queryset, 50)
+ # this number doesn't need to be high and its quite an expensive
+ # page to generate
+ paginated = Paginator(queryset, 10)
page = get_page(request, paginated)
return direct_to_template(request, "notification_list.html", extra_context={
"page": page,
View
3  listener/app_engine/urls.py
@@ -20,3 +20,6 @@
(r'', include('app.urls')),
(r'^notification/', include('notifications.urls')),
)
+
+handler404 = 'app.errors.not_found_error'
+handler500 = 'app.errors.application_error'
View
1  listener/docs/source/index.rst
@@ -10,6 +10,7 @@ Contents:
quickstart.rst
server/index.rst
server/installation.rst
+ server/useraccess.rst
client/index.rst
client/post.rst
client/variables.rst
View
17 listener/docs/source/server/installation.rst
@@ -6,7 +6,7 @@ Requirements
You will require a App Engine application. You can create a free one at http://appengine.google.com/.
-So you can push to to the server you will need a copy of the **Python** App Engine SDK installed, you can get that here: http://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Python.
+To deploy you copy of Arecibo to App Engine you will need a copy of the SDK. You can get the *Python* version of the App Engine SDK here: http://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Python.
You will need git to check out Arecibo from github: http://git-scm.com/.
@@ -17,11 +17,16 @@ Installation steps
The following are done on Mac OS X. Other operating systems may vary.
-1. Create an App Engine instance
+1 a. Create an App Engine instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At http://appengine.google.com/ create a new App Engine application. Give your new App Engine installation a unique name. This is the **app name** that we will be using in later steps.
+1 b. Install the Google App Engine SDK
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Install the Google App Engine SDK. If you already have it installed, you can skip this step.
+
2. Download Arecibo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -49,7 +54,7 @@ Alter the first line of *app.yaml*::
application: your_application_error
-Replacing *your_application_error* with the unique name of your application from step 1.
+Replacing *your_application_error* with the **app name** of your application from step 1.
Second *local_settings.py*::
@@ -63,9 +68,7 @@ Then alter the file as detailed::
DEFAULT_FROM_EMAIL = "you.account@gmail.com.that.is.authorized.for.app_engine"
SITE_URL = "http://theurl.to.your.arecibo.instance.com"
-*ARECIBO_PUBLIC_ACCOUNT_NUMBER* should be a unique id that you'll be using to post to your site. This can be anything you like. Normally a random string 32 characters long.
-
-*ARECIBO_PRIVATE_ACCOUNT_NUMBER* should be a unique id that you'll be using to read from your site. This can be anything you like. Normally a random string 32 characters long.
+*ARECIBO_PUBLIC_ACCOUNT_NUMBER* and *ARECIBO_PRIVATE_ACCOUNT_NUMBER* should be unique id that you'll be using to post to your site. This can be anything you like. Normally a random string 32 characters long.
*DEFAULT_FROM_EMAIL* is the Google email address you used to setup your App Engine site. This has to be an email that is authorized by App Engine, the simplest is to use the one you created you site with.
@@ -82,7 +85,7 @@ An example file might be::
4. Copy over Django
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Download and copy over Django so we can be sure we use the version of Django that is compatible, not the the one that comes by default::
+Download and copy over Django (this is not included for licensing reasons). Then we can be sure we use the version of Django that is compatible, not the the one that comes by default with App Engine::
~/arecibo/listener/app_engine $ wget http://media.djangoproject.com/releases/1.2/Django-1.2.1.tar.gz
..

0 comments on commit 7a36086

Please sign in to comment.
Something went wrong with that request. Please try again.