Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
Windows-specific encoding fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smathot committed Aug 19, 2014
1 parent ce60096 commit c449d1d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion libqnotero/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def __init__(self, qnotero, firstRun=False):
QDialog.__init__(self)
self.qnotero = qnotero
uiPath = os.path.join(os.path.dirname(__file__), 'ui', 'preferences.ui')
print('Preferences.__init__(): loading preferences ui from %s' % uiPath)
self.ui = uic.loadUi(uiPath, self)
self.ui.labelLocatePath.hide()
if not firstRun:
Expand Down
8 changes: 3 additions & 5 deletions libqnotero/qnotero.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def __init__(self, systray=True, debug=False, reset=False, parent=None):

QMainWindow.__init__(self, parent)
uiPath = os.path.join(os.path.dirname(__file__), 'ui', 'qnotero.ui')
print('qnotero.__init__(): loading Qnotero ui from %s' % uiPath)
self.ui = uic.loadUi(uiPath, self)
if not reset:
self.restoreState()
Expand All @@ -63,7 +62,7 @@ def __init__(self, systray=True, debug=False, reset=False, parent=None):
self.minimizeOnClose = True
else:
self.minimizeOnClose = False
if getConfig(u"firstRun"):
if getConfig(u"firstRun") or not os.path.exists(getConfig('zoteroPath')):
self.preferences(firstRun=True)
if getConfig(u"autoUpdateCheck"):
self.updateCheck()
Expand Down Expand Up @@ -228,13 +227,12 @@ def runResult(self, listWidgetItem):
if listWidgetItem.zoteroItem.fulltext == None:
return
pdf = listWidgetItem.zoteroItem.fulltext
if os.name == u"nt":
if os.name == 'nt':
os.startfile(pdf)
else:
# For some reason, the file must be encoded with latin-1, despite
# the fact that it's a utf-8 encoded database and filesystem!
pdf = pdf.encode(u'latin-1')
reader = getConfig(u'pdfReader').encode(sys.getfilesystemencoding())
reader = getConfig('pdfReader').encode(sys.getfilesystemencoding())
pid = subprocess.Popen([reader, pdf])
self.popDown()

Expand Down
8 changes: 6 additions & 2 deletions libzotero/libzotero.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def __init__(self, zotero_path, noteProvider=None):
"""

assert(isinstance(zotero_path, str))

print(u"libzotero.__init__(): zotero_path = %s" % zotero_path)
print(u"libzotero.__init__(): zotero_path = %s" % bytes(zotero_path,
'utf-8'))
# Set paths
self.zotero_path = zotero_path
self.storage_path = os.path.join(self.zotero_path, u"storage")
Expand Down Expand Up @@ -270,6 +270,10 @@ def update(self, force=False):
# by "storage:"
if att[:8] == u"storage:":
item_attachment = att[8:]
# The item attachment appears to be encoded in
# latin-1 encoding, which we don't want, so recode.
item_attachment = item_attachment.encode(
'latin-1').decode('utf-8')
attachment_id = item[2]
if item_attachment[-4:].lower() in \
self.attachment_ext:
Expand Down
2 changes: 1 addition & 1 deletion qnotero
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if __name__ == "__main__":
import socket
print(u"qnotero: Qnotero already running, sending activate signal")
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(u"activate", (u"localhost", getConfig(u"listenerPort")) )
sock.sendto(b"activate", (u"localhost", getConfig(u"listenerPort")) )
sys.exit()

# Normal start of Qnotero
Expand Down

0 comments on commit c449d1d

Please sign in to comment.