Permalink
Browse files

fixed pylint and pep8 warnings

  • Loading branch information...
1 parent dd15051 commit bef1afc750fbf072ec0d2524ea8681fb7be14bca @trey0 trey0 committed Sep 20, 2011
View
@@ -11,7 +11,6 @@
from django.core import urlresolvers
from geocamUtil import KmlUtil
-from geocamCore.models import Feature
from geocamLens.models import GoogleEarthSession
from geocamLens import settings
@@ -25,6 +24,8 @@ def build_absolute_uri(self, text):
class ViewKml(object):
+ search = None # override in derived classes
+
def kmlGetStartSessionKml(self, request, sessionId):
urlPath = urlresolvers.reverse('geocamLens_kmlGetSessionResponse',
args=[sessionId, 'initial'])
@@ -48,7 +49,7 @@ def kmlGetStartSessionKml(self, request, sessionId):
def kmlStartSession(self, request):
searchQuery = request.REQUEST.get('q', None)
sessionId = GoogleEarthSession.getSessionId(searchQuery)
- print >>sys.stderr, "ViewKml: started session %s" % sessionId
+ print >> sys.stderr, "ViewKml: started session %s" % sessionId
return KmlUtil.wrapKmlDjango(self.kmlGetStartSessionKml(request, sessionId))
def kmlGetAllFeaturesFolder(self, request, searchQuery, newUtime):
@@ -68,8 +69,8 @@ def kmlGetAllFeaturesFolder(self, request, searchQuery, newUtime):
def kmlGetInitialKml(self, request, sessionId):
newUtime = datetime.datetime.now()
- session, created = GoogleEarthSession.objects.get_or_create(sessionId=sessionId,
- defaults=dict(utime=newUtime))
+ session, _created = GoogleEarthSession.objects.get_or_create(sessionId=sessionId,
+ defaults=dict(utime=newUtime))
session.utime = newUtime
session.save()
@@ -146,9 +146,9 @@ def uploadImageAuth(self, request):
def uploadImage(self, request, userName):
author = User.objects.get(username=userName)
if request.method == 'POST':
- print >>sys.stderr, 'upload image start'
+ print >> sys.stderr, 'upload image start'
form = UploadImageForm(request.POST, request.FILES)
- print >>sys.stderr, 'FILES:', request.FILES.keys()
+ print >> sys.stderr, 'FILES:', request.FILES.keys()
if form.is_valid():
incoming = request.FILES['photo']
@@ -159,7 +159,7 @@ def uploadImage(self, request, userName):
for chunk in incoming.chunks():
storeFile.write(chunk)
storeFile.close()
- print >>sys.stderr, 'upload: saved image data to temp file:', tempStorePath
+ print >> sys.stderr, 'upload: saved image data to temp file:', tempStorePath
# create image db record
uuid = form.cleaned_data.setdefault('uuid', makeUuid())
@@ -173,7 +173,7 @@ def uploadImage(self, request, userName):
# the next higher resolution level in an incremental
# upload.
img = uuidMatches.get()
- print >>sys.stderr, 'upload: photo %s with same uuid %s posted' % (img.name, img.uuid)
+ print >> sys.stderr, 'upload: photo %s with same uuid %s posted' % (img.name, img.uuid)
newVersion = img.version + 1
else:
# create Image db record
@@ -192,11 +192,11 @@ def uploadImage(self, request, userName):
if sameUuid:
oldRes = (img.widthPixels, img.heightPixels)
if newRes > oldRes:
- print >>sys.stderr, 'upload: resolution increased from %d to %d' % (oldRes[0], newRes[0])
+ print >> sys.stderr, 'upload: resolution increased from %d to %d' % (oldRes[0], newRes[0])
img.widthPixels, img.heightPixels = newRes
img.processed = False
else:
- print >>sys.stderr, 'upload: ignoring dupe, but telling the client it was received so it stops trying'
+ print >> sys.stderr, 'upload: ignoring dupe, but telling the client it was received so it stops trying'
else:
img.widthPixels, img.heightPixels = newRes
@@ -214,19 +214,19 @@ def uploadImage(self, request, userName):
# after import by process(), can delete redundant temp copy
os.unlink(tempStorePath)
- print >>sys.stderr, 'upload image end'
+ print >> sys.stderr, 'upload image end'
# swfupload requires non-empty response text.
# also added a text pattern (in html comment) for clients to check against to make sure
# photo has actually arrived in share. we also put a matching line in the error log so we
# never again run into the issue that the phone thinks it successfully uploaded but there
# is no record of the http post on the server.
- print >>sys.stderr, 'GEOCAM_SHARE_POSTED %s' % img.name
+ print >> sys.stderr, 'GEOCAM_SHARE_POSTED %s' % img.name
return HttpResponse('file posted <!--\nGEOCAM_SHARE_POSTED %s\n-->' % img.name)
else:
- print >>sys.stderr, "form is invalid"
- print >>sys.stderr, "form errors: ", form._errors
+ print >> sys.stderr, "form is invalid"
+ print >> sys.stderr, "form errors: ", form._errors
userAgent = request.META.get('HTTP_USER_AGENT', '')
# swfupload user can't see errors in form response, best return an error code
if 'Flash' in userAgent:
@@ -239,7 +239,7 @@ def uploadImage(self, request, userName):
author=author,
),
context_instance=RequestContext(request))
- print >>sys.stderr, 'upload image end'
+ print >> sys.stderr, 'upload image end'
return resp
def viewPhoto(self, request, imgId):
@@ -10,23 +10,17 @@
import sys
import os
-import datetime
import glob
import csv
import re
import uuid
import getpass
import stat
-import PIL
-import pytz
-import tagging
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
-from geocamUtil import TimeUtil
-from geocamUtil.FileUtil import mkdirP
-from geocamCore.models import Feature, Folder
+from geocamCore.models import Feature
from geocamLens.UploadClient import UploadClient
from geocamLens.models import Photo
@@ -69,22 +63,14 @@ def getBogusUuid(name, userName, timeStr):
return str(uuid.uuid3(uuid.NAMESPACE_DNS, '%s-%s-%s' % (name, userName, timeStr)))
-def importDir(opts, dir, uploadClient):
- dir = os.path.realpath(dir)
+def importDir(opts, d, uploadClient):
+ d = os.path.realpath(d)
- tzFile = '%s/timezone.txt' % dir
- if os.path.exists(tzFile):
- timeZone = file(tzFile, 'r').read().strip()
- else:
- timeZone = 'US/Pacific' # default
-
- folderName = os.path.basename(dir)
- if not opts.upload:
- folder, created = Folder.objects.get_or_create(name=folderName)
+ folderName = os.path.basename(d)
photosToUpload = []
- csvFiles = glob.glob('%s/*.csv' % dir)
+ csvFiles = glob.glob('%s/*.csv' % d)
if csvFiles:
csvName = csvFiles[0]
reader = csv.reader(file(csvName, 'r'))
@@ -107,7 +93,7 @@ def importDir(opts, dir, uploadClient):
lat, lon, compass = float(latStr), float(lonStr), float(compassStr)
if lat == -999:
lat, lon = None, None
- imagePath = os.path.join(dir, 'photos', name)
+ imagePath = os.path.join(d, 'photos', name)
# make up a consistent bogus uuid field so we can test incremental upload.
# real clients should always make a stronger uuid to avoid collisions!
@@ -135,10 +121,10 @@ def importDir(opts, dir, uploadClient):
else:
images = []
for ext in ('.jpg', '.jpeg', '.JPG'):
- images += glob.glob('%s/*%s' % (dir, ext))
+ images += glob.glob('%s/*%s' % (d, ext))
if images:
if opts.match:
- print >>sys.stderr, "warning: can't import dir %s -- can't match tags unless we have a .csv" % dir
+ print >> sys.stderr, "warning: can't import dir %s -- can't match tags unless we have a .csv" % d
images = []
if opts.number != 0:
images = images[:opts.number]
@@ -155,7 +141,7 @@ def importDir(opts, dir, uploadClient):
photosToUpload.append(dict(imagePath=img,
attributes=attributes))
else:
- print >>sys.stderr, "warning: can't import dir %s -- no *.csv, no images" % dir
+ print >> sys.stderr, "warning: can't import dir %s -- no *.csv, no images" % d
for p in photosToUpload:
if uploadClient:
@@ -186,8 +172,8 @@ def doit(opts, importDirs):
for f in features:
f.deleteFiles()
f.delete()
- for dir in importDirs:
- importDir(opts, dir, uploadClient)
+ for d in importDirs:
+ importDir(opts, d, uploadClient)
def main():
@@ -222,7 +208,7 @@ def main():
help='Downsample images by specified factor before upload. Implies -u.')
opts, args = parser.parse_args()
if not args:
- print >>sys.stderr, 'warning: no import dirs specified, not importing anything'
+ print >> sys.stderr, 'warning: no import dirs specified, not importing anything'
importDirs = args
doit(opts, importDirs)
@@ -30,7 +30,7 @@ def handle_noargs(self, **options):
svgOutput = '%s/build/media/geocamLens/icons/map/' % appDir
if settings.GEOCAM_LENS_RENDER_SVG_ICONS:
svgGlob = '%s/media_src/icons/*.svg' % appDir
- logging.debug('svgIcons %s %s' % (svgGlob, svgOutput))
+ logging.debug('svgIcons %s %s', svgGlob, svgOutput)
for imPath in glob(svgGlob):
svg.buildIcon(builder, imPath, outputDir=svgOutput)
@@ -41,7 +41,7 @@ def handle_noargs(self, **options):
# make highlighted versions of icons
dstGlob = svgOutput + '*.png'
- logging.debug('highlightIcons %s' % dstGlob)
+ logging.debug('highlightIcons %s', dstGlob)
for dst in glob(dstGlob):
if 'Highlighted' in dst:
continue
@@ -51,6 +51,6 @@ def handle_noargs(self, **options):
# rotate pngs
rotGlob = '%s/build/media/geocamLens/icons/map/*Point*.png' % appDir
rotOutput = '%s/build/media/geocamLens/icons/mapr' % appDir
- logging.debug('rotateIcons %s %s' % (rotGlob, rotOutput))
+ logging.debug('rotateIcons %s %s', rotGlob, rotOutput)
for imPath in glob(rotGlob):
rotate.buildAllDirections(builder, imPath, outputDir=rotOutput)
View
@@ -3,8 +3,3 @@
# the Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# __END_LICENSE__
-
-from django.shortcuts import render_to_response
-from django.http import HttpResponseRedirect, HttpResponseForbidden, Http404
-from django.template import RequestContext
-from django.utils.translation import ugettext, ugettext_lazy as _

0 comments on commit bef1afc

Please sign in to comment.