Permalink
Browse files

moved apps/geocamTrack content into separate repo submodules/geocamTr…

…ackWeb
  • Loading branch information...
1 parent cf14d7e commit 45358c6350ce1d0f2f13a783aa95dc0c3e68f1d4 @trey0 committed Mar 10, 2011
Showing with 7 additions and 2,230 deletions.
  1. +1 −4 .gitignore
  2. +3 −0 .gitmodules
  3. +0 −47 apps/geocamTrack/README.rst
  4. +0 −38 apps/geocamTrack/__init__.py
  5. +0 −18 apps/geocamTrack/admin.py
  6. +0 −192 apps/geocamTrack/avatar.py
  7. +0 −48 apps/geocamTrack/bin/addResourceDisplayNames.py
  8. +0 −262 apps/geocamTrack/bin/clientSim.py
  9. +0 −20 apps/geocamTrack/bin/exampleResourceDisplayNames.txt
  10. +0 −7 apps/geocamTrack/defaultSettings.py
  11. +0 −39 apps/geocamTrack/latitude/README.rst
  12. 0 apps/geocamTrack/latitude/__init__.py
  13. +0 −11 apps/geocamTrack/latitude/admin.py
  14. +0 −93 apps/geocamTrack/latitude/client.py
  15. +0 −17 apps/geocamTrack/latitude/models.py
  16. +0 −28 apps/geocamTrack/latitude/tests.py
  17. +0 −29 apps/geocamTrack/latitude/urls.py
  18. +0 −131 apps/geocamTrack/latitude/views.py
  19. BIN apps/geocamTrack/media_src/mapIcons/placard.png
  20. +0 −111 apps/geocamTrack/models.py
  21. +0 −9 apps/geocamTrack/static/external/css/jquery.mobile-1.0a2.min.css
  22. BIN apps/geocamTrack/static/external/icons/ajax-loader.png
  23. BIN apps/geocamTrack/static/external/icons/close_button.gif
  24. BIN apps/geocamTrack/static/external/icons/dot.png
  25. BIN apps/geocamTrack/static/external/icons/form-check-off.png
  26. BIN apps/geocamTrack/static/external/icons/form-check-on.png
  27. BIN apps/geocamTrack/static/external/icons/form-radio-off.png
  28. BIN apps/geocamTrack/static/external/icons/form-radio-on.png
  29. BIN apps/geocamTrack/static/external/icons/icon-search-black.png
  30. BIN apps/geocamTrack/static/external/icons/icons-18-black.png
  31. BIN apps/geocamTrack/static/external/icons/icons-18-white.png
  32. BIN apps/geocamTrack/static/external/icons/icons-36-black.png
  33. BIN apps/geocamTrack/static/external/icons/icons-36-white.png
  34. BIN apps/geocamTrack/static/external/icons/loading.gif
  35. +0 −41 apps/geocamTrack/static/external/js/infobubble-compiled.js
  36. +0 −167 apps/geocamTrack/static/external/js/jquery-1.4.4.min.js
  37. +0 −99 apps/geocamTrack/static/external/js/jquery.mobile-1.0a2.min.js
  38. +0 −60 apps/geocamTrack/static/geocamTrack/js/geocamTrack.js
  39. +0 −12 apps/geocamTrack/templates/latitudeIndex.html
  40. +0 −27 apps/geocamTrack/templates/latitudeSignup.html
  41. +0 −9 apps/geocamTrack/templates/latitudeSignupComplete.html
  42. +0 −471 apps/geocamTrack/templates/liveMap.html
  43. +0 −15 apps/geocamTrack/templates/trackingIndex.html
  44. +0 −34 apps/geocamTrack/tests.py
  45. +0 −41 apps/geocamTrack/urls.py
  46. +0 −150 apps/geocamTrack/views.py
  47. +2 −0 management/bootstrap.py
  48. +1 −0 submodules/geocamTrackWeb
View
@@ -10,7 +10,4 @@
/settings.py
/sourceme.sh
/gigapan
-/apps/geocamUtil
-/apps/geocamCore
-/apps/geocamAware
-/apps/geocamLens
+/apps
View
@@ -12,3 +12,6 @@
[submodule "submodules/geocamCoreWeb"]
path = submodules/geocamCoreWeb
url = git@github.com:geocam/geocamCoreWeb.git
+[submodule "submodules/geocamTrackWeb"]
+ path = submodules/geocamTrackWeb
+ url = git://github.com/geocam/geocamTrackWeb.git
@@ -1,47 +0,0 @@
-=========================================
-GeoCam Share Tracking Module
-=========================================
-
-.. sectnum::
-
-.. contents:: Contents
-
-About
-~~~~~
-
-The tracking module is currently (Oct 2010) a prototype of how we could
-handle tracking live resource positions using GeoCam Share. The intent
-is to add a matching position posting feature to GeoCam Mobile, and we
-could also accept position info from other sources.
-
-Installation
-~~~~~~~~~~~~
-
-Follow the normal directions for installing GeoCam Share. If you're
-updating an existing install, you'll need to run ``./manage.py syncdb``
-to add the new DB tables.
-
-To see the prototype display, load http://localhost:8000/tracking/liveMap/
-or the corresponding URL on your server. Initially, the map won't have
-any markers.
-
-To add some markers and simulate movement, run
-``geocamTrack/clientSim.py -s 100 -v``. This simulates five clients
-driving around at 100 km/h and posting independent position updates at
-about 1 Hz each. (This live map is designed to be engaging. Note that
-real clients will probably post updates at most once every 30 seconds.)
-
-Currently, the database only stores the most recent position update for
-each resource. Later, we'll want to have some capability to store and
-display tracks as well. We'll also want the display integrated with
-the existing GeoCam Share map interface.
-
-If you'd like to see the data format the simulated clients are posting
-in, you can run clientSim with the ``-vv`` option.
-
-| __BEGIN_LICENSE__
-| Copyright (C) 2008-2010 United States Government as represented by
-| the Administrator of the National Aeronautics and Space Administration.
-| All Rights Reserved.
-| __END_LICENSE__
-
@@ -1,38 +0,0 @@
-# __BEGIN_LICENSE__
-# Copyright (C) 2008-2010 United States Government as represented by
-# the Administrator of the National Aeronautics and Space Administration.
-# All Rights Reserved.
-# __END_LICENSE__
-
-"""
-geocamTrackWeb
-"""
-
-import django.conf
-
-from geocamUtil.MultiSettings import MultiSettings
-from geocamTrack import defaultSettings
-
-__version_info__ = {
- 'major': 0,
- 'minor': 1,
- 'micro': 0,
- 'releaselevel': 'final',
- 'serial': 1
-}
-
-def get_version():
- """
- Return the formatted version information
- """
- vers = ["%(major)i.%(minor)i" % __version_info__, ]
-
- if __version_info__['micro']:
- vers.append(".%(micro)i" % __version_info__)
- if __version_info__['releaselevel'] != 'final':
- vers.append('%(releaselevel)s%(serial)i' % __version_info__)
- return ''.join(vers)
-
-__version__ = get_version()
-
-settings = MultiSettings(django.conf.settings, defaultSettings)
View
@@ -1,18 +0,0 @@
-# __BEGIN_LICENSE__
-# Copyright (C) 2008-2010 United States Government as represented by
-# the Administrator of the National Aeronautics and Space Administration.
-# All Rights Reserved.
-# __END_LICENSE__
-
-from django.contrib import admin
-
-from geocamTrack.models import *
-from geocamTrack import settings
-
-admin.site.register(Resource)
-admin.site.register(ResourcePosition)
-admin.site.register(PastResourcePosition)
-
-if settings.GEOCAM_TRACK_LATITUDE_ENABLED:
- # register latitude-related models with admin
- from geocamTrack.latitude import admin
View
@@ -1,192 +0,0 @@
-# __BEGIN_LICENSE__
-# Copyright (C) 2008-2010 United States Government as represented by
-# the Administrator of the National Aeronautics and Space Administration.
-# All Rights Reserved.
-# __END_LICENSE__
-
-import hashlib
-import urllib2
-import os
-import os.path as op
-import sys
-import time
-import stat
-import re
-from StringIO import StringIO
-
-from PIL import Image, ImageDraw, ImageFont, ImageOps
-from django.contrib.auth.models import User
-
-from geocamTrack import settings
-
-trackAppDir = os.path.dirname(__file__)
-
-AVATAR_DIR = '%sgeocamTrack/avatars' % settings.MEDIA_ROOT
-GRAVATAR_DIR = '%s/gravatars' % AVATAR_DIR
-CACHE_DIR = '%s/cache' % AVATAR_DIR
-PLACARD_FRESH = '%s/media_src/mapIcons/placard.png' % trackAppDir
-
-# time to wait to refresh avatar image
-AVATAR_CACHE_SECONDS = 24*60*60
-
-# time to wait before retry after failed gravatar fetch
-GRAVATAR_FAIL_RETRY_SECONDS = 24*60*60
-
-# time to wait before refresh after successful gravatar fetch
-GRAVATAR_SUCCESS_REFRESH_SECONDS = 24*60*60
-
-def mkdirP(dir):
- if not os.path.exists(dir):
- os.makedirs(dir)
-
-def fetchGravatarImage(email, fname):
- '''Grabs the Gravatar image for the given email address and writes it to
- fname. Returns False on error.'''
- hex = hashlib.md5(email.strip().lower()).hexdigest()
- url = 'http://www.gravatar.com/avatar/%s.jpg?d=404' % hex
- req = urllib2.Request(url)
- try:
- response = urllib2.urlopen(req)
- except urllib2.URLError, e:
- if hasattr(e, 'reason'):
- print >>sys.stderr, 'fetch %s -- failed to reach a server' % url
- print >>sys.stderr, 'Reason: ', e.reason
- elif hasattr(e, 'code'):
- print >>sys.stderr, 'fetch %s -- server couldn\'t fulfill request' % url
- print >>sys.stderr, 'Error code: ', e.code
- return False
- mkdirP(os.path.dirname(fname))
- out = file(fname, 'w')
- out.write(response.read())
- out.close()
- return True
-
-def getAge(fname):
- if os.path.exists(fname):
- mtime = os.stat(fname)[stat.ST_MTIME]
- return time.time() - mtime
- else:
- return time.time()
-
-def getGravatarPath(userName, email):
- """Returns a path on local disk that points to the gravatar icon for
- the given user, or None if we couldn't fetch one. Caches past query
- results for efficiency."""
- failFname = '%s/%s-fail.txt' % (GRAVATAR_DIR, userName)
- successFname = '%s/%s.jpg' % (GRAVATAR_DIR, userName)
-
- if os.path.exists(successFname):
- if getAge(successFname) < GRAVATAR_SUCCESS_REFRESH_SECONDS:
- return successFname
- else:
- os.unlink(successFname)
-
- if os.path.exists(failFname):
- if getAge(failFname) < GRAVATAR_FAIL_RETRY_SECONDS:
- return None
- else:
- os.unlink(failFname)
-
- mkdirP(os.path.dirname(failFname))
- file(failFname, 'w').close()
- status = fetchGravatarImage(email, successFname)
- if status:
- os.unlink(failFname)
- return successFname
- else:
- return None
-
-def parse_params(params):
- color = None
- if 'color' in params:
- if re.match(r'^[0-9a-fA-F]{6}$', params['color']):
- color = params['color'].lower()
-
- scale = None
- if 'scale' in params:
- try:
- scale = float(params['scale'])
- except ValueError:
- pass
-
- stale = False
- if 'stale' in params:
- stale = True
-
- return (color, scale, stale)
-
-def getAvatarCacheName(userName, color, scale, stale):
- # See if we can return cached image
- image_name = userName
- if color:
- image_name += "_%s" % color
- if scale:
- image_name += "_%s" % scale
- if stale:
- image_name += '_stale'
- image_name += '.png'
- return op.join(CACHE_DIR, image_name);
-
- return
-
-def renderAvatar(request, userName):
- # Parse junk
- (color, scale, stale) = parse_params(request.REQUEST)
- cachedName = getAvatarCacheName(userName, color, scale, stale)
-
- if os.path.exists(cachedName) and getAge(cachedName) > AVATAR_CACHE_SECONDS:
- os.unlink(cachedName)
-
- if op.exists(cachedName):
- return open(cachedName, 'r').read()
-
- placard = Image.open(PLACARD_FRESH)
-
- # Colorize base placard
- if color:
- placard.load()
- bands = placard.split()
- placardGray = placard.convert("L")
- placardColored = ImageOps.colorize(placardGray,
- "#000000",
- "#" + color);
- placard = placardColored.convert("RGBA");
- placard.putalpha(bands[3]);
-
- # Find avatar, gravatar or lettered image
- avatar = None
- avatar_file = op.join(AVATAR_DIR, "%s.png" % userName)
- if op.exists(avatar_file):
- avatar = Image.open(avatar_file)
- else:
- featureUser = User.objects.get(username=userName)
- gravPath = getGravatarPath(userName, featureUser.email)
- if gravPath:
- avatar = Image.open(gravPath)
- else:
- avatar = Image.new("RGB", (8, 8), "#FFFFFF")
- font = ImageFont.load_default()
- draw = ImageDraw.Draw(avatar)
- draw.text((1, -2), userName.upper()[0], font=font, fill=0)
- del draw
-
- # Paste generated/opened image into placard
- avatar = avatar.resize((36,36))
- placard.paste(avatar, (10, 8))
-
- # Optionally scale image
- if scale:
- new_size = (int(placard.size[0] * scale),
- int(placard.size[1] * scale))
- placard = placard.resize(new_size)
-
- # Save image in cache
- dir = os.path.dirname(cachedName)
- if not os.path.exists(dir):
- os.makedirs(dir)
- placard.save(cachedName, "PNG")
-
- # Send image to browser
- strio = StringIO()
- placard.save(strio, "PNG")
- return strio.getvalue()
@@ -1,48 +0,0 @@
-#!/usr/bin/env python
-# __BEGIN_LICENSE__
-# Copyright (C) 2008-2010 United States Government as represented by
-# the Administrator of the National Aeronautics and Space Administration.
-# All Rights Reserved.
-# __END_LICENSE__
-
-import re
-import sys
-
-from geocamTrack.models import Resource
-
-def doit(opts, args):
- for fname in args:
- f = file(fname, 'r')
- for line in f:
- line = line[:-1] # chop final cr
- # remove comments
- line = re.sub(r'\s*\#.*$', '', line)
- # skip blank lines
- if line == '':
- continue
- print line
- # userName, displayName in format: 'jdoe:John Doe'
- userName, displayName = [s.strip() for s in line.split(':', 1)]
- matches = Resource.objects.filter(userName=userName)
- if matches:
- resource = matches[0]
- resource.displayName = displayName
- resource.save()
- else:
- print >>sys.stderr, 'warning: no resource with userName "%s"' % userName
-
-def main():
- import optparse
- parser = optparse.OptionParser('''usage: %prog <names.txt> [moreNames.txt] ...
-
-Takes a bulk file of (userName, displayName) pairs where each line is in
-the format 'jdoe:John Doe, Some Unit'. Finds the geocamTrack Resource
-with that userName and assigns it the specified displayName.''')
- opts, args = parser.parse_args()
-
- if not args:
- parser.error('expected at least one argument')
- doit(opts, args)
-
-if __name__ == '__main__':
- main()
Oops, something went wrong.

0 comments on commit 45358c6

Please sign in to comment.