mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 20:53:13 -06:00
Initial Python 3 compatible code
This commit is contained in:
parent
d441536f01
commit
ef689d04fc
@ -2,6 +2,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
name = 'TWBlue'
|
name = 'TWBlue'
|
||||||
|
short_name='twblue'
|
||||||
snapshot = True
|
snapshot = True
|
||||||
if snapshot == False:
|
if snapshot == False:
|
||||||
version = "0.94"
|
version = "0.94"
|
||||||
@ -11,11 +12,11 @@ else:
|
|||||||
version = "14"
|
version = "14"
|
||||||
update_url = 'https://twblue.es/updates/snapshot.php'
|
update_url = 'https://twblue.es/updates/snapshot.php'
|
||||||
mirror_update_url = 'https://raw.githubusercontent.com/manuelcortez/TWBlue/next-gen/updates/snapshots.json'
|
mirror_update_url = 'https://raw.githubusercontent.com/manuelcortez/TWBlue/next-gen/updates/snapshots.json'
|
||||||
authors = [u"Manuel Cortéz", u"José Manuel Delicado"]
|
authors = ["Manuel Cortéz", "José Manuel Delicado"]
|
||||||
authorEmail = "manuel@manuelcortez.net"
|
authorEmail = "manuel@manuelcortez.net"
|
||||||
copyright = u"Copyright (C) 2013-2018, Manuel cortéz."
|
copyright = "Copyright (C) 2013-2018, Manuel cortéz."
|
||||||
description = unicode(name+" is an app designed to use Twitter simply and efficiently while using minimal system resources. This app provides access to most Twitter features.")
|
description = name+" is an app designed to use Twitter simply and efficiently while using minimal system resources. This app provides access to most Twitter features."
|
||||||
translators = [u"Manuel Cortéz (English)", u"Mohammed Al Shara, Hatoun Felemban (Arabic)", u"Francisco Torres (Catalan)", u"Manuel cortéz (Spanish)", u"Sukil Etxenike Arizaleta (Basque)", u"Jani Kinnunen (finnish)", u"Rémy Ruiz (French)", u"Juan Buño (Galician)", u"Steffen Schultz (German)", u"Zvonimir Stanečić (Croatian)", u"Robert Osztolykan (Hungarian)", u"Christian Leo Mameli (Italian)", u"Riku (Japanese)", u"Paweł Masarczyk (Polish)", u"Odenilton Júnior Santos (Portuguese)", u"Florian Ionașcu, Nicușor Untilă (Romanian)", u"Natalia Hedlund, Valeria Kuznetsova (Russian)", u"Aleksandar Đurić (Serbian)", u"Burak Yüksek (Turkish)"]
|
translators = ["Manuel Cortéz (English)", "Mohammed Al Shara, Hatoun Felemban (Arabic)", "Francisco Torres (Catalan)", "Manuel cortéz (Spanish)", "Sukil Etxenike Arizaleta (Basque)", "Jani Kinnunen (finnish)", "Rémy Ruiz (French)", "Juan Buño (Galician)", "Steffen Schultz (German)", "Zvonimir Stanečić (Croatian)", "Robert Osztolykan (Hungarian)", "Christian Leo Mameli (Italian)", "Riku (Japanese)", "Paweł Masarczyk (Polish)", "Odenilton Júnior Santos (Portuguese)", "Florian Ionașcu, Nicușor Untilă (Romanian)", "Natalia Hedlund, Valeria Kuznetsova (Russian)", "Aleksandar Đurić (Serbian)", "Burak Yüksek (Turkish)"]
|
||||||
url = u"https://twblue.es"
|
url = u"https://twblue.es"
|
||||||
report_bugs_url = "https://github.com/manuelcortez/twblue/issues"
|
report_bugs_url = "https://github.com/manuelcortez/twblue/issues"
|
||||||
supported_languages = []
|
supported_languages = []
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
def matches_url(url):
|
def matches_url(url):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from audio_services import matches_url
|
from audio_services import matches_url
|
||||||
import youtube_utils
|
import youtube_utils
|
||||||
import requests
|
import requests
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
|
|
||||||
def get_video_url(url):
|
def get_video_url(url):
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: cp1252 -*-
|
# -*- coding: cp1252 -*-
|
||||||
|
import os
|
||||||
import config_utils
|
import config_utils
|
||||||
import paths
|
import paths
|
||||||
import logging
|
import logging
|
||||||
@ -16,7 +17,7 @@ changed_keymap = False
|
|||||||
def setup ():
|
def setup ():
|
||||||
global app
|
global app
|
||||||
log.debug("Loading global app settings...")
|
log.debug("Loading global app settings...")
|
||||||
app = config_utils.load_config(paths.config_path(MAINFILE), paths.app_path(MAINSPEC))
|
app = config_utils.load_config(os.path.join(paths.config_path(), MAINFILE), os.path.join(paths.app_path(), MAINSPEC))
|
||||||
log.debug("Loading keymap...")
|
log.debug("Loading keymap...")
|
||||||
global keymap
|
global keymap
|
||||||
if float(platform.version()[:2]) >= 10 and app["app-settings"]["load_keymap"] == "default.keymap":
|
if float(platform.version()[:2]) >= 10 and app["app-settings"]["load_keymap"] == "default.keymap":
|
||||||
@ -24,4 +25,4 @@ def setup ():
|
|||||||
app.write()
|
app.write()
|
||||||
global changed_keymap
|
global changed_keymap
|
||||||
changed_keymap = True
|
changed_keymap = True
|
||||||
keymap = config_utils.load_config(paths.config_path("keymap.keymap"), paths.app_path("keymaps/"+app['app-settings']['load_keymap']), copy=False)
|
keymap = config_utils.load_config(os.path.join(paths.config_path(), "keymap.keymap"), os.path.join(paths.app_path(), "keymaps/"+app['app-settings']['load_keymap']), copy=False)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import os
|
import os
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import logging
|
import logging
|
||||||
|
@ -5,3 +5,4 @@
|
|||||||
* baseBuffers: Define a set of functions and structure to be expected in all buffers. New buffers should inherit its classes from one of the classes present here.
|
* baseBuffers: Define a set of functions and structure to be expected in all buffers. New buffers should inherit its classes from one of the classes present here.
|
||||||
* twitterBuffers: All other code, specific to Twitter.
|
* twitterBuffers: All other code, specific to Twitter.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import unicode_literals
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" Common logic to all buffers in TWBlue."""
|
""" Common logic to all buffers in TWBlue."""
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import logging
|
import logging
|
||||||
import wx
|
import wx
|
||||||
import output
|
import output
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from builtins import range
|
||||||
import time
|
import time
|
||||||
import platform
|
import platform
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
@ -67,7 +70,7 @@ class baseBufferController(baseBuffers.buffer):
|
|||||||
""" Get buffer name from a set of different techniques."""
|
""" Get buffer name from a set of different techniques."""
|
||||||
# firstly let's take the easier buffers.
|
# firstly let's take the easier buffers.
|
||||||
basic_buffers = dict(home_timeline=_(u"Home"), mentions=_(u"Mentions"), direct_messages=_(u"Direct messages"), sent_direct_messages=_(u"Sent direct messages"), sent_tweets=_(u"Sent tweets"), favourites=_(u"Likes"), followers=_(u"Followers"), friends=_(u"Friends"), blocked=_(u"Blocked users"), muted=_(u"Muted users"))
|
basic_buffers = dict(home_timeline=_(u"Home"), mentions=_(u"Mentions"), direct_messages=_(u"Direct messages"), sent_direct_messages=_(u"Sent direct messages"), sent_tweets=_(u"Sent tweets"), favourites=_(u"Likes"), followers=_(u"Followers"), friends=_(u"Friends"), blocked=_(u"Blocked users"), muted=_(u"Muted users"))
|
||||||
if self.name in basic_buffers.keys():
|
if self.name in list(basic_buffers.keys()):
|
||||||
return basic_buffers[self.name]
|
return basic_buffers[self.name]
|
||||||
# Check user timelines
|
# Check user timelines
|
||||||
elif hasattr(self, "username"):
|
elif hasattr(self, "username"):
|
||||||
@ -266,7 +269,7 @@ class baseBufferController(baseBuffers.buffer):
|
|||||||
|
|
||||||
def remove_tweet(self, id):
|
def remove_tweet(self, id):
|
||||||
if type(self.session.db[self.name]) == dict: return
|
if type(self.session.db[self.name]) == dict: return
|
||||||
for i in xrange(0, len(self.session.db[self.name])):
|
for i in range(0, len(self.session.db[self.name])):
|
||||||
if self.session.db[self.name][i]["id"] == id:
|
if self.session.db[self.name][i]["id"] == id:
|
||||||
self.session.db[self.name].pop(i)
|
self.session.db[self.name].pop(i)
|
||||||
self.remove_item(i)
|
self.remove_item(i)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import time
|
import time
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import application
|
import application
|
||||||
@ -51,7 +53,7 @@ class filterManager(object):
|
|||||||
|
|
||||||
def insert_filters(self, filters):
|
def insert_filters(self, filters):
|
||||||
self.dialog.filters.clear()
|
self.dialog.filters.clear()
|
||||||
for f in filters.keys():
|
for f in list(filters.keys()):
|
||||||
filterName = f
|
filterName = f
|
||||||
buffer = filters[f]["in_buffer"]
|
buffer = filters[f]["in_buffer"]
|
||||||
if filters[f]["if_word_exists"] == "True" and filters[f]["word"] != "":
|
if filters[f]["if_word_exists"] == "True" and filters[f]["word"] != "":
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import output
|
import output
|
||||||
from wxUI.dialogs import lists
|
from wxUI.dialogs import lists
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from builtins import range
|
||||||
|
from builtins import object
|
||||||
import platform
|
import platform
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
import application
|
import application
|
||||||
@ -268,7 +271,7 @@ class Controller(object):
|
|||||||
self.start_buffers(sessions.sessions[i])
|
self.start_buffers(sessions.sessions[i])
|
||||||
self.set_buffer_positions(sessions.sessions[i])
|
self.set_buffer_positions(sessions.sessions[i])
|
||||||
if config.app["app-settings"]["play_ready_sound"] == True:
|
if config.app["app-settings"]["play_ready_sound"] == True:
|
||||||
sessions.sessions[sessions.sessions.keys()[0]].sound.play("ready.ogg")
|
sessions.sessions[list(sessions.sessions.keys())[0]].sound.play("ready.ogg")
|
||||||
if config.app["app-settings"]["speak_ready_msg"] == True:
|
if config.app["app-settings"]["speak_ready_msg"] == True:
|
||||||
output.speak(_(u"Ready"))
|
output.speak(_(u"Ready"))
|
||||||
self.started = True
|
self.started = True
|
||||||
@ -465,7 +468,7 @@ class Controller(object):
|
|||||||
output.speak(_(u"Empty buffer."), True)
|
output.speak(_(u"Empty buffer."), True)
|
||||||
return
|
return
|
||||||
start = page.buffer.list.get_selected()
|
start = page.buffer.list.get_selected()
|
||||||
for i in xrange(start, count):
|
for i in range(start, count):
|
||||||
if string.lower() in page.buffer.list.get_text_column(i, 1).lower():
|
if string.lower() in page.buffer.list.get_text_column(i, 1).lower():
|
||||||
page.buffer.list.select_item(i)
|
page.buffer.list.select_item(i)
|
||||||
return output.speak(page.get_message(), True)
|
return output.speak(page.get_message(), True)
|
||||||
@ -969,8 +972,8 @@ class Controller(object):
|
|||||||
x = tweet["coordinates"]["coordinates"][0]
|
x = tweet["coordinates"]["coordinates"][0]
|
||||||
y = tweet["coordinates"]["coordinates"][1]
|
y = tweet["coordinates"]["coordinates"][1]
|
||||||
address = geocoder.reverse_geocode(y, x, language = languageHandler.curLang)
|
address = geocoder.reverse_geocode(y, x, language = languageHandler.curLang)
|
||||||
if event == None: output.speak(address[0].__str__().decode("utf-8"))
|
if event == None: output.speak(address[0].__str__())
|
||||||
else: self.view.show_address(address[0].__str__().decode("utf-8"))
|
else: self.view.show_address(address[0].__str__())
|
||||||
else:
|
else:
|
||||||
output.speak(_(u"There are no coordinates in this tweet"))
|
output.speak(_(u"There are no coordinates in this tweet"))
|
||||||
except GeocoderError:
|
except GeocoderError:
|
||||||
@ -1580,7 +1583,7 @@ class Controller(object):
|
|||||||
elif "quoted_status" in tweet and "media" in tweet["quoted_status"]["entities"]:
|
elif "quoted_status" in tweet and "media" in tweet["quoted_status"]["entities"]:
|
||||||
[media_list.append(i) for i in tweet["quoted_status"]["entities"]["media"] if i not in media_list]
|
[media_list.append(i) for i in tweet["quoted_status"]["entities"]["media"] if i not in media_list]
|
||||||
if len(media_list) > 1:
|
if len(media_list) > 1:
|
||||||
image_list = [_(u"Picture {0}").format(i,) for i in xrange(0, len(media_list))]
|
image_list = [_(u"Picture {0}").format(i,) for i in range(0, len(media_list))]
|
||||||
dialog = dialogs.urlList.urlList(title=_(u"Select the picture"))
|
dialog = dialogs.urlList.urlList(title=_(u"Select the picture"))
|
||||||
if dialog.get_response() == widgetUtils.OK:
|
if dialog.get_response() == widgetUtils.OK:
|
||||||
img = media_list[dialog.get_item()]
|
img = media_list[dialog.get_item()]
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from builtins import range
|
||||||
|
from builtins import object
|
||||||
import re
|
import re
|
||||||
import platform
|
import platform
|
||||||
from . import attach
|
from . import attach
|
||||||
@ -173,14 +177,14 @@ class reply(tweet):
|
|||||||
|
|
||||||
def get_ids(self):
|
def get_ids(self):
|
||||||
excluded_ids = ""
|
excluded_ids = ""
|
||||||
for i in xrange(0, len(self.message.checkboxes)):
|
for i in range(0, len(self.message.checkboxes)):
|
||||||
if self.message.checkboxes[i].GetValue() == False:
|
if self.message.checkboxes[i].GetValue() == False:
|
||||||
excluded_ids = excluded_ids + "{0},".format(self.ids[i],)
|
excluded_ids = excluded_ids + "{0},".format(self.ids[i],)
|
||||||
return excluded_ids
|
return excluded_ids
|
||||||
|
|
||||||
def get_people(self):
|
def get_people(self):
|
||||||
people = ""
|
people = ""
|
||||||
for i in xrange(0, len(self.message.checkboxes)):
|
for i in range(0, len(self.message.checkboxes)):
|
||||||
if self.message.checkboxes[i].GetValue() == True:
|
if self.message.checkboxes[i].GetValue() == True:
|
||||||
people = people + "{0} ".format(self.message.checkboxes[i].GetLabel(),)
|
people = people + "{0} ".format(self.message.checkboxes[i].GetLabel(),)
|
||||||
return people
|
return people
|
||||||
@ -205,7 +209,7 @@ class viewTweet(basicTweet):
|
|||||||
self.title = _(u"Tweet")
|
self.title = _(u"Tweet")
|
||||||
image_description = []
|
image_description = []
|
||||||
text = ""
|
text = ""
|
||||||
for i in xrange(0, len(tweetList)):
|
for i in range(0, len(tweetList)):
|
||||||
# tweets with message keys are longer tweets, the message value is the full messaje taken from twishort.
|
# tweets with message keys are longer tweets, the message value is the full messaje taken from twishort.
|
||||||
if "message" in tweetList[i] and tweetList[i]["is_quote_status"] == False:
|
if "message" in tweetList[i] and tweetList[i]["is_quote_status"] == False:
|
||||||
value = "message"
|
value = "message"
|
||||||
@ -231,7 +235,7 @@ class viewTweet(basicTweet):
|
|||||||
rt_count = str(tweet["retweet_count"])
|
rt_count = str(tweet["retweet_count"])
|
||||||
favs_count = str(tweet["favorite_count"])
|
favs_count = str(tweet["favorite_count"])
|
||||||
# Gets the client from where this tweet was made.
|
# Gets the client from where this tweet was made.
|
||||||
source = str(re.sub(r"(?s)<.*?>", "", tweet["source"].encode("utf-8")))
|
source = re.sub(r"(?s)<.*?>", "", tweet["source"])
|
||||||
original_date = arrow.get(tweet["created_at"], "ddd MMM DD H:m:s Z YYYY", locale="en")
|
original_date = arrow.get(tweet["created_at"], "ddd MMM DD H:m:s Z YYYY", locale="en")
|
||||||
date = original_date.replace(seconds=utc_offset).format(_(u"MMM D, YYYY. H:m"), locale=languageHandler.getLanguage())
|
date = original_date.replace(seconds=utc_offset).format(_(u"MMM D, YYYY. H:m"), locale=languageHandler.getLanguage())
|
||||||
if text == "":
|
if text == "":
|
||||||
@ -255,7 +259,7 @@ class viewTweet(basicTweet):
|
|||||||
for z in tweet["retweeted_status"]["extended_entities"]["media"]:
|
for z in tweet["retweeted_status"]["extended_entities"]["media"]:
|
||||||
if "ext_alt_text" in z and z["ext_alt_text"] != None:
|
if "ext_alt_text" in z and z["ext_alt_text"] != None:
|
||||||
image_description.append(z["ext_alt_text"])
|
image_description.append(z["ext_alt_text"])
|
||||||
self.message = message.viewTweet(text, rt_count, favs_count, source.decode("utf-8"), date)
|
self.message = message.viewTweet(text, rt_count, favs_count, source, date)
|
||||||
self.message.set_title(len(text))
|
self.message.set_title(len(text))
|
||||||
[self.message.set_image_description(i) for i in image_description]
|
[self.message.set_image_description(i) for i in image_description]
|
||||||
else:
|
else:
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from builtins import object
|
||||||
import os
|
import os
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import sound_lib
|
import sound_lib
|
||||||
@ -49,7 +52,7 @@ class globalSettingsController(object):
|
|||||||
id = self.codes.index(config.app["app-settings"]["language"])
|
id = self.codes.index(config.app["app-settings"]["language"])
|
||||||
self.kmfriendlies=[]
|
self.kmfriendlies=[]
|
||||||
self.kmnames=[]
|
self.kmnames=[]
|
||||||
for k,v in self.kmmap.items():
|
for k,v in list(self.kmmap.items()):
|
||||||
self.kmfriendlies.append(k)
|
self.kmfriendlies.append(k)
|
||||||
self.kmnames.append(v)
|
self.kmnames.append(v)
|
||||||
self.kmid=self.kmnames.index(config.app['app-settings']['load_keymap'])
|
self.kmid=self.kmnames.index(config.app['app-settings']['load_keymap'])
|
||||||
@ -291,7 +294,7 @@ class accountSettingsController(globalSettingsController):
|
|||||||
all_buffers['muted']=_(u"Muted users")
|
all_buffers['muted']=_(u"Muted users")
|
||||||
list_buffers = []
|
list_buffers = []
|
||||||
hidden_buffers=[]
|
hidden_buffers=[]
|
||||||
all_buffers_keys = all_buffers.keys()
|
all_buffers_keys = list(all_buffers.keys())
|
||||||
# Check buffers shown first.
|
# Check buffers shown first.
|
||||||
for i in self.config["general"]["buffer_order"]:
|
for i in self.config["general"]["buffer_order"]:
|
||||||
if i in all_buffers_keys:
|
if i in all_buffers_keys:
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
from wxUI.dialogs import trends
|
from wxUI.dialogs import trends
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import wx
|
import wx
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import re
|
import re
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import output
|
import output
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from builtins import object
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
from . import wx_ui
|
from . import wx_ui
|
||||||
from . import wx_transfer_dialogs
|
from . import wx_transfer_dialogs
|
||||||
@ -132,7 +135,7 @@ class audioUploader(object):
|
|||||||
def _play(self):
|
def _play(self):
|
||||||
output.speak(_(u"Playing..."))
|
output.speak(_(u"Playing..."))
|
||||||
# try:
|
# try:
|
||||||
self.playing = sound_lib.stream.FileStream(file=unicode(self.file), flags=sound_lib.stream.BASS_UNICODE)
|
self.playing = sound_lib.stream.FileStream(file=str(self.file), flags=sound_lib.stream.BASS_UNICODE)
|
||||||
self.playing.play()
|
self.playing.play()
|
||||||
self.dialog.set("play", _(u"&Stop"))
|
self.dialog.set("play", _(u"&Stop"))
|
||||||
try:
|
try:
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
|
from past.utils import old_div
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
@ -21,7 +25,7 @@ class Upload(object):
|
|||||||
self.background_thread = None
|
self.background_thread = None
|
||||||
self.transfer_rate = 0
|
self.transfer_rate = 0
|
||||||
self.local_filename=os.path.basename(self.filename)
|
self.local_filename=os.path.basename(self.filename)
|
||||||
if isinstance(self.local_filename, unicode):
|
if isinstance(self.local_filename, str):
|
||||||
self.local_filename=self.local_filename.encode(sys.getfilesystemencoding())
|
self.local_filename=self.local_filename.encode(sys.getfilesystemencoding())
|
||||||
self.fin=open(self.filename, 'rb')
|
self.fin=open(self.filename, 'rb')
|
||||||
self.m = MultipartEncoder(fields={field:(self.local_filename, self.fin, "application/octet-stream")})
|
self.m = MultipartEncoder(fields={field:(self.local_filename, self.fin, "application/octet-stream")})
|
||||||
@ -45,10 +49,10 @@ class Upload(object):
|
|||||||
self.transfer_rate = 0
|
self.transfer_rate = 0
|
||||||
else:
|
else:
|
||||||
progress["percent"] = int((float(progress["current"]) / progress["total"]) * 100)
|
progress["percent"] = int((float(progress["current"]) / progress["total"]) * 100)
|
||||||
self.transfer_rate = progress["current"] / self.elapsed_time()
|
self.transfer_rate = old_div(progress["current"], self.elapsed_time())
|
||||||
progress["speed"] = '%s/s' % convert_bytes(self.transfer_rate)
|
progress["speed"] = '%s/s' % convert_bytes(self.transfer_rate)
|
||||||
if self.transfer_rate:
|
if self.transfer_rate:
|
||||||
progress["eta"] = (progress["total"] - progress["current"]) / self.transfer_rate
|
progress["eta"] = old_div((progress["total"] - progress["current"]), self.transfer_rate)
|
||||||
else:
|
else:
|
||||||
progress["eta"] = 0
|
progress["eta"] = 0
|
||||||
pub.sendMessage("uploading", data=progress)
|
pub.sendMessage("uploading", data=progress)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
def convert_bytes(n):
|
def convert_bytes(n):
|
||||||
K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
|
K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
|
||||||
if n >= P:
|
if n >= P:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
from .utils import *
|
from .utils import *
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import output
|
import output
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
from .soundsTutorial import soundsTutorial
|
from .soundsTutorial import soundsTutorial
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
#Reverse sort, by Bill Dengler <codeofdusk@gmail.com> for use in TWBlue http://twblue.es
|
#Reverse sort, by Bill Dengler <codeofdusk@gmail.com> for use in TWBlue http://twblue.es
|
||||||
def invert_tuples(t):
|
def invert_tuples(t):
|
||||||
"Invert a list of tuples, so that the 0th element becomes the -1th, and the -1th becomes the 0th."
|
"Invert a list of tuples, so that the 0th element becomes the -1th, and the -1th becomes the 0th."
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import platform
|
import platform
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import os
|
import os
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#-*- coding: utf-8 -*-
|
#-*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
#-*- coding: utf-8 -*-
|
#-*- coding: utf-8 -*-
|
||||||
from . import reverse_sort
|
from . import reverse_sort
|
||||||
import application
|
import application
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
from . import spellchecker
|
from . import spellchecker
|
||||||
import platform
|
import platform
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import next
|
||||||
|
from builtins import object
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from . import wx_ui
|
from . import wx_ui
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import re
|
import re
|
||||||
from enchant.tokenize import Filter
|
from enchant.tokenize import Filter
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
import application
|
import application
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from . import completion, settings
|
from . import completion, settings
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import output
|
import output
|
||||||
from . import storage
|
from . import storage
|
||||||
from . import wx_menu
|
from . import wx_menu
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from builtins import object
|
||||||
from . import storage
|
from . import storage
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
from . import wx_manage
|
from . import wx_manage
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from builtins import object
|
||||||
from . import storage
|
from . import storage
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
from . import wx_settings
|
from . import wx_settings
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import sqlite3, paths
|
import sqlite3, paths
|
||||||
|
|
||||||
class storage(object):
|
class storage(object):
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
from multiplatform_widgets import widgets
|
from multiplatform_widgets import widgets
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
class menu(wx.Menu):
|
class menu(wx.Menu):
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import application
|
import application
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" original module taken and modified from https://github.com/ctoth/cloudOCR"""
|
""" original module taken and modified from https://github.com/ctoth/cloudOCR"""
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
translatable_langs = [_(u"Detect automatically"), _(u"Danish"), _(u"Dutch"), _(u"English"), _(u"Finnish"), _(u"French"), _(u"German"), _(u"Hungarian"), _(u"Korean"), _(u"Italian"), _(u"Japanese"), _(u"Polish"), _(u"Portuguese"), _(u"Russian"), _(u"Spanish"), _(u"Turkish")]
|
translatable_langs = [_(u"Detect automatically"), _(u"Danish"), _(u"Dutch"), _(u"English"), _(u"Finnish"), _(u"French"), _(u"German"), _(u"Hungarian"), _(u"Korean"), _(u"Italian"), _(u"Japanese"), _(u"Polish"), _(u"Portuguese"), _(u"Russian"), _(u"Spanish"), _(u"Turkish")]
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from . import OCRSpace
|
from . import OCRSpace
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
from . import translator
|
from . import translator
|
||||||
import platform
|
import platform
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import zip
|
||||||
from yandex_translate import YandexTranslate
|
from yandex_translate import YandexTranslate
|
||||||
|
|
||||||
def translate(text="", target="en"):
|
def translate(text="", target="en"):
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
############################################################
|
############################################################
|
||||||
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
|
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" This module contains some bugfixes for packages used in TWBlue."""
|
""" This module contains some bugfixes for packages used in TWBlue."""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
import sys
|
import sys
|
||||||
from . import fix_arrow # A few new locales for Three languages in arrow.
|
from . import fix_arrow # A few new locales for Three languages in arrow.
|
||||||
from . import fix_libloader # Regenerates comcache properly.
|
from . import fix_libloader # Regenerates comcache properly.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
from arrow import locales
|
from arrow import locales
|
||||||
from arrow.locales import Locale
|
from arrow.locales import Locale
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import logging
|
import logging
|
||||||
import win32com
|
import win32com
|
||||||
import paths
|
import paths
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from requests import certs, utils, adapters
|
from requests import certs, utils, adapters
|
||||||
import paths
|
import paths
|
||||||
import config
|
import config
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
from requests.packages import urllib3
|
from requests.packages import urllib3
|
||||||
from requests.packages.urllib3 import fields
|
from requests.packages.urllib3 import fields
|
||||||
import six
|
import six
|
||||||
import urllib
|
import urllib.request, urllib.parse, urllib.error
|
||||||
|
|
||||||
def fix():
|
def fix():
|
||||||
urllib3.disable_warnings()
|
urllib3.disable_warnings()
|
||||||
@ -19,6 +22,6 @@ def patched_format_header_param(name, value):
|
|||||||
return result
|
return result
|
||||||
if not six.PY3 and isinstance(value, six.text_type): # Python 2:
|
if not six.PY3 and isinstance(value, six.text_type): # Python 2:
|
||||||
value = value.encode('utf-8')
|
value = value.encode('utf-8')
|
||||||
value=urllib.quote(value, safe='')
|
value=urllib.parse.quote(value, safe='')
|
||||||
value = '%s=%s' % (name, value)
|
value = '%s=%s' % (name, value)
|
||||||
return value
|
return value
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
import win32com.client
|
import win32com.client
|
||||||
def fix():
|
def fix():
|
||||||
if win32com.client.gencache.is_readonly == True:
|
if win32com.client.gencache.is_readonly == True:
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
|
from __future__ import unicode_literals
|
||||||
categories = ["General"]
|
categories = ["General"]
|
||||||
reproducibilities = ["always", "sometimes", "random", "have not tried", "unable to duplicate"]
|
reproducibilities = ["always", "sometimes", "random", "have not tried", "unable to duplicate"]
|
||||||
severities = ["block", "crash", "major", "minor", "tweak", "text", "trivial", "feature"]
|
severities = ["block", "crash", "major", "minor", "tweak", "text", "trivial", "feature"]
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import keys
|
import keys
|
||||||
import wx
|
import wx
|
||||||
import wx_ui
|
import wx_ui
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import application
|
import application
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from main import KeyboardHandler, KeyboardHandlerError
|
from __future__ import absolute_import
|
||||||
#from wx_handler import WXKeyboardHandler
|
from .main import KeyboardHandler, KeyboardHandlerError
|
||||||
__all__ = ["KeyboardHandler", "KeyboardHandlerError", "WXKeyboardHandler", "WXPanelKeyboardHandler"]
|
__all__ = ["KeyboardHandler", "KeyboardHandlerError", ]
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import platform
|
import platform
|
||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Linux':
|
||||||
from linux import LinuxKeyboardHandler as GlobalKeyboardHandler
|
from .linux import LinuxKeyboardHandler as GlobalKeyboardHandler
|
||||||
elif platform.system() == 'Windows':
|
else:
|
||||||
from wx_handler import WXKeyboardHandler as GlobalKeyboardHandler
|
from .wx_handler import WXKeyboardHandler as GlobalKeyboardHandler
|
||||||
elif platform.system() == 'Darwin':
|
#elif platform.system() == 'Darwin':
|
||||||
from osx import OSXKeyboardHandler as GlobalKeyboardHandler
|
#from osx import OSXKeyboardHandler as GlobalKeyboardHandler
|
||||||
|
128
src/keyboard_handler/key_constants.py
Normal file
128
src/keyboard_handler/key_constants.py
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
keys = {
|
||||||
|
'accept': 30,
|
||||||
|
'add': 107,
|
||||||
|
'apps': 93,
|
||||||
|
'attn': 246,
|
||||||
|
'back': 8,
|
||||||
|
'browser_back': 166,
|
||||||
|
'browser_forward': 167,
|
||||||
|
'cancel': 3,
|
||||||
|
'capital': 20,
|
||||||
|
'clear': 12,
|
||||||
|
'control': 17,
|
||||||
|
'convert': 28,
|
||||||
|
'crsel': 247,
|
||||||
|
'decimal': 110,
|
||||||
|
'delete': 46,
|
||||||
|
'divide': 111,
|
||||||
|
'down': 40,
|
||||||
|
'end': 35,
|
||||||
|
'ereof': 249,
|
||||||
|
'escape': 27,
|
||||||
|
'execute': 43,
|
||||||
|
'exsel': 248,
|
||||||
|
'f1': 112,
|
||||||
|
'f10': 121,
|
||||||
|
'f11': 122,
|
||||||
|
'f12': 123,
|
||||||
|
'f13': 124,
|
||||||
|
'f14': 125,
|
||||||
|
'f15': 126,
|
||||||
|
'f16': 127,
|
||||||
|
'f17': 128,
|
||||||
|
'f18': 129,
|
||||||
|
'f19': 130,
|
||||||
|
'f2': 113,
|
||||||
|
'f20': 131,
|
||||||
|
'f21': 132,
|
||||||
|
'f22': 133,
|
||||||
|
'f23': 134,
|
||||||
|
'f24': 135,
|
||||||
|
'f3': 114,
|
||||||
|
'f4': 115,
|
||||||
|
'f5': 116,
|
||||||
|
'f6': 117,
|
||||||
|
'f7': 118,
|
||||||
|
'f8': 119,
|
||||||
|
'f9': 120,
|
||||||
|
'final': 24,
|
||||||
|
'hangeul': 21,
|
||||||
|
'hangul': 21,
|
||||||
|
'hanja': 25,
|
||||||
|
'help': 47,
|
||||||
|
'home': 36,
|
||||||
|
'insert': 45,
|
||||||
|
'junja': 23,
|
||||||
|
'kana': 21,
|
||||||
|
'kanji': 25,
|
||||||
|
'lbutton': 1,
|
||||||
|
'lcontrol': 162,
|
||||||
|
'left': 37,
|
||||||
|
'lmenu': 164,
|
||||||
|
'lshift': 160,
|
||||||
|
'lwin': 91,
|
||||||
|
'mbutton': 4,
|
||||||
|
'media_next_track': 176,
|
||||||
|
'media_play_pause': 179,
|
||||||
|
'media_prev_track': 177,
|
||||||
|
'menu': 18,
|
||||||
|
'modechange': 31,
|
||||||
|
'multiply': 106,
|
||||||
|
'next': 34,
|
||||||
|
'noname': 252,
|
||||||
|
'nonconvert': 29,
|
||||||
|
'numlock': 144,
|
||||||
|
'numpad0': 96,
|
||||||
|
'numpad1': 97,
|
||||||
|
'numpad2': 98,
|
||||||
|
'numpad3': 99,
|
||||||
|
'numpad4': 100,
|
||||||
|
'numpad5': 101,
|
||||||
|
'numpad6': 102,
|
||||||
|
'numpad7': 103,
|
||||||
|
'numpad8': 104,
|
||||||
|
'numpad9': 105,
|
||||||
|
'oem_clear': 254,
|
||||||
|
'pa1': 253,
|
||||||
|
'pagedown': 34,
|
||||||
|
'pageup': 33,
|
||||||
|
'pause': 19,
|
||||||
|
'play': 250,
|
||||||
|
'print': 42,
|
||||||
|
'prior': 33,
|
||||||
|
'processkey': 229,
|
||||||
|
'rbutton': 2,
|
||||||
|
'rcontrol': 163,
|
||||||
|
'return': 13,
|
||||||
|
'right': 39,
|
||||||
|
'rmenu': 165,
|
||||||
|
'rshift': 161,
|
||||||
|
'rwin': 92,
|
||||||
|
'scroll': 145,
|
||||||
|
'select': 41,
|
||||||
|
'separator': 108,
|
||||||
|
'shift': 16,
|
||||||
|
'snapshot': 44,
|
||||||
|
'space': 32,
|
||||||
|
'subtract': 109,
|
||||||
|
'tab': 9,
|
||||||
|
'up': 38,
|
||||||
|
'volume_down': 174,
|
||||||
|
'volume_mute': 173,
|
||||||
|
'volume_up': 175,
|
||||||
|
'xbutton1': 5,
|
||||||
|
'xbutton2': 6,
|
||||||
|
'zoom': 251,
|
||||||
|
'/': 191,
|
||||||
|
';': 218,
|
||||||
|
'[': 219,
|
||||||
|
'\\': 220,
|
||||||
|
']': 221,
|
||||||
|
'\'': 222,
|
||||||
|
'=': 187,
|
||||||
|
'-': 189,
|
||||||
|
';': 186,
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiers = {'alt': 1, 'control': 2, 'shift': 4, 'win': 8}
|
||||||
|
|
@ -18,17 +18,17 @@ class KeyboardHandler(object):
|
|||||||
|
|
||||||
def register_key (self, key, function):
|
def register_key (self, key, function):
|
||||||
if key in self.active_keys:
|
if key in self.active_keys:
|
||||||
raise KeyboardHandlerError, "Key %s is already registered to a function" % key
|
raise KeyboardHandlerError("Key %s is already registered to a function" % key)
|
||||||
if not callable(function):
|
if not callable(function):
|
||||||
raise TypeError, "Must provide a callable to be invoked upon keypress"
|
raise TypeError("Must provide a callable to be invoked upon keypress")
|
||||||
self.active_keys[key] = function
|
self.active_keys[key] = function
|
||||||
|
|
||||||
def unregister_key (self, key, function):
|
def unregister_key (self, key, function):
|
||||||
try:
|
try:
|
||||||
if self.active_keys[key] != function:
|
if self.active_keys[key] != function:
|
||||||
raise KeyboardHandlerError, "key %s is not registered to that function" % key
|
raise KeyboardHandlerError("key %s is not registered to that function" % key)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise KeyboardHandlerError, "Key %s not currently registered"
|
raise KeyboardHandlerError("Key %s not currently registered" % key)
|
||||||
del(self.active_keys[key])
|
del(self.active_keys[key])
|
||||||
|
|
||||||
def unregister_all_keys(self):
|
def unregister_all_keys(self):
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import functools
|
import functools
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger("keyboard_handler")
|
||||||
import wx
|
import wx
|
||||||
import platform
|
|
||||||
from main import KeyboardHandler
|
from .main import KeyboardHandler, KeyboardHandlerError
|
||||||
|
from . import key_constants
|
||||||
|
|
||||||
__all__ = ['WXKeyboardHandler', 'WXControlKeyboardHandler']
|
__all__ = ['WXKeyboardHandler', 'WXControlKeyboardHandler']
|
||||||
|
|
||||||
|
|
||||||
def call_after(func):
|
def call_after(func):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
wx.CallAfter(func, *args, **kwargs)
|
wx.CallAfter(func, *args, **kwargs)
|
||||||
@ -34,6 +37,7 @@ class BaseWXKeyboardHandler(KeyboardHandler):
|
|||||||
return (mods, keystroke[-1])
|
return (mods, keystroke[-1])
|
||||||
|
|
||||||
def keycode_from_key(self, key):
|
def keycode_from_key(self, key):
|
||||||
|
result = None
|
||||||
if key in self.replacement_mods:
|
if key in self.replacement_mods:
|
||||||
result = self.replacement_mods[key]
|
result = self.replacement_mods[key]
|
||||||
elif key in self.replacement_keys:
|
elif key in self.replacement_keys:
|
||||||
@ -42,33 +46,40 @@ class BaseWXKeyboardHandler(KeyboardHandler):
|
|||||||
result -= 277
|
result -= 277
|
||||||
elif len(key) == 1:
|
elif len(key) == 1:
|
||||||
result = ord(key.upper())
|
result = ord(key.upper())
|
||||||
print "result: ", result
|
if result is None:
|
||||||
|
raise KeyboardHandlerError("Could not translate key %r into a valid keycode." % key)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#try:
|
class WXKeyboardHandler(BaseWXKeyboardHandler):
|
||||||
if platform.system() == "Windows":
|
|
||||||
from windows import WindowsKeyboardHandler as keyboard_handler
|
|
||||||
elif platform.system() == "Linux":
|
|
||||||
from linux import LinuxKeyboardHandler as keyboard_handler
|
|
||||||
elif platform.system() == "Darwin":
|
|
||||||
from osx import OSXKeyboardHandler as keyboard_handler
|
|
||||||
|
|
||||||
class WXKeyboardHandler(keyboard_handler):
|
|
||||||
def __init__ (self, parent, *args, **kwargs):
|
def __init__ (self, parent, *args, **kwargs):
|
||||||
super(WXKeyboardHandler, self).__init__(*args, **kwargs)
|
super(WXKeyboardHandler, self).__init__(*args, **kwargs)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.key_ids = {}
|
self.key_ids = {}
|
||||||
|
self.replacement_keys = key_constants.keys
|
||||||
|
self.replacement_mods = key_constants.modifiers
|
||||||
|
|
||||||
@call_after
|
@call_after
|
||||||
def register_key(self, key, function):
|
def register_key(self, key, function):
|
||||||
super(WXKeyboardHandler, self).register_key(key, function)
|
super(WXKeyboardHandler, self).register_key(key, function)
|
||||||
key_id = wx.NewId()
|
key_id = wx.NewId()
|
||||||
parsed = self.parse_key(key)
|
parsed = self.parse_key(key)
|
||||||
self.parent.RegisterHotKey(key_id, *parsed)
|
res = self.parent.RegisterHotKey(key_id, *parsed)
|
||||||
|
if not res:
|
||||||
|
logger.warn("Failed to register hotkey: %s for function %r", key, function)
|
||||||
self.parent.Bind(wx.EVT_HOTKEY, lambda evt: self.process_key(evt, key_id), id=key_id)
|
self.parent.Bind(wx.EVT_HOTKEY, lambda evt: self.process_key(evt, key_id), id=key_id)
|
||||||
self.key_ids[key] = key_id
|
self.key_ids[key] = key_id
|
||||||
|
return res
|
||||||
|
|
||||||
|
def parse_key (self, keystroke, separator="+"):
|
||||||
|
keystroke = str(keystroke) #We don't want unicode
|
||||||
|
keystroke = [self.keycode_from_key(i) for i in keystroke.split(separator)]
|
||||||
|
mods = 0
|
||||||
|
for i in keystroke[:-1]:
|
||||||
|
mods = mods | i #or everything together
|
||||||
|
return (mods, keystroke[-1])
|
||||||
|
|
||||||
@call_after
|
@call_after
|
||||||
def unregister_key (self, key, function):
|
def unregister_key (self, key, function):
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
from builtins import object
|
from builtins import object
|
||||||
|
import os
|
||||||
import application
|
import application
|
||||||
import platform
|
import platform
|
||||||
import exceptions
|
|
||||||
from ctypes import c_char_p
|
from ctypes import c_char_p
|
||||||
from libloader import load_library
|
from libloader import load_library
|
||||||
import paths
|
import paths
|
||||||
@ -13,9 +14,9 @@ import paths
|
|||||||
# lib = load_library("snapshot_api_keys64", x64_path=paths.app_path("keys/lib"))
|
# lib = load_library("snapshot_api_keys64", x64_path=paths.app_path("keys/lib"))
|
||||||
#else:
|
#else:
|
||||||
if platform.architecture()[0][:2] == "32":
|
if platform.architecture()[0][:2] == "32":
|
||||||
lib = load_library("stable_api_keys32", x86_path=paths.app_path("keys/lib"))
|
lib = load_library("stable_api_keys32", x86_path=os.path.join(paths.app_path(), "keys", "lib"))
|
||||||
else:
|
else:
|
||||||
lib = load_library("stable_api_keys64", x64_path=paths.app_path("keys/lib"))
|
lib = load_library("stable_api_keys64", x64_path=os.path.join(paths.app_path(), "keys", "lib"))
|
||||||
|
|
||||||
# import linuxKeys
|
# import linuxKeys
|
||||||
# lib = linuxKeys
|
# lib = linuxKeys
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
def get_api_key():
|
def get_api_key():
|
||||||
return "8pDLbyOW3saYnvSZ4uLFg\0"
|
return "8pDLbyOW3saYnvSZ4uLFg\0"
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
from .keystrokeEditor import KeystrokeEditor
|
from .keystrokeEditor import KeystrokeEditor
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
actions = {
|
actions = {
|
||||||
"up": _(u"Go up in the current buffer"),
|
"up": _(u"Go up in the current buffer"),
|
||||||
"down": _(u"Go down in the current buffer"),
|
"down": _(u"Go down in the current buffer"),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import config
|
import config
|
||||||
from . import wx_ui
|
from . import wx_ui
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
from multiplatform_widgets import widgets
|
from multiplatform_widgets import widgets
|
||||||
from wxUI.dialogs import baseDialog
|
from wxUI.dialogs import baseDialog
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import __builtin__
|
from __future__ import unicode_literals
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import zip
|
||||||
|
from builtins import str
|
||||||
|
import builtins
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
import locale
|
import locale
|
||||||
# add mapping for Serbian (latin) language
|
|
||||||
locale.windows_locale[9242]='sr_RS'
|
|
||||||
import gettext
|
import gettext
|
||||||
import paths
|
import paths
|
||||||
import platform
|
import platform
|
||||||
|
import application
|
||||||
# A fix for the mac locales
|
|
||||||
#if platform.system() == 'Darwin':
|
|
||||||
|
|
||||||
#a few Windows locale constants
|
#a few Windows locale constants
|
||||||
LOCALE_SLANGUAGE=0x2
|
LOCALE_SLANGUAGE=0x2
|
||||||
@ -29,12 +30,12 @@ def localeNameToWindowsLCID(localeName):
|
|||||||
func_LocaleNameToLCID=getattr(ctypes.windll.kernel32,'LocaleNameToLCID',None)
|
func_LocaleNameToLCID=getattr(ctypes.windll.kernel32,'LocaleNameToLCID',None)
|
||||||
if func_LocaleNameToLCID is not None:
|
if func_LocaleNameToLCID is not None:
|
||||||
localeName=localeName.replace('_','-')
|
localeName=localeName.replace('_','-')
|
||||||
LCID=func_LocaleNameToLCID(unicode(localeName),0)
|
LCID=func_LocaleNameToLCID(str(localeName),0)
|
||||||
else: #Windows doesn't have this functionality, manually search Python's windows_locale dictionary for the LCID
|
else: #Windows doesn't have this functionality, manually search Python's windows_locale dictionary for the LCID
|
||||||
localeName=locale.normalize(localeName)
|
localeName=locale.normalize(localeName)
|
||||||
if '.' in localeName:
|
if '.' in localeName:
|
||||||
localeName=localeName.split('.')[0]
|
localeName=localeName.split('.')[0]
|
||||||
LCList=[x[0] for x in locale.windows_locale.iteritems() if x[1]==localeName]
|
LCList=[x[0] for x in locale.windows_locale.items() if x[1]==localeName]
|
||||||
if len(LCList)>0:
|
if len(LCList)>0:
|
||||||
LCID=LCList[0]
|
LCID=LCList[0]
|
||||||
else:
|
else:
|
||||||
@ -72,7 +73,6 @@ def getLanguageDescription(language):
|
|||||||
"ne":pgettext("languageName","Nepali"),
|
"ne":pgettext("languageName","Nepali"),
|
||||||
"sr":pgettext("languageName","Serbian (Latin)"),
|
"sr":pgettext("languageName","Serbian (Latin)"),
|
||||||
"ja":pgettext("languageName","Japanese"),
|
"ja":pgettext("languageName","Japanese"),
|
||||||
"ro":pgettext("languageName","Romanian"),
|
|
||||||
}.get(language,None)
|
}.get(language,None)
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ def getAvailableLanguages():
|
|||||||
"""
|
"""
|
||||||
#Make a list of all the locales found in NVDA's locale dir
|
#Make a list of all the locales found in NVDA's locale dir
|
||||||
l=[x for x in os.listdir(paths.locale_path()) if not x.startswith('.')]
|
l=[x for x in os.listdir(paths.locale_path()) if not x.startswith('.')]
|
||||||
l=[x for x in l if os.path.isfile(paths.locale_path('%s/LC_MESSAGES/twblue.mo' % x))]
|
l=[x for x in l if os.path.isfile(os.path.join(paths.locale_path(), '%s/LC_MESSAGES/%s.po' % (x, application.short_name)))]
|
||||||
#Make sure that en (english) is in the list as it may not have any locale files, but is default
|
#Make sure that en (english) is in the list as it may not have any locale files, but is default
|
||||||
if 'en' not in l:
|
if 'en' not in l:
|
||||||
l.append('en')
|
l.append('en')
|
||||||
@ -98,7 +98,7 @@ def getAvailableLanguages():
|
|||||||
# Translators: the label for the Windows default NVDA interface language.
|
# Translators: the label for the Windows default NVDA interface language.
|
||||||
d.append(_("User default"))
|
d.append(_("User default"))
|
||||||
#return a zipped up version of both the lists (a list with tuples of locale,label)
|
#return a zipped up version of both the lists (a list with tuples of locale,label)
|
||||||
return zip(l,d)
|
return list(zip(l,d))
|
||||||
|
|
||||||
def makePgettext(translations):
|
def makePgettext(translations):
|
||||||
"""Obtaina pgettext function for use with a gettext translations instance.
|
"""Obtaina pgettext function for use with a gettext translations instance.
|
||||||
@ -108,15 +108,15 @@ def makePgettext(translations):
|
|||||||
"""
|
"""
|
||||||
if isinstance(translations, gettext.GNUTranslations):
|
if isinstance(translations, gettext.GNUTranslations):
|
||||||
def pgettext(context, message):
|
def pgettext(context, message):
|
||||||
message = unicode(message)
|
message = str(message)
|
||||||
try:
|
try:
|
||||||
# Look up the message with its context.
|
# Look up the message with its context.
|
||||||
return translations._catalog[u"%s\x04%s" % (context, message)]
|
return translations._catalog["%s\x04%s" % (context, message)]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return message
|
return message
|
||||||
else:
|
else:
|
||||||
def pgettext(context, message):
|
def pgettext(context, message):
|
||||||
return unicode(message)
|
return str(message)
|
||||||
return pgettext
|
return pgettext
|
||||||
|
|
||||||
def setLanguage(lang):
|
def setLanguage(lang):
|
||||||
@ -132,7 +132,7 @@ def setLanguage(lang):
|
|||||||
localeName = Foundation.NSLocale.currentLocale().identifier()
|
localeName = Foundation.NSLocale.currentLocale().identifier()
|
||||||
elif system == "Linux":
|
elif system == "Linux":
|
||||||
localeName = locale.getdefaultlocale()[0]
|
localeName = locale.getdefaultlocale()[0]
|
||||||
trans=gettext.translation('twblue', localedir=paths.locale_path(), languages=[localeName])
|
trans=gettext.translation(application.short_name, localedir=paths.locale_path(), languages=[localeName])
|
||||||
curLang=localeName
|
curLang=localeName
|
||||||
# else:
|
# else:
|
||||||
# localeName=locale.getdefaultlocale()[0]
|
# localeName=locale.getdefaultlocale()[0]
|
||||||
@ -140,7 +140,7 @@ def setLanguage(lang):
|
|||||||
# curLang=localeName
|
# curLang=localeName
|
||||||
|
|
||||||
else:
|
else:
|
||||||
trans=gettext.translation("twblue", localedir=paths.locale_path(), languages=[lang])
|
trans=gettext.translation(application.short_name, localedir=paths.locale_path(), languages=[lang])
|
||||||
curLang=lang
|
curLang=lang
|
||||||
localeChanged=False
|
localeChanged=False
|
||||||
#Try setting Python's locale to lang
|
#Try setting Python's locale to lang
|
||||||
@ -164,9 +164,12 @@ def setLanguage(lang):
|
|||||||
LCID=localeNameToWindowsLCID(lang)
|
LCID=localeNameToWindowsLCID(lang)
|
||||||
ctypes.windll.kernel32.SetThreadLocale(LCID)
|
ctypes.windll.kernel32.SetThreadLocale(LCID)
|
||||||
except IOError:
|
except IOError:
|
||||||
trans=gettext.translation("twblue",fallback=True)
|
trans=gettext.translation(application.short_name, fallback=True)
|
||||||
curLang="en"
|
curLang="en"
|
||||||
trans.install(unicode=True)
|
if sys.version[0] == "3":
|
||||||
|
trans.install()
|
||||||
|
else:
|
||||||
|
trans.install(unicode=True)
|
||||||
# Install our pgettext function.
|
# Install our pgettext function.
|
||||||
# __builtin__.__dict__["pgettext"] = makePgettext(trans)
|
# __builtin__.__dict__["pgettext"] = makePgettext(trans)
|
||||||
|
|
||||||
@ -192,8 +195,7 @@ def langToWindowsLocale(lang):
|
|||||||
languages = {"en": "eng",
|
languages = {"en": "eng",
|
||||||
"ar": "ara",
|
"ar": "ara",
|
||||||
"ca": "cat",
|
"ca": "cat",
|
||||||
"da": "dan",
|
"de": "deu",
|
||||||
"de": "deu",
|
|
||||||
"es": "esp",
|
"es": "esp",
|
||||||
"fi": "fin",
|
"fi": "fin",
|
||||||
"fr": "fre_FRA",
|
"fr": "fre_FRA",
|
||||||
@ -205,7 +207,6 @@ def langToWindowsLocale(lang):
|
|||||||
"ja": "jpn",
|
"ja": "jpn",
|
||||||
"pl": "plk",
|
"pl": "plk",
|
||||||
"pt": "ptb",
|
"pt": "ptb",
|
||||||
"ro": "rom",
|
|
||||||
"ru": "rus",
|
"ru": "rus",
|
||||||
"tr": "trk",
|
"tr": "trk",
|
||||||
"sr": "eng",
|
"sr": "eng",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
import logging
|
import logging
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
import paths
|
import paths
|
||||||
@ -7,33 +8,30 @@ import sys
|
|||||||
APP_LOG_FILE = 'debug.log'
|
APP_LOG_FILE = 'debug.log'
|
||||||
ERROR_LOG_FILE = "error.log"
|
ERROR_LOG_FILE = "error.log"
|
||||||
MESSAGE_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s"
|
MESSAGE_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s"
|
||||||
DATE_FORMAT = u"%d/%m/%Y %H:%M:%S"
|
DATE_FORMAT = "%d/%m/%Y %H:%M:%S"
|
||||||
|
|
||||||
formatter = logging.Formatter(MESSAGE_FORMAT.decode("utf-8"), datefmt=DATE_FORMAT)
|
formatter = logging.Formatter(MESSAGE_FORMAT, datefmt=DATE_FORMAT)
|
||||||
|
|
||||||
requests_log = logging.getLogger("requests")
|
requests_log = logging.getLogger("requests")
|
||||||
requests_log.setLevel(logging.WARNING)
|
requests_log.setLevel(logging.WARNING)
|
||||||
oauthlib_log = logging.getLogger("oauthlib")
|
urllib3 = logging.getLogger("urllib3")
|
||||||
oauthlib_log.setLevel(logging.WARNING)
|
urllib3.setLevel(logging.WARNING)
|
||||||
requests_oauthlib_log = logging.getLogger("requests_oauthlib")
|
requests_oauthlib = logging.getLogger("requests_oauthlib")
|
||||||
requests_oauthlib_log.setLevel(logging.WARNING)
|
requests_oauthlib.setLevel(logging.WARNING)
|
||||||
suds_log = logging.getLogger("suds")
|
oauthlib = logging.getLogger("oauthlib")
|
||||||
suds_log.setLevel(logging.WARNING)
|
oauthlib.setLevel(logging.WARNING)
|
||||||
server_log = logging.getLogger("BaseHTTPServer")
|
|
||||||
server_log.setLevel(logging.WARNING)
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
#handlers
|
#handlers
|
||||||
|
|
||||||
app_handler = RotatingFileHandler(paths.logs_path(APP_LOG_FILE), mode="w")
|
app_handler = RotatingFileHandler(os.path.join(paths.logs_path(), APP_LOG_FILE), mode="w", encoding="utf-8")
|
||||||
app_handler.setFormatter(formatter)
|
app_handler.setFormatter(formatter)
|
||||||
app_handler.setLevel(logging.DEBUG)
|
app_handler.setLevel(logging.DEBUG)
|
||||||
logger.addHandler(app_handler)
|
logger.addHandler(app_handler)
|
||||||
|
|
||||||
error_handler = logging.FileHandler(paths.logs_path(ERROR_LOG_FILE), mode="w")
|
error_handler = logging.FileHandler(os.path.join(paths.logs_path(), ERROR_LOG_FILE), mode="w", encoding="utf-8")
|
||||||
error_handler.setFormatter(formatter)
|
error_handler.setFormatter(formatter)
|
||||||
error_handler.setLevel(logging.ERROR)
|
error_handler.setLevel(logging.ERROR)
|
||||||
logger.addHandler(error_handler)
|
logger.addHandler(error_handler)
|
||||||
|
12
src/main.py
12
src/main.py
@ -17,7 +17,8 @@ if system == "Windows":
|
|||||||
import languageHandler
|
import languageHandler
|
||||||
import paths
|
import paths
|
||||||
#check if TWBlue is installed (Windows only)
|
#check if TWBlue is installed (Windows only)
|
||||||
if os.path.exists(paths.app_path(u"Uninstall.exe")):
|
# ToDo: Remove this soon as this is done already when importing the paths module.
|
||||||
|
if os.path.exists(os.path.join(paths.app_path(), "Uninstall.exe")):
|
||||||
paths.mode="installed"
|
paths.mode="installed"
|
||||||
import commandline
|
import commandline
|
||||||
import config
|
import config
|
||||||
@ -37,8 +38,8 @@ if system == "Windows":
|
|||||||
stderr_temp=sys.stderr
|
stderr_temp=sys.stderr
|
||||||
#if it's a binary version
|
#if it's a binary version
|
||||||
if hasattr(sys, 'frozen'):
|
if hasattr(sys, 'frozen'):
|
||||||
sys.stderr = open(paths.logs_path("stderr.log"), 'w')
|
sys.stderr = open(os.path.join(paths.logs_path(), "stderr.log"), 'w')
|
||||||
sys.stdout = open(paths.logs_path("stdout.log"), 'w')
|
sys.stdout = open(os.path.join(paths.logs_path(), "stdout.log"), 'w')
|
||||||
else:
|
else:
|
||||||
sys.stdout=stdout
|
sys.stdout=stdout
|
||||||
sys.stderr=stderr
|
sys.stderr=stderr
|
||||||
@ -47,8 +48,8 @@ if system == "Windows":
|
|||||||
arch="x86"
|
arch="x86"
|
||||||
if platform.architecture()[0][:2] == "64":
|
if platform.architecture()[0][:2] == "64":
|
||||||
arch="x64"
|
arch="x64"
|
||||||
os.environ['PYTHON_VLC_MODULE_PATH']=str(os.path.abspath(paths.app_path("..", "windows-dependencies", arch)))
|
os.environ['PYTHON_VLC_MODULE_PATH']=os.path.abspath(os.path.join(paths.app_path(), "..", "windows-dependencies", arch))
|
||||||
os.environ['PYTHON_VLC_LIB_PATH']=str(os.path.abspath(paths.app_path("..", "windows-dependencies", arch, "libvlc.dll")))
|
os.environ['PYTHON_VLC_LIB_PATH']=os.path.abspath(os.path.join(paths.app_path(), "..", "windows-dependencies", arch, "libvlc.dll"))
|
||||||
#the final log files have been opened succesfully, let's close the temporary files
|
#the final log files have been opened succesfully, let's close the temporary files
|
||||||
stdout_temp.close()
|
stdout_temp.close()
|
||||||
stderr_temp.close()
|
stderr_temp.close()
|
||||||
@ -72,6 +73,7 @@ def setup():
|
|||||||
fixes.setup()
|
fixes.setup()
|
||||||
output.setup()
|
output.setup()
|
||||||
keys.setup()
|
keys.setup()
|
||||||
|
from controller import settings
|
||||||
from controller import mainController
|
from controller import mainController
|
||||||
from sessionmanager import sessionManager
|
from sessionmanager import sessionManager
|
||||||
app = widgetUtils.mainLoopObject()
|
app = widgetUtils.mainLoopObject()
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
from . import widgets
|
from . import widgets
|
@ -1,4 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import range
|
||||||
|
from builtins import object
|
||||||
import wx
|
import wx
|
||||||
import platform
|
import platform
|
||||||
import logging
|
import logging
|
||||||
@ -27,7 +30,7 @@ class list(object):
|
|||||||
def create_list(self, parent):
|
def create_list(self, parent):
|
||||||
if self.system == "Windows":
|
if self.system == "Windows":
|
||||||
self.list = wx.ListCtrl(parent, -1, **self.listArguments)
|
self.list = wx.ListCtrl(parent, -1, **self.listArguments)
|
||||||
for i in xrange(0, len(self.columns)):
|
for i in range(0, len(self.columns)):
|
||||||
self.list.InsertColumn(i, u"%s" % (self.columns[i]))
|
self.list.InsertColumn(i, u"%s" % (self.columns[i]))
|
||||||
else:
|
else:
|
||||||
self.list = wx.ListBox(parent, -1, choices=[])
|
self.list = wx.ListBox(parent, -1, choices=[])
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
import _winreg
|
from __future__ import unicode_literals
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import str
|
||||||
|
import winreg
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from platform_utils import paths
|
from platform_utils import paths
|
||||||
|
|
||||||
RUN_REGKEY = ur"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
|
RUN_REGKEY = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
|
||||||
|
|
||||||
def is_installed(app_subkey):
|
def is_installed(app_subkey):
|
||||||
"""Checks if the currently running copy is installed or portable variant. Requires the name of the application subkey found under the uninstall section in Windows registry."""
|
"""Checks if the currently running copy is installed or portable variant. Requires the name of the application subkey found under the uninstall section in Windows registry."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s" % app_subkey)
|
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s" % app_subkey)
|
||||||
inst_dir = _winreg.QueryValueEx(key,"InstallLocation")[0]
|
inst_dir = winreg.QueryValueEx(key,"InstallLocation")[0]
|
||||||
except WindowsError:
|
except WindowsError:
|
||||||
return False
|
return False
|
||||||
_winreg.CloseKey(key)
|
winreg.CloseKey(key)
|
||||||
try:
|
try:
|
||||||
return os.stat(inst_dir) == os.stat(paths.app_path())
|
return os.stat(inst_dir) == os.stat(paths.app_path())
|
||||||
except WindowsError:
|
except WindowsError:
|
||||||
@ -23,19 +27,18 @@ def getAutoStart(app_name):
|
|||||||
"""Queries if the automatic startup should be set for the application or not, depending on it's current state."""
|
"""Queries if the automatic startup should be set for the application or not, depending on it's current state."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, RUN_REGKEY)
|
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_REGKEY)
|
||||||
val = _winreg.QueryValueEx(key, unicode(app_name))[0]
|
val = winreg.QueryValueEx(key, str(app_name))[0]
|
||||||
return os.stat(val) == os.stat(sys.argv[0])
|
return os.stat(val) == os.stat(sys.argv[0])
|
||||||
except (WindowsError, OSError):
|
except (WindowsError, OSError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def setAutoStart(app_name, enable=True):
|
def setAutoStart(app_name, enable=True):
|
||||||
"""Configures automatic startup for the application, if the enable argument is set to True. If set to False, deletes the application AutoStart value."""
|
"""Configures automatic startup for the application, if the enable argument is set to True. If set to False, deletes the application AutoStart value."""
|
||||||
print paths.get_executable()
|
|
||||||
if getAutoStart(app_name) == enable:
|
if getAutoStart(app_name) == enable:
|
||||||
return
|
return
|
||||||
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, RUN_REGKEY, 0, _winreg.KEY_WRITE)
|
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_REGKEY, 0, winreg.KEY_WRITE)
|
||||||
if enable:
|
if enable:
|
||||||
_winreg.SetValueEx(key, unicode(app_name), None, _winreg.REG_SZ, paths.get_executable())
|
winreg.SetValueEx(key, str(app_name), None, winreg.REG_SZ, paths.get_executable())
|
||||||
else:
|
else:
|
||||||
_winreg.DeleteValue(key, unicode(app_name))
|
winreg.DeleteValue(key, str(app_name))
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
import os
|
import os
|
||||||
import languageHandler
|
import languageHandler
|
||||||
import logging
|
import logging
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger("mysc.repeating_timer")
|
log = logging.getLogger("mysc.repeating_timer")
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: cp1252
|
# -*- coding: cp1252
|
||||||
|
from __future__ import unicode_literals
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
def restart_program():
|
def restart_program():
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger("mysc.thread_utils")
|
log = logging.getLogger("mysc.thread_utils")
|
||||||
import threading
|
import threading
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
""" A cross platform notification system.
|
""" A cross platform notification system.
|
||||||
Under Linux, the wx.NotificationMessage does not show a notification on the taskbar, so we decided to use dbus for showing notifications for linux and wx for Windows."""
|
Under Linux, the wx.NotificationMessage does not show a notification on the taskbar, so we decided to use dbus for showing notifications for linux and wx for Windows."""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
notify = None
|
notify = None
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import dbus
|
import dbus
|
||||||
import application
|
import application
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
class notification(object):
|
class notification(object):
|
||||||
|
110
src/paths.py
110
src/paths.py
@ -1,85 +1,67 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import sys
|
||||||
import platform
|
import platform
|
||||||
import os
|
import os
|
||||||
import sys
|
import glob
|
||||||
import logging
|
|
||||||
from platform_utils import paths as paths_
|
from platform_utils import paths as paths_
|
||||||
|
|
||||||
from functools import wraps
|
|
||||||
|
|
||||||
mode = "portable"
|
mode = "portable"
|
||||||
directory = None
|
directory = None
|
||||||
|
fsencoding = sys.getfilesystemencoding()
|
||||||
|
|
||||||
log = logging.getLogger("paths")
|
if len(glob.glob("Uninstall.exe")) > 0: # installed copy
|
||||||
|
mode= "installed"
|
||||||
|
|
||||||
def merge_paths(func):
|
|
||||||
@wraps(func)
|
|
||||||
def merge_paths_wrapper(*a):
|
|
||||||
return unicode(os.path.join(func(), *a))
|
|
||||||
return merge_paths_wrapper
|
|
||||||
|
|
||||||
@merge_paths
|
|
||||||
def app_path():
|
def app_path():
|
||||||
return paths_.app_path()
|
return paths_.app_path()
|
||||||
|
|
||||||
@merge_paths
|
|
||||||
def config_path():
|
def config_path():
|
||||||
global mode, directory
|
global mode, directory
|
||||||
if mode == "portable":
|
if mode == "portable":
|
||||||
if directory != None: path = os.path.join(directory, "config")
|
if directory != None: path = os.path.join(directory, "config")
|
||||||
elif directory == None: path = app_path(u"config")
|
elif directory == None: path = os.path.join(app_path(), "config")
|
||||||
elif mode == "installed":
|
elif mode == "installed":
|
||||||
path = data_path(u"config")
|
path = os.path.join(data_path(), "config")
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
log.debug("%s path does not exist, creating..." % (path,))
|
# log.debug("%s path does not exist, creating..." % (path,))
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@merge_paths
|
|
||||||
def logs_path():
|
def logs_path():
|
||||||
global mode, directory
|
global mode, directory
|
||||||
if mode == "portable":
|
if mode == "portable":
|
||||||
if directory != None: path = os.path.join(directory, "logs")
|
if directory != None: path = os.path.join(directory, "logs")
|
||||||
elif directory == None: path = app_path(u"logs")
|
elif directory == None: path = os.path.join(app_path(), "logs")
|
||||||
elif mode == "installed":
|
elif mode == "installed":
|
||||||
path = data_path(u"logs")
|
path = os.path.join(data_path(), "logs")
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
log.debug("%s path does not exist, creating..." % (path,))
|
# log.debug("%s path does not exist, creating..." % (path,))
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@merge_paths
|
def data_path(app_name='socializer'):
|
||||||
def data_path(app_name='TW blue'):
|
if platform.system() == "Windows":
|
||||||
# if platform.system() == "Windows":
|
data_path = os.path.join(os.getenv("AppData"), app_name)
|
||||||
# import shlobj
|
else:
|
||||||
# data_path = os.path.join(shlobj.SHGetFolderPath(0, shlobj.CSIDL_APPDATA), app_name)
|
data_path = os.path.join(os.environ['HOME'], ".%s" % app_name)
|
||||||
# else:
|
if not os.path.exists(data_path):
|
||||||
if platform.system() == "Windows":
|
os.mkdir(data_path)
|
||||||
import winpaths
|
return data_path
|
||||||
data_path = os.path.join(winpaths.get_appdata(), app_name)
|
|
||||||
else:
|
|
||||||
data_path = os.path.join(os.environ['HOME'], ".%s" % app_name)
|
|
||||||
if not os.path.exists(data_path):
|
|
||||||
os.mkdir(data_path)
|
|
||||||
return data_path
|
|
||||||
|
|
||||||
@merge_paths
|
|
||||||
def locale_path():
|
def locale_path():
|
||||||
return app_path(u"locales")
|
return os.path.join(app_path(), "locales")
|
||||||
|
|
||||||
@merge_paths
|
|
||||||
def sound_path():
|
def sound_path():
|
||||||
return app_path(u"sounds")
|
return os.path.join(app_path(), "sounds")
|
||||||
|
|
||||||
@merge_paths
|
|
||||||
def com_path():
|
def com_path():
|
||||||
global mode, directory
|
global mode, directory
|
||||||
if mode == "portable":
|
if mode == "portable":
|
||||||
if directory != None: path = os.path.join(directory, "com_cache")
|
if directory != None: path = os.path.join(directory, "com_cache")
|
||||||
elif directory == None: path = app_path(u"com_cache")
|
elif directory == None: path = os.path.join(app_path(), "com_cache")
|
||||||
elif mode == "installed":
|
elif mode == "installed":
|
||||||
path = data_path(u"com_cache")
|
path = os.path.join(data_path(), "com_cache")
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
log.debug("%s path does not exist, creating..." % (path,))
|
# log.debug("%s path does not exist, creating..." % (path,))
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
return path
|
return path
|
||||||
|
@ -7,3 +7,4 @@ Contents of this package:
|
|||||||
manager: Handles multiple sessions, setting the configuration files and check if the session is valid. Part of the model.
|
manager: Handles multiple sessions, setting the configuration files and check if the session is valid. Part of the model.
|
||||||
session: Creates a twitter session for an user. The other part of the model.
|
session: Creates a twitter session for an user. The other part of the model.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import unicode_literals
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: cp1252 -*-
|
# -*- coding: cp1252 -*-
|
||||||
#from config_utils import Configuration, ConfigurationResetException
|
#from config_utils import Configuration, ConfigurationResetException
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import object
|
||||||
import config
|
import config
|
||||||
import paths
|
import paths
|
||||||
import os
|
import os
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from builtins import object
|
||||||
import shutil
|
import shutil
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import platform
|
import platform
|
||||||
@ -43,14 +46,14 @@ class sessionManagerController(object):
|
|||||||
log.debug("Filling the sessions list.")
|
log.debug("Filling the sessions list.")
|
||||||
self.sessions = []
|
self.sessions = []
|
||||||
for i in os.listdir(paths.config_path()):
|
for i in os.listdir(paths.config_path()):
|
||||||
if os.path.isdir(paths.config_path(i)) and i not in reserved_dirs:
|
if os.path.isdir(os.path.join(paths.config_path(), i)) and i not in reserved_dirs:
|
||||||
log.debug("Adding session %s" % (i,))
|
log.debug("Adding session %s" % (i,))
|
||||||
strconfig = "%s/session.conf" % (paths.config_path(i))
|
strconfig = "%s/session.conf" % (os.path.join(paths.config_path(), i))
|
||||||
config_test = config_utils.load_config(strconfig)
|
config_test = config_utils.load_config(strconfig)
|
||||||
if len(config_test) == 0:
|
if len(config_test) == 0:
|
||||||
try:
|
try:
|
||||||
log.debug("Deleting session %s" % (i,))
|
log.debug("Deleting session %s" % (i,))
|
||||||
shutil.rmtree(paths.config_path(i))
|
shutil.rmtree(os.path.join(paths.config_path(), i))
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
output.speak("An exception was raised while attempting to clean malformed session data. See the error log for details. If this message persists, contact the developers.",True)
|
output.speak("An exception was raised while attempting to clean malformed session data. See the error log for details. If this message persists, contact the developers.",True)
|
||||||
@ -63,7 +66,7 @@ class sessionManagerController(object):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
log.debug("Deleting session %s" % (i,))
|
log.debug("Deleting session %s" % (i,))
|
||||||
shutil.rmtree(paths.config_path(i))
|
shutil.rmtree(os.path.join(paths.config_path(), i))
|
||||||
except:
|
except:
|
||||||
output.speak("An exception was raised while attempting to clean malformed session data. See the error log for details. If this message persists, contact the developers.",True)
|
output.speak("An exception was raised while attempting to clean malformed session data. See the error log for details. If this message persists, contact the developers.",True)
|
||||||
os.exception("Exception thrown while removing malformed session")
|
os.exception("Exception thrown while removing malformed session")
|
||||||
@ -110,7 +113,7 @@ class sessionManagerController(object):
|
|||||||
self.view.remove_session(self.view.get_selected())
|
self.view.remove_session(self.view.get_selected())
|
||||||
self.removed_sessions.append(selected_account)
|
self.removed_sessions.append(selected_account)
|
||||||
self.sessions.remove(selected_account)
|
self.sessions.remove(selected_account)
|
||||||
shutil.rmtree(path=paths.config_path(selected_account), ignore_errors=True)
|
shutil.rmtree(path=os.path.join(paths.config_path(), selected_account), ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
def configuration(self, *args, **kwargs):
|
def configuration(self, *args, **kwargs):
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
from multiplatform_widgets import widgets
|
from multiplatform_widgets import widgets
|
||||||
import application
|
import application
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" this package contains code related to Sessions.
|
""" this package contains code related to Sessions.
|
||||||
In TWBlue, a session module defines everything a social network needs to be used in the program."""
|
In TWBlue, a session module defines everything a social network needs to be used in the program."""
|
||||||
|
from __future__ import unicode_literals
|
||||||
# let's define a global object for storing sessions across the program.
|
# let's define a global object for storing sessions across the program.
|
||||||
sessions = {}
|
sessions = {}
|
@ -1,6 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" A base class to be derived in possible new sessions for TWBlue and services."""
|
""" A base class to be derived in possible new sessions for TWBlue and services."""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from builtins import object
|
||||||
|
import os
|
||||||
import paths
|
import paths
|
||||||
import output
|
import output
|
||||||
import time
|
import time
|
||||||
@ -53,7 +57,7 @@ class baseSession(object):
|
|||||||
""" Get settings for a session."""
|
""" Get settings for a session."""
|
||||||
file_ = "%s/session.conf" % (self.session_id,)
|
file_ = "%s/session.conf" % (self.session_id,)
|
||||||
log.debug("Creating config file %s" % (file_,))
|
log.debug("Creating config file %s" % (file_,))
|
||||||
self.settings = config_utils.load_config(paths.config_path(file_), paths.app_path("Conf.defaults"))
|
self.settings = config_utils.load_config(os.path.join(paths.config_path(), file_), os.path.join(paths.app_path(), "Conf.defaults"))
|
||||||
self.init_sound()
|
self.init_sound()
|
||||||
self.deshelve()
|
self.deshelve()
|
||||||
|
|
||||||
@ -71,7 +75,7 @@ class baseSession(object):
|
|||||||
|
|
||||||
def shelve(self):
|
def shelve(self):
|
||||||
"""Shelve the database to allow for persistance."""
|
"""Shelve the database to allow for persistance."""
|
||||||
shelfname=paths.config_path(str(self.session_id)+"/cache.db")
|
shelfname=os.path.join(paths.config_path(), str(self.session_id)+"/cache.db")
|
||||||
if self.settings["general"]["persist_size"] == 0:
|
if self.settings["general"]["persist_size"] == 0:
|
||||||
if os.path.exists(shelfname):
|
if os.path.exists(shelfname):
|
||||||
os.remove(shelfname)
|
os.remove(shelfname)
|
||||||
@ -79,9 +83,9 @@ class baseSession(object):
|
|||||||
try:
|
try:
|
||||||
if not os.path.exists(shelfname):
|
if not os.path.exists(shelfname):
|
||||||
output.speak("Generating database, this might take a while.",True)
|
output.speak("Generating database, this might take a while.",True)
|
||||||
shelf=shelve.open(paths.config_path(shelfname),'c')
|
shelf=shelve.open(os.path.join(paths.config_path(), shelfname),'c')
|
||||||
for key,value in self.db.items():
|
for key,value in list(self.db.items()):
|
||||||
if type(key) != str and type(key) != unicode:
|
if type(key) != str and type(key) != str:
|
||||||
output.speak("Uh oh, while shelving the database, a key of type " + str(type(key)) + " has been found. It will be converted to type str, but this will cause all sorts of problems on deshelve. Please bring this to the attention of the " + application.name + " developers immediately. More information about the error will be written to the error log.",True)
|
output.speak("Uh oh, while shelving the database, a key of type " + str(type(key)) + " has been found. It will be converted to type str, but this will cause all sorts of problems on deshelve. Please bring this to the attention of the " + application.name + " developers immediately. More information about the error will be written to the error log.",True)
|
||||||
log.error("Uh oh, " + str(key) + " is of type " + str(type(key)) + "!")
|
log.error("Uh oh, " + str(key) + " is of type " + str(type(key)) + "!")
|
||||||
# Convert unicode objects to UTF-8 strings before shelve these objects.
|
# Convert unicode objects to UTF-8 strings before shelve these objects.
|
||||||
@ -97,14 +101,14 @@ class baseSession(object):
|
|||||||
|
|
||||||
def deshelve(self):
|
def deshelve(self):
|
||||||
"""Import a shelved database."""
|
"""Import a shelved database."""
|
||||||
shelfname=paths.config_path(str(self.session_id)+"/cache.db")
|
shelfname=os.path.join(paths.config_path(), str(self.session_id)+"/cache.db")
|
||||||
if self.settings["general"]["persist_size"] == 0:
|
if self.settings["general"]["persist_size"] == 0:
|
||||||
if os.path.exists(shelfname):
|
if os.path.exists(shelfname):
|
||||||
os.remove(shelfname)
|
os.remove(shelfname)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
shelf=shelve.open(paths.config_path(shelfname),'c')
|
shelf=shelve.open(os.path.join(paths.config_path(), shelfname),'c')
|
||||||
for key,value in shelf.items():
|
for key,value in list(shelf.items()):
|
||||||
self.db[key]=value
|
self.db[key]=value
|
||||||
shelf.close()
|
shelf.close()
|
||||||
except:
|
except:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# -*- coding: cp1252 -*-
|
# -*- coding: cp1252 -*-
|
||||||
import exceptions
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
class InvalidSessionError(exceptions.Exception): pass
|
class InvalidSessionError(Exception): pass
|
||||||
class NonExistentSessionError(exceptions.Exception): pass
|
class NonExistentSessionError(Exception): pass
|
||||||
class NotLoggedSessionError(exceptions.BaseException): pass
|
class NotLoggedSessionError(BaseException): pass
|
||||||
class NotConfiguredSessionError(exceptions.BaseException): pass
|
class NotConfiguredSessionError(BaseException): pass
|
||||||
class RequireCredentialsSessionError(exceptions.BaseException): pass
|
class RequireCredentialsSessionError(BaseException): pass
|
||||||
class AlreadyAuthorisedError(exceptions.BaseException): pass
|
class AlreadyAuthorisedError(BaseException): pass
|
@ -1,10 +1,16 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import str
|
||||||
|
from builtins import chr
|
||||||
|
from builtins import range
|
||||||
import platform
|
import platform
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
from . import utils
|
from . import utils
|
||||||
import re
|
import re
|
||||||
import htmlentitydefs
|
import html.entities
|
||||||
import time
|
import time
|
||||||
import output
|
import output
|
||||||
import languageHandler
|
import languageHandler
|
||||||
@ -22,10 +28,10 @@ def StripChars(s):
|
|||||||
If we match &blah; and it's not found, &blah; will be returned.
|
If we match &blah; and it's not found, &blah; will be returned.
|
||||||
if we match #\d+, unichr(digits) will be returned.
|
if we match #\d+, unichr(digits) will be returned.
|
||||||
Else, a unicode string will be returned."""
|
Else, a unicode string will be returned."""
|
||||||
if match.group(1).startswith('#'): return unichr(int(match.group(1)[1:]))
|
if match.group(1).startswith('#'): return chr(int(match.group(1)[1:]))
|
||||||
replacement = htmlentitydefs.entitydefs.get(match.group(1), "&%s;" % match.group(1))
|
replacement = html.entities.entitydefs.get(match.group(1), "&%s;" % match.group(1))
|
||||||
return replacement.decode('iso-8859-1')
|
return replacement
|
||||||
return unicode(entity_re.sub(matchFunc, s))
|
return str(entity_re.sub(matchFunc, s))
|
||||||
|
|
||||||
chars = "abcdefghijklmnopqrstuvwxyz"
|
chars = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" this package holds different modules to extract information regarding long tweets. A long tweet contains more than one tweet (such a quoted tweet), or is made via services like twishort."""
|
""" this package holds different modules to extract information regarding long tweets. A long tweet contains more than one tweet (such a quoted tweet), or is made via services like twishort."""
|
||||||
|
from __future__ import unicode_literals
|
@ -16,6 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
|
from __future__ import unicode_literals
|
||||||
from sessions.twitter import utils
|
from sessions.twitter import utils
|
||||||
|
|
||||||
def is_long(tweet):
|
def is_long(tweet):
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import range
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
import keys
|
import keys
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" This is the main session needed to access all Twitter Features."""
|
""" This is the main session needed to access all Twitter Features."""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import range
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
@ -368,6 +370,7 @@ class Session(base.baseSession):
|
|||||||
else:
|
else:
|
||||||
return quoted_tweet
|
return quoted_tweet
|
||||||
original_tweet = self.check_long_tweet(original_tweet)
|
original_tweet = self.check_long_tweet(original_tweet)
|
||||||
|
|
||||||
if "full_text" in original_tweet:
|
if "full_text" in original_tweet:
|
||||||
value = "full_text"
|
value = "full_text"
|
||||||
elif "message" in original_tweet:
|
elif "message" in original_tweet:
|
||||||
@ -430,7 +433,7 @@ class Session(base.baseSession):
|
|||||||
self.db["users"][user["id_str"]] = user
|
self.db["users"][user["id_str"]] = user
|
||||||
return user["id_str"]
|
return user["id_str"]
|
||||||
else:
|
else:
|
||||||
for i in self.db["users"].keys():
|
for i in list(self.db["users"].keys()):
|
||||||
if self.db["users"][i]["screen_name"] == screen_name:
|
if self.db["users"][i]["screen_name"] == screen_name:
|
||||||
return self.db["users"][i]["id_str"]
|
return self.db["users"][i]["id_str"]
|
||||||
user = utils.if_user_exists(self.twitter, screen_name)
|
user = utils.if_user_exists(self.twitter, screen_name)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from builtins import range
|
||||||
import url_shortener, re
|
import url_shortener, re
|
||||||
import output
|
import output
|
||||||
from twython import TwythonError
|
from twython import TwythonError
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
class authorisationDialog(wx.Dialog):
|
class authorisationDialog(wx.Dialog):
|
||||||
|
10
src/sound.py
10
src/sound.py
@ -36,7 +36,7 @@ def setup():
|
|||||||
|
|
||||||
def recode_audio(filename, quality=4.5):
|
def recode_audio(filename, quality=4.5):
|
||||||
global system
|
global system
|
||||||
if system == "Windows": subprocess.call(r'"%s" -q %r "%s"' % (paths.app_path('oggenc2.exe'), quality, filename))
|
if system == "Windows": subprocess.call(r'"%s" -q %r "%s"' % (os.path.join(paths.app_path(), 'oggenc2.exe'), quality, filename))
|
||||||
|
|
||||||
def recording(filename):
|
def recording(filename):
|
||||||
# try:
|
# try:
|
||||||
@ -51,12 +51,12 @@ class soundSystem(object):
|
|||||||
def check_soundpack(self):
|
def check_soundpack(self):
|
||||||
""" Checks if the folder where live the current soundpack exists."""
|
""" Checks if the folder where live the current soundpack exists."""
|
||||||
self.soundpack_OK = False
|
self.soundpack_OK = False
|
||||||
if os.path.exists(paths.sound_path(self.config["current_soundpack"])):
|
if os.path.exists(os.path.join(paths.sound_path(), self.config["current_soundpack"])):
|
||||||
self.path = paths.sound_path(self.config["current_soundpack"])
|
self.path = os.path.join(paths.sound_path(), self.config["current_soundpack"])
|
||||||
self.soundpack_OK = True
|
self.soundpack_OK = True
|
||||||
elif os.path.exists(paths.sound_path("default")):
|
elif os.path.exists(os.path.join(paths.sound_path(), "default")):
|
||||||
log.error("The soundpack does not exist, using default...")
|
log.error("The soundpack does not exist, using default...")
|
||||||
self.path = paths.sound_path("default")
|
self.path = os.path.join(paths.sound_path(), "default")
|
||||||
self.soundpack_OK = True
|
self.soundpack_OK = True
|
||||||
else:
|
else:
|
||||||
log.error("The current soundpack could not be found and the default soundpack has been deleted, " + application.name + " will not play sounds.")
|
log.error("The current soundpack could not be found and the default soundpack has been deleted, " + application.name + " will not play sounds.")
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
import glob
|
import glob
|
||||||
import os.path
|
import os.path
|
||||||
import platform
|
import platform
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
logger = getLogger('update')
|
logger = getLogger('update')
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
import application
|
import application
|
||||||
from . import update
|
from . import update
|
||||||
import platform
|
import platform
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
def convert_bytes(n):
|
def convert_bytes(n):
|
||||||
K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
|
K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
|
||||||
if n >= P:
|
if n >= P:
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import str
|
||||||
|
from past.utils import old_div
|
||||||
import wx
|
import wx
|
||||||
import application
|
import application
|
||||||
from . import utils
|
from . import utils
|
||||||
@ -25,7 +29,7 @@ def progress_callback(total_downloaded, total_size):
|
|||||||
if total_downloaded == total_size:
|
if total_downloaded == total_size:
|
||||||
progress_dialog.Destroy()
|
progress_dialog.Destroy()
|
||||||
else:
|
else:
|
||||||
progress_dialog.Update((total_downloaded*100)/total_size, _(u"Updating... %s of %s") % (str(utils.convert_bytes(total_downloaded)), str(utils.convert_bytes(total_size))))
|
progress_dialog.Update(old_div((total_downloaded*100),total_size), _(u"Updating... %s of %s") % (str(utils.convert_bytes(total_downloaded)), str(utils.convert_bytes(total_size))))
|
||||||
|
|
||||||
def update_finished():
|
def update_finished():
|
||||||
ms = wx.MessageDialog(None, _(u"The update has been downloaded and installed successfully. Press OK to continue."), _(u"Done!")).ShowModal()
|
ms = wx.MessageDialog(None, _(u"The update has been downloaded and installed successfully. Press OK to continue."), _(u"Done!")).ShowModal()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user