Skip to content

Commit

Permalink
Fixed some encoding issues.. mainly in plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jkakavas committed Jan 4, 2014
1 parent 3fb7912 commit d26b55f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion creepy/models/LocationsList.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def data(self, index, role):
if column == 0:
return QVariant(location.datetime.isoformat())
if column == 1:
return QVariant(location.shortName)
return QVariant(location.shortName.encode('utf-8'))
else:
return QVariant()

Expand Down
9 changes: 6 additions & 3 deletions creepy/plugins/flickr/flickr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import os
from configobj import ConfigObj
from flickrapi.exceptions import FlickrError
from utilities import GeneralUtilities
#set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(os.path.join(GeneralUtilities.getUserHome(),'creepy_main.log'))
fh = logging.FileHandler(os.path.join(os.getcwdu(),'creepy_main.log'))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
Expand Down Expand Up @@ -118,7 +117,11 @@ def getLocationsFromPhotos(self, photos):
loc = {}
loc['plugin'] = "flickr"
photo_link = 'http://www.flickr.com/photos/%s/%s' % (photo.attrib['owner'], photo.attrib['id'])
loc['context'] = 'Photo from flickr \n Title : %s \n ' % (photo.attrib['title'])
title = photo.attrib['title']
#If the title is a string, make it unicode
if isinstance(title,str):
title = title.decode('utf-8')
loc['context'] = u'Photo from flickr \n Title : %s \n ' % (title)
loc['date'] = datetime.datetime.strptime(photo.attrib['datetaken'], "%Y-%m-%d %H:%M:%S")
loc['lat'] = photo.attrib['latitude']
loc['lon'] = photo.attrib['longitude']
Expand Down
13 changes: 6 additions & 7 deletions creepy/plugins/instagram/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import urllib
from urlparse import urlparse, parse_qs
from configobj import ConfigObj
from utilities import GeneralUtilities
#set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(os.path.join(GeneralUtilities.getUserHome(),'creepy_main.log'))
fh = logging.FileHandler(os.path.join(os.getcwdu(),'creepy_main.log'))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
Expand Down Expand Up @@ -127,7 +126,7 @@ def runConfigWizard(self):



wizard = QWizard()
self.wizard = QWizard()
page1 = QWizardPage()

layout1 = QVBoxLayout()
Expand All @@ -154,9 +153,9 @@ def runConfigWizard(self):
layout1.addWidget(labelLink)
layout1.addWidget(inputLink)
page1.setLayout(layout1)
wizard.addPage(page1)
wizard.resize(600,400)
if wizard.exec_():
self.wizard.addPage(page1)
self.wizard.resize(600,400)
if self.wizard.exec_():
c = self.parseRedirectUrl(str(inputLink.text()))
if c:
try:
Expand All @@ -180,7 +179,7 @@ def parseRedirectUrl(self, link):
return None

def showWarning(self, title, text):
QMessageBox.warning(self, title, text)
QMessageBox.warning(self.wizard, title, text)

def constructContextInfoWindow(self, photo):
html = self.options_string['infowindow_html']
Expand Down
19 changes: 9 additions & 10 deletions creepy/plugins/twitter/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
from PyQt4.QtCore import QUrl
from PyQt4.QtWebKit import QWebView
from tweepy import Cursor
from utilities import GeneralUtilities
from configobj import ConfigObj

#set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(os.path.join(GeneralUtilities.getUserHome(),'creepy_main.log'))
fh = logging.FileHandler(os.path.join(os.getcwdu(),'creepy_main.log'))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
Expand Down Expand Up @@ -89,7 +88,7 @@ def runConfigWizard(self):



wizard = QWizard()
self.wizard = QWizard()
page1 = QWizardPage()
page2 = QWizardPage()
layout1 = QVBoxLayout()
Expand All @@ -116,13 +115,13 @@ def runConfigWizard(self):
page1.setLayout(layout1)
page2.setLayout(layout2)
page2.registerField("inputPin*", inputPin)
wizard.addPage(page1)
wizard.addPage(page2)
wizard.resize(800,600)
self.wizard.addPage(page1)
self.wizard.addPage(page2)
self.wizard.resize(800,600)

if wizard.exec_():
if self.wizard.exec_():
try:
oAuthHandler.get_access_token(str(wizard.field("inputPin").toString()).strip())
oAuthHandler.get_access_token(str(self.wizard.field("inputPin").toString()).strip())
access_token = oAuthHandler.access_token.key
access_token_secret = oAuthHandler.access_token.secret
self.options_string['hidden_access_token'] = access_token
Expand All @@ -138,7 +137,7 @@ def runConfigWizard(self):

def showWarning(self, title, text):
try:
QMessageBox.warning(self, title, text)
QMessageBox.warning(self.wizard, title, text)
except Exception, err:
print err

Expand Down Expand Up @@ -247,7 +246,7 @@ def constructContextInfoWindow(self, tweet):

html = self.options_string['infowindow_html']
#returned value also becomes unicode since tweet.text is unicode, and carries the encoding also
return html.replace("@TEXT@",tweet.text).replace("@DATE@",tweet.created_at.strftime("%a %b %d,%H:%M:%S %z")).replace("@PLUGIN@", "twitter")
return html.replace("@TEXT@",tweet.text.encode('utf-8')).replace("@DATE@",tweet.created_at.strftime("%a %b %d,%H:%M:%S %z")).replace("@PLUGIN@", "twitter")

def getCenterOfPolygon(self, coord):
'''
Expand Down

0 comments on commit d26b55f

Please sign in to comment.