mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Initial Python 3 compatible code
This commit is contained in:
parent
d441536f01
commit
ef689d04fc
@ -2,6 +2,7 @@
|
||||
import datetime
|
||||
|
||||
name = 'TWBlue'
|
||||
short_name='twblue'
|
||||
snapshot = True
|
||||
if snapshot == False:
|
||||
version = "0.94"
|
||||
@ -11,11 +12,11 @@ else:
|
||||
version = "14"
|
||||
update_url = 'https://twblue.es/updates/snapshot.php'
|
||||
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"
|
||||
copyright = u"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.")
|
||||
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)"]
|
||||
copyright = "Copyright (C) 2013-2018, Manuel cortéz."
|
||||
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 = ["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"
|
||||
report_bugs_url = "https://github.com/manuelcortez/twblue/issues"
|
||||
supported_languages = []
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
from functools import wraps
|
||||
|
||||
def matches_url(url):
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
from audio_services import matches_url
|
||||
import youtube_utils
|
||||
import requests
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import youtube_dl
|
||||
|
||||
def get_video_url(url):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: cp1252 -*-
|
||||
import os
|
||||
import config_utils
|
||||
import paths
|
||||
import logging
|
||||
@ -16,7 +17,7 @@ changed_keymap = False
|
||||
def setup ():
|
||||
global app
|
||||
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...")
|
||||
global keymap
|
||||
if float(platform.version()[:2]) >= 10 and app["app-settings"]["load_keymap"] == "default.keymap":
|
||||
@ -24,4 +25,4 @@ def setup ():
|
||||
app.write()
|
||||
global changed_keymap
|
||||
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 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import os
|
||||
import widgetUtils
|
||||
import logging
|
||||
|
@ -4,4 +4,5 @@
|
||||
Currently, the package contains the following modules:
|
||||
* 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.
|
||||
"""
|
||||
"""
|
||||
from __future__ import unicode_literals
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" Common logic to all buffers in TWBlue."""
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import logging
|
||||
import wx
|
||||
import output
|
||||
|
@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
import time
|
||||
import platform
|
||||
if platform.system() == "Windows":
|
||||
@ -67,7 +70,7 @@ class baseBufferController(baseBuffers.buffer):
|
||||
""" Get buffer name from a set of different techniques."""
|
||||
# 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"))
|
||||
if self.name in basic_buffers.keys():
|
||||
if self.name in list(basic_buffers.keys()):
|
||||
return basic_buffers[self.name]
|
||||
# Check user timelines
|
||||
elif hasattr(self, "username"):
|
||||
@ -266,7 +269,7 @@ class baseBufferController(baseBuffers.buffer):
|
||||
|
||||
def remove_tweet(self, id):
|
||||
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:
|
||||
self.session.db[self.name].pop(i)
|
||||
self.remove_item(i)
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import time
|
||||
import widgetUtils
|
||||
import application
|
||||
@ -51,7 +53,7 @@ class filterManager(object):
|
||||
|
||||
def insert_filters(self, filters):
|
||||
self.dialog.filters.clear()
|
||||
for f in filters.keys():
|
||||
for f in list(filters.keys()):
|
||||
filterName = f
|
||||
buffer = filters[f]["in_buffer"]
|
||||
if filters[f]["if_word_exists"] == "True" and filters[f]["word"] != "":
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import widgetUtils
|
||||
import output
|
||||
from wxUI.dialogs import lists
|
||||
|
@ -1,5 +1,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
|
||||
system = platform.system()
|
||||
import application
|
||||
@ -268,7 +271,7 @@ class Controller(object):
|
||||
self.start_buffers(sessions.sessions[i])
|
||||
self.set_buffer_positions(sessions.sessions[i])
|
||||
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:
|
||||
output.speak(_(u"Ready"))
|
||||
self.started = True
|
||||
@ -465,7 +468,7 @@ class Controller(object):
|
||||
output.speak(_(u"Empty buffer."), True)
|
||||
return
|
||||
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():
|
||||
page.buffer.list.select_item(i)
|
||||
return output.speak(page.get_message(), True)
|
||||
@ -969,8 +972,8 @@ class Controller(object):
|
||||
x = tweet["coordinates"]["coordinates"][0]
|
||||
y = tweet["coordinates"]["coordinates"][1]
|
||||
address = geocoder.reverse_geocode(y, x, language = languageHandler.curLang)
|
||||
if event == None: output.speak(address[0].__str__().decode("utf-8"))
|
||||
else: self.view.show_address(address[0].__str__().decode("utf-8"))
|
||||
if event == None: output.speak(address[0].__str__())
|
||||
else: self.view.show_address(address[0].__str__())
|
||||
else:
|
||||
output.speak(_(u"There are no coordinates in this tweet"))
|
||||
except GeocoderError:
|
||||
@ -1580,7 +1583,7 @@ class Controller(object):
|
||||
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]
|
||||
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"))
|
||||
if dialog.get_response() == widgetUtils.OK:
|
||||
img = media_list[dialog.get_item()]
|
||||
|
@ -1,5 +1,9 @@
|
||||
# -*- 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 re
|
||||
import platform
|
||||
from . import attach
|
||||
@ -173,14 +177,14 @@ class reply(tweet):
|
||||
|
||||
def get_ids(self):
|
||||
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:
|
||||
excluded_ids = excluded_ids + "{0},".format(self.ids[i],)
|
||||
return excluded_ids
|
||||
|
||||
def get_people(self):
|
||||
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:
|
||||
people = people + "{0} ".format(self.message.checkboxes[i].GetLabel(),)
|
||||
return people
|
||||
@ -205,7 +209,7 @@ class viewTweet(basicTweet):
|
||||
self.title = _(u"Tweet")
|
||||
image_description = []
|
||||
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.
|
||||
if "message" in tweetList[i] and tweetList[i]["is_quote_status"] == False:
|
||||
value = "message"
|
||||
@ -231,7 +235,7 @@ class viewTweet(basicTweet):
|
||||
rt_count = str(tweet["retweet_count"])
|
||||
favs_count = str(tweet["favorite_count"])
|
||||
# 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")
|
||||
date = original_date.replace(seconds=utc_offset).format(_(u"MMM D, YYYY. H:m"), locale=languageHandler.getLanguage())
|
||||
if text == "":
|
||||
@ -255,7 +259,7 @@ class viewTweet(basicTweet):
|
||||
for z in tweet["retweeted_status"]["extended_entities"]["media"]:
|
||||
if "ext_alt_text" in z and z["ext_alt_text"] != None:
|
||||
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_image_description(i) for i in image_description]
|
||||
else:
|
||||
|
@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
import os
|
||||
import webbrowser
|
||||
import sound_lib
|
||||
@ -49,7 +52,7 @@ class globalSettingsController(object):
|
||||
id = self.codes.index(config.app["app-settings"]["language"])
|
||||
self.kmfriendlies=[]
|
||||
self.kmnames=[]
|
||||
for k,v in self.kmmap.items():
|
||||
for k,v in list(self.kmmap.items()):
|
||||
self.kmfriendlies.append(k)
|
||||
self.kmnames.append(v)
|
||||
self.kmid=self.kmnames.index(config.app['app-settings']['load_keymap'])
|
||||
@ -291,7 +294,7 @@ class accountSettingsController(globalSettingsController):
|
||||
all_buffers['muted']=_(u"Muted users")
|
||||
list_buffers = []
|
||||
hidden_buffers=[]
|
||||
all_buffers_keys = all_buffers.keys()
|
||||
all_buffers_keys = list(all_buffers.keys())
|
||||
# Check buffers shown first.
|
||||
for i in self.config["general"]["buffer_order"]:
|
||||
if i in all_buffers_keys:
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
from wxUI.dialogs import trends
|
||||
import widgetUtils
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import wx
|
||||
import webbrowser
|
||||
import widgetUtils
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import re
|
||||
import widgetUtils
|
||||
import output
|
||||
|
@ -17,6 +17,9 @@
|
||||
#
|
||||
############################################################
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
import widgetUtils
|
||||
from . import wx_ui
|
||||
from . import wx_transfer_dialogs
|
||||
@ -132,7 +135,7 @@ class audioUploader(object):
|
||||
def _play(self):
|
||||
output.speak(_(u"Playing..."))
|
||||
# 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.dialog.set("play", _(u"&Stop"))
|
||||
try:
|
||||
|
@ -1,5 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
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 threading
|
||||
import time
|
||||
@ -21,7 +25,7 @@ class Upload(object):
|
||||
self.background_thread = None
|
||||
self.transfer_rate = 0
|
||||
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.fin=open(self.filename, 'rb')
|
||||
self.m = MultipartEncoder(fields={field:(self.local_filename, self.fin, "application/octet-stream")})
|
||||
@ -45,10 +49,10 @@ class Upload(object):
|
||||
self.transfer_rate = 0
|
||||
else:
|
||||
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)
|
||||
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:
|
||||
progress["eta"] = 0
|
||||
pub.sendMessage("uploading", data=progress)
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
def convert_bytes(n):
|
||||
K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
|
||||
if n >= P:
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
from .utils import *
|
||||
import widgetUtils
|
||||
|
@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import widgetUtils
|
||||
import output
|
||||
|
@ -1,2 +1,3 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from .soundsTutorial import soundsTutorial
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from gi.repository import Gtk
|
||||
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
|
||||
def invert_tuples(t):
|
||||
"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 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import platform
|
||||
import widgetUtils
|
||||
import os
|
||||
|
@ -1,5 +1,6 @@
|
||||
#-*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
#-*- coding: utf-8 -*-
|
||||
from . import reverse_sort
|
||||
import application
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import widgetUtils
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from . import spellchecker
|
||||
import platform
|
||||
if platform.system() == "Windows":
|
||||
|
@ -1,5 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import next
|
||||
from builtins import object
|
||||
import os
|
||||
import logging
|
||||
from . import wx_ui
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import re
|
||||
from enchant.tokenize import Filter
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import application
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import completion, settings
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import output
|
||||
from . import storage
|
||||
from . import wx_menu
|
||||
|
@ -1,6 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
# -*- coding: utf-8 -*-
|
||||
from builtins import object
|
||||
from . import storage
|
||||
import widgetUtils
|
||||
from . import wx_manage
|
||||
|
@ -1,6 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
# -*- coding: utf-8 -*-
|
||||
from builtins import object
|
||||
from . import storage
|
||||
import widgetUtils
|
||||
from . import wx_settings
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import sqlite3, paths
|
||||
|
||||
class storage(object):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import widgetUtils
|
||||
from multiplatform_widgets import widgets
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
|
||||
class menu(wx.Menu):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import widgetUtils
|
||||
import application
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" original module taken and modified from https://github.com/ctoth/cloudOCR"""
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
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")]
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import OCRSpace
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from . import translator
|
||||
import platform
|
||||
if platform.system() == "Windows":
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import zip
|
||||
from yandex_translate import YandexTranslate
|
||||
|
||||
def translate(text="", target="en"):
|
||||
|
@ -17,6 +17,7 @@
|
||||
#
|
||||
############################################################
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
# -*- coding: utf-8 -*-
|
||||
############################################################
|
||||
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
|
||||
|
@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" This module contains some bugfixes for packages used in TWBlue."""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
import sys
|
||||
from . import fix_arrow # A few new locales for Three languages in arrow.
|
||||
from . import fix_libloader # Regenerates comcache properly.
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from arrow import locales
|
||||
from arrow.locales import Locale
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import logging
|
||||
import win32com
|
||||
import paths
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
from requests import certs, utils, adapters
|
||||
import paths
|
||||
import config
|
||||
|
@ -1,8 +1,11 @@
|
||||
# -*- 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.urllib3 import fields
|
||||
import six
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
|
||||
def fix():
|
||||
urllib3.disable_warnings()
|
||||
@ -19,6 +22,6 @@ def patched_format_header_param(name, value):
|
||||
return result
|
||||
if not six.PY3 and isinstance(value, six.text_type): # Python 2:
|
||||
value = value.encode('utf-8')
|
||||
value=urllib.quote(value, safe='')
|
||||
value=urllib.parse.quote(value, safe='')
|
||||
value = '%s=%s' % (name, value)
|
||||
return value
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
import win32com.client
|
||||
def fix():
|
||||
if win32com.client.gencache.is_readonly == True:
|
||||
|
@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
categories = ["General"]
|
||||
reproducibilities = ["always", "sometimes", "random", "have not tried", "unable to duplicate"]
|
||||
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/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import keys
|
||||
import wx
|
||||
import wx_ui
|
||||
|
@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import widgetUtils
|
||||
import application
|
||||
|
@ -1,3 +1,3 @@
|
||||
from main import KeyboardHandler, KeyboardHandlerError
|
||||
#from wx_handler import WXKeyboardHandler
|
||||
__all__ = ["KeyboardHandler", "KeyboardHandlerError", "WXKeyboardHandler", "WXPanelKeyboardHandler"]
|
||||
from __future__ import absolute_import
|
||||
from .main import KeyboardHandler, KeyboardHandlerError
|
||||
__all__ = ["KeyboardHandler", "KeyboardHandlerError", ]
|
||||
|
@ -1,7 +1,8 @@
|
||||
from __future__ import absolute_import
|
||||
import platform
|
||||
if platform.system() == 'Linux':
|
||||
from linux import LinuxKeyboardHandler as GlobalKeyboardHandler
|
||||
elif platform.system() == 'Windows':
|
||||
from wx_handler import WXKeyboardHandler as GlobalKeyboardHandler
|
||||
elif platform.system() == 'Darwin':
|
||||
from osx import OSXKeyboardHandler as GlobalKeyboardHandler
|
||||
from .linux import LinuxKeyboardHandler as GlobalKeyboardHandler
|
||||
else:
|
||||
from .wx_handler import WXKeyboardHandler as GlobalKeyboardHandler
|
||||
#elif platform.system() == 'Darwin':
|
||||
#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):
|
||||
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):
|
||||
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
|
||||
|
||||
def unregister_key (self, key, function):
|
||||
try:
|
||||
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:
|
||||
raise KeyboardHandlerError, "Key %s not currently registered"
|
||||
raise KeyboardHandlerError("Key %s not currently registered" % key)
|
||||
del(self.active_keys[key])
|
||||
|
||||
def unregister_all_keys(self):
|
||||
|
@ -1,11 +1,14 @@
|
||||
from __future__ import absolute_import
|
||||
import functools
|
||||
import logging
|
||||
logger = logging.getLogger("keyboard_handler")
|
||||
import wx
|
||||
import platform
|
||||
from main import KeyboardHandler
|
||||
|
||||
from .main import KeyboardHandler, KeyboardHandlerError
|
||||
from . import key_constants
|
||||
|
||||
__all__ = ['WXKeyboardHandler', 'WXControlKeyboardHandler']
|
||||
|
||||
|
||||
def call_after(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
wx.CallAfter(func, *args, **kwargs)
|
||||
@ -34,6 +37,7 @@ class BaseWXKeyboardHandler(KeyboardHandler):
|
||||
return (mods, keystroke[-1])
|
||||
|
||||
def keycode_from_key(self, key):
|
||||
result = None
|
||||
if key in self.replacement_mods:
|
||||
result = self.replacement_mods[key]
|
||||
elif key in self.replacement_keys:
|
||||
@ -42,33 +46,40 @@ class BaseWXKeyboardHandler(KeyboardHandler):
|
||||
result -= 277
|
||||
elif len(key) == 1:
|
||||
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
|
||||
|
||||
|
||||
|
||||
class WXKeyboardHandler(BaseWXKeyboardHandler):
|
||||
|
||||
#try:
|
||||
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):
|
||||
super(WXKeyboardHandler, self).__init__(*args, **kwargs)
|
||||
self.parent = parent
|
||||
self.key_ids = {}
|
||||
self.replacement_keys = key_constants.keys
|
||||
self.replacement_mods = key_constants.modifiers
|
||||
|
||||
@call_after
|
||||
def register_key(self, key, function):
|
||||
super(WXKeyboardHandler, self).register_key(key, function)
|
||||
key_id = wx.NewId()
|
||||
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.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
|
||||
def unregister_key (self, key, function):
|
||||
|
@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import os
|
||||
import application
|
||||
import platform
|
||||
import exceptions
|
||||
from ctypes import c_char_p
|
||||
from libloader import load_library
|
||||
import paths
|
||||
@ -13,9 +14,9 @@ import paths
|
||||
# lib = load_library("snapshot_api_keys64", x64_path=paths.app_path("keys/lib"))
|
||||
#else:
|
||||
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:
|
||||
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
|
||||
# lib = linuxKeys
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
def get_api_key():
|
||||
return "8pDLbyOW3saYnvSZ4uLFg\0"
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from .keystrokeEditor import KeystrokeEditor
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
actions = {
|
||||
"up": _(u"Go up in the current buffer"),
|
||||
"down": _(u"Go down in the current buffer"),
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import widgetUtils
|
||||
import config
|
||||
from . import wx_ui
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
from multiplatform_widgets import widgets
|
||||
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 sys
|
||||
import ctypes
|
||||
import locale
|
||||
# add mapping for Serbian (latin) language
|
||||
locale.windows_locale[9242]='sr_RS'
|
||||
import gettext
|
||||
import paths
|
||||
import platform
|
||||
|
||||
# A fix for the mac locales
|
||||
#if platform.system() == 'Darwin':
|
||||
import application
|
||||
|
||||
#a few Windows locale constants
|
||||
LOCALE_SLANGUAGE=0x2
|
||||
@ -29,12 +30,12 @@ def localeNameToWindowsLCID(localeName):
|
||||
func_LocaleNameToLCID=getattr(ctypes.windll.kernel32,'LocaleNameToLCID',None)
|
||||
if func_LocaleNameToLCID is not None:
|
||||
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
|
||||
localeName=locale.normalize(localeName)
|
||||
if '.' in localeName:
|
||||
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:
|
||||
LCID=LCList[0]
|
||||
else:
|
||||
@ -72,7 +73,6 @@ def getLanguageDescription(language):
|
||||
"ne":pgettext("languageName","Nepali"),
|
||||
"sr":pgettext("languageName","Serbian (Latin)"),
|
||||
"ja":pgettext("languageName","Japanese"),
|
||||
"ro":pgettext("languageName","Romanian"),
|
||||
}.get(language,None)
|
||||
return desc
|
||||
|
||||
@ -82,7 +82,7 @@ def getAvailableLanguages():
|
||||
"""
|
||||
#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 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
|
||||
if 'en' not in l:
|
||||
l.append('en')
|
||||
@ -98,7 +98,7 @@ def getAvailableLanguages():
|
||||
# Translators: the label for the Windows default NVDA interface language.
|
||||
d.append(_("User default"))
|
||||
#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):
|
||||
"""Obtaina pgettext function for use with a gettext translations instance.
|
||||
@ -108,15 +108,15 @@ def makePgettext(translations):
|
||||
"""
|
||||
if isinstance(translations, gettext.GNUTranslations):
|
||||
def pgettext(context, message):
|
||||
message = unicode(message)
|
||||
message = str(message)
|
||||
try:
|
||||
# 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:
|
||||
return message
|
||||
else:
|
||||
def pgettext(context, message):
|
||||
return unicode(message)
|
||||
return str(message)
|
||||
return pgettext
|
||||
|
||||
def setLanguage(lang):
|
||||
@ -132,7 +132,7 @@ def setLanguage(lang):
|
||||
localeName = Foundation.NSLocale.currentLocale().identifier()
|
||||
elif system == "Linux":
|
||||
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
|
||||
# else:
|
||||
# localeName=locale.getdefaultlocale()[0]
|
||||
@ -140,7 +140,7 @@ def setLanguage(lang):
|
||||
# curLang=localeName
|
||||
|
||||
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
|
||||
localeChanged=False
|
||||
#Try setting Python's locale to lang
|
||||
@ -164,9 +164,12 @@ def setLanguage(lang):
|
||||
LCID=localeNameToWindowsLCID(lang)
|
||||
ctypes.windll.kernel32.SetThreadLocale(LCID)
|
||||
except IOError:
|
||||
trans=gettext.translation("twblue",fallback=True)
|
||||
trans=gettext.translation(application.short_name, fallback=True)
|
||||
curLang="en"
|
||||
trans.install(unicode=True)
|
||||
if sys.version[0] == "3":
|
||||
trans.install()
|
||||
else:
|
||||
trans.install(unicode=True)
|
||||
# Install our pgettext function.
|
||||
# __builtin__.__dict__["pgettext"] = makePgettext(trans)
|
||||
|
||||
@ -192,8 +195,7 @@ def langToWindowsLocale(lang):
|
||||
languages = {"en": "eng",
|
||||
"ar": "ara",
|
||||
"ca": "cat",
|
||||
"da": "dan",
|
||||
"de": "deu",
|
||||
"de": "deu",
|
||||
"es": "esp",
|
||||
"fi": "fin",
|
||||
"fr": "fre_FRA",
|
||||
@ -205,7 +207,6 @@ def langToWindowsLocale(lang):
|
||||
"ja": "jpn",
|
||||
"pl": "plk",
|
||||
"pt": "ptb",
|
||||
"ro": "rom",
|
||||
"ru": "rus",
|
||||
"tr": "trk",
|
||||
"sr": "eng",
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
import paths
|
||||
@ -7,33 +8,30 @@ import sys
|
||||
APP_LOG_FILE = 'debug.log'
|
||||
ERROR_LOG_FILE = "error.log"
|
||||
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.setLevel(logging.WARNING)
|
||||
oauthlib_log = logging.getLogger("oauthlib")
|
||||
oauthlib_log.setLevel(logging.WARNING)
|
||||
requests_oauthlib_log = logging.getLogger("requests_oauthlib")
|
||||
requests_oauthlib_log.setLevel(logging.WARNING)
|
||||
suds_log = logging.getLogger("suds")
|
||||
suds_log.setLevel(logging.WARNING)
|
||||
server_log = logging.getLogger("BaseHTTPServer")
|
||||
server_log.setLevel(logging.WARNING)
|
||||
|
||||
urllib3 = logging.getLogger("urllib3")
|
||||
urllib3.setLevel(logging.WARNING)
|
||||
requests_oauthlib = logging.getLogger("requests_oauthlib")
|
||||
requests_oauthlib.setLevel(logging.WARNING)
|
||||
oauthlib = logging.getLogger("oauthlib")
|
||||
oauthlib.setLevel(logging.WARNING)
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
#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.setLevel(logging.DEBUG)
|
||||
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.setLevel(logging.ERROR)
|
||||
logger.addHandler(error_handler)
|
||||
|
12
src/main.py
12
src/main.py
@ -17,7 +17,8 @@ if system == "Windows":
|
||||
import languageHandler
|
||||
import paths
|
||||
#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"
|
||||
import commandline
|
||||
import config
|
||||
@ -37,8 +38,8 @@ if system == "Windows":
|
||||
stderr_temp=sys.stderr
|
||||
#if it's a binary version
|
||||
if hasattr(sys, 'frozen'):
|
||||
sys.stderr = open(paths.logs_path("stderr.log"), 'w')
|
||||
sys.stdout = open(paths.logs_path("stdout.log"), 'w')
|
||||
sys.stderr = open(os.path.join(paths.logs_path(), "stderr.log"), 'w')
|
||||
sys.stdout = open(os.path.join(paths.logs_path(), "stdout.log"), 'w')
|
||||
else:
|
||||
sys.stdout=stdout
|
||||
sys.stderr=stderr
|
||||
@ -47,8 +48,8 @@ if system == "Windows":
|
||||
arch="x86"
|
||||
if platform.architecture()[0][:2] == "64":
|
||||
arch="x64"
|
||||
os.environ['PYTHON_VLC_MODULE_PATH']=str(os.path.abspath(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_MODULE_PATH']=os.path.abspath(os.path.join(paths.app_path(), "..", "windows-dependencies", arch))
|
||||
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
|
||||
stdout_temp.close()
|
||||
stderr_temp.close()
|
||||
@ -72,6 +73,7 @@ def setup():
|
||||
fixes.setup()
|
||||
output.setup()
|
||||
keys.setup()
|
||||
from controller import settings
|
||||
from controller import mainController
|
||||
from sessionmanager import sessionManager
|
||||
app = widgetUtils.mainLoopObject()
|
||||
|
@ -1,2 +1,3 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from . import widgets
|
@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import range
|
||||
from builtins import object
|
||||
import wx
|
||||
import platform
|
||||
import logging
|
||||
@ -27,7 +30,7 @@ class list(object):
|
||||
def create_list(self, parent):
|
||||
if self.system == "Windows":
|
||||
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]))
|
||||
else:
|
||||
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 sys
|
||||
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):
|
||||
"""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:
|
||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s" % app_subkey)
|
||||
inst_dir = _winreg.QueryValueEx(key,"InstallLocation")[0]
|
||||
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s" % app_subkey)
|
||||
inst_dir = winreg.QueryValueEx(key,"InstallLocation")[0]
|
||||
except WindowsError:
|
||||
return False
|
||||
_winreg.CloseKey(key)
|
||||
winreg.CloseKey(key)
|
||||
try:
|
||||
return os.stat(inst_dir) == os.stat(paths.app_path())
|
||||
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."""
|
||||
|
||||
try:
|
||||
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, RUN_REGKEY)
|
||||
val = _winreg.QueryValueEx(key, unicode(app_name))[0]
|
||||
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_REGKEY)
|
||||
val = winreg.QueryValueEx(key, str(app_name))[0]
|
||||
return os.stat(val) == os.stat(sys.argv[0])
|
||||
except (WindowsError, OSError):
|
||||
return False
|
||||
|
||||
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."""
|
||||
print paths.get_executable()
|
||||
if getAutoStart(app_name) == enable:
|
||||
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:
|
||||
_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:
|
||||
_winreg.DeleteValue(key, unicode(app_name))
|
||||
winreg.DeleteValue(key, str(app_name))
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
import os
|
||||
import languageHandler
|
||||
import logging
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
import threading
|
||||
import logging
|
||||
log = logging.getLogger("mysc.repeating_timer")
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: cp1252
|
||||
from __future__ import unicode_literals
|
||||
import sys, os
|
||||
|
||||
def restart_program():
|
||||
|
@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import logging
|
||||
log = logging.getLogger("mysc.thread_utils")
|
||||
import threading
|
||||
|
@ -2,6 +2,7 @@
|
||||
""" 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."""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
import platform
|
||||
|
||||
notify = None
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import dbus
|
||||
import application
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import wx
|
||||
|
||||
class notification(object):
|
||||
|
110
src/paths.py
110
src/paths.py
@ -1,85 +1,67 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import platform
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import glob
|
||||
from platform_utils import paths as paths_
|
||||
|
||||
from functools import wraps
|
||||
|
||||
mode = "portable"
|
||||
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():
|
||||
return paths_.app_path()
|
||||
return paths_.app_path()
|
||||
|
||||
@merge_paths
|
||||
def config_path():
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
if directory != None: path = os.path.join(directory, "config")
|
||||
elif directory == None: path = app_path(u"config")
|
||||
elif mode == "installed":
|
||||
path = data_path(u"config")
|
||||
if not os.path.exists(path):
|
||||
log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
return path
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
if directory != None: path = os.path.join(directory, "config")
|
||||
elif directory == None: path = os.path.join(app_path(), "config")
|
||||
elif mode == "installed":
|
||||
path = os.path.join(data_path(), "config")
|
||||
if not os.path.exists(path):
|
||||
# log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
return path
|
||||
|
||||
@merge_paths
|
||||
def logs_path():
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
if directory != None: path = os.path.join(directory, "logs")
|
||||
elif directory == None: path = app_path(u"logs")
|
||||
elif mode == "installed":
|
||||
path = data_path(u"logs")
|
||||
if not os.path.exists(path):
|
||||
log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
return path
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
if directory != None: path = os.path.join(directory, "logs")
|
||||
elif directory == None: path = os.path.join(app_path(), "logs")
|
||||
elif mode == "installed":
|
||||
path = os.path.join(data_path(), "logs")
|
||||
if not os.path.exists(path):
|
||||
# log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
return path
|
||||
|
||||
@merge_paths
|
||||
def data_path(app_name='TW blue'):
|
||||
# if platform.system() == "Windows":
|
||||
# import shlobj
|
||||
# data_path = os.path.join(shlobj.SHGetFolderPath(0, shlobj.CSIDL_APPDATA), app_name)
|
||||
# else:
|
||||
if platform.system() == "Windows":
|
||||
import winpaths
|
||||
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
|
||||
def data_path(app_name='socializer'):
|
||||
if platform.system() == "Windows":
|
||||
data_path = os.path.join(os.getenv("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():
|
||||
return app_path(u"locales")
|
||||
return os.path.join(app_path(), "locales")
|
||||
|
||||
@merge_paths
|
||||
def sound_path():
|
||||
return app_path(u"sounds")
|
||||
return os.path.join(app_path(), "sounds")
|
||||
|
||||
@merge_paths
|
||||
def com_path():
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
if directory != None: path = os.path.join(directory, "com_cache")
|
||||
elif directory == None: path = app_path(u"com_cache")
|
||||
elif mode == "installed":
|
||||
path = data_path(u"com_cache")
|
||||
if not os.path.exists(path):
|
||||
log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
return path
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
if directory != None: path = os.path.join(directory, "com_cache")
|
||||
elif directory == None: path = os.path.join(app_path(), "com_cache")
|
||||
elif mode == "installed":
|
||||
path = os.path.join(data_path(), "com_cache")
|
||||
if not os.path.exists(path):
|
||||
# log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
return path
|
||||
|
@ -6,4 +6,5 @@ Contents of this package:
|
||||
session_exceptions: Some useful exceptions when there is an error.
|
||||
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.
|
||||
"""
|
||||
"""
|
||||
from __future__ import unicode_literals
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
from gi.repository import Gtk
|
||||
import widgetUtils
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: cp1252 -*-
|
||||
#from config_utils import Configuration, ConfigurationResetException
|
||||
from __future__ import unicode_literals
|
||||
from builtins import object
|
||||
import config
|
||||
import paths
|
||||
import os
|
||||
|
@ -1,5 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
import shutil
|
||||
import widgetUtils
|
||||
import platform
|
||||
@ -43,14 +46,14 @@ class sessionManagerController(object):
|
||||
log.debug("Filling the sessions list.")
|
||||
self.sessions = []
|
||||
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,))
|
||||
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)
|
||||
if len(config_test) == 0:
|
||||
try:
|
||||
log.debug("Deleting session %s" % (i,))
|
||||
shutil.rmtree(paths.config_path(i))
|
||||
shutil.rmtree(os.path.join(paths.config_path(), i))
|
||||
continue
|
||||
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)
|
||||
@ -63,7 +66,7 @@ class sessionManagerController(object):
|
||||
else:
|
||||
try:
|
||||
log.debug("Deleting session %s" % (i,))
|
||||
shutil.rmtree(paths.config_path(i))
|
||||
shutil.rmtree(os.path.join(paths.config_path(), i))
|
||||
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)
|
||||
os.exception("Exception thrown while removing malformed session")
|
||||
@ -110,7 +113,7 @@ class sessionManagerController(object):
|
||||
self.view.remove_session(self.view.get_selected())
|
||||
self.removed_sessions.append(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):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
from multiplatform_widgets import widgets
|
||||
import application
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" this package contains code related to Sessions.
|
||||
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.
|
||||
sessions = {}
|
@ -1,6 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" A base class to be derived in possible new sessions for TWBlue and services."""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
import os
|
||||
import paths
|
||||
import output
|
||||
import time
|
||||
@ -53,7 +57,7 @@ class baseSession(object):
|
||||
""" Get settings for a session."""
|
||||
file_ = "%s/session.conf" % (self.session_id,)
|
||||
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.deshelve()
|
||||
|
||||
@ -71,7 +75,7 @@ class baseSession(object):
|
||||
|
||||
def shelve(self):
|
||||
"""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 os.path.exists(shelfname):
|
||||
os.remove(shelfname)
|
||||
@ -79,9 +83,9 @@ class baseSession(object):
|
||||
try:
|
||||
if not os.path.exists(shelfname):
|
||||
output.speak("Generating database, this might take a while.",True)
|
||||
shelf=shelve.open(paths.config_path(shelfname),'c')
|
||||
for key,value in self.db.items():
|
||||
if type(key) != str and type(key) != unicode:
|
||||
shelf=shelve.open(os.path.join(paths.config_path(), shelfname),'c')
|
||||
for key,value in list(self.db.items()):
|
||||
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)
|
||||
log.error("Uh oh, " + str(key) + " is of type " + str(type(key)) + "!")
|
||||
# Convert unicode objects to UTF-8 strings before shelve these objects.
|
||||
@ -97,14 +101,14 @@ class baseSession(object):
|
||||
|
||||
def deshelve(self):
|
||||
"""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 os.path.exists(shelfname):
|
||||
os.remove(shelfname)
|
||||
return
|
||||
try:
|
||||
shelf=shelve.open(paths.config_path(shelfname),'c')
|
||||
for key,value in shelf.items():
|
||||
shelf=shelve.open(os.path.join(paths.config_path(), shelfname),'c')
|
||||
for key,value in list(shelf.items()):
|
||||
self.db[key]=value
|
||||
shelf.close()
|
||||
except:
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: cp1252 -*-
|
||||
import exceptions
|
||||
from __future__ import unicode_literals
|
||||
|
||||
class InvalidSessionError(exceptions.Exception): pass
|
||||
class NonExistentSessionError(exceptions.Exception): pass
|
||||
class NotLoggedSessionError(exceptions.BaseException): pass
|
||||
class NotConfiguredSessionError(exceptions.BaseException): pass
|
||||
class RequireCredentialsSessionError(exceptions.BaseException): pass
|
||||
class AlreadyAuthorisedError(exceptions.BaseException): pass
|
||||
class InvalidSessionError(Exception): pass
|
||||
class NonExistentSessionError(Exception): pass
|
||||
class NotLoggedSessionError(BaseException): pass
|
||||
class NotConfiguredSessionError(BaseException): pass
|
||||
class RequireCredentialsSessionError(BaseException): pass
|
||||
class AlreadyAuthorisedError(BaseException): pass
|
@ -1,10 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
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
|
||||
system = platform.system()
|
||||
from . import utils
|
||||
import re
|
||||
import htmlentitydefs
|
||||
import html.entities
|
||||
import time
|
||||
import output
|
||||
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 #\d+, unichr(digits) will be returned.
|
||||
Else, a unicode string will be returned."""
|
||||
if match.group(1).startswith('#'): return unichr(int(match.group(1)[1:]))
|
||||
replacement = htmlentitydefs.entitydefs.get(match.group(1), "&%s;" % match.group(1))
|
||||
return replacement.decode('iso-8859-1')
|
||||
return unicode(entity_re.sub(matchFunc, s))
|
||||
if match.group(1).startswith('#'): return chr(int(match.group(1)[1:]))
|
||||
replacement = html.entities.entitydefs.get(match.group(1), "&%s;" % match.group(1))
|
||||
return replacement
|
||||
return str(entity_re.sub(matchFunc, s))
|
||||
|
||||
chars = "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
# -*- 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/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
from sessions.twitter import utils
|
||||
|
||||
def is_long(tweet):
|
||||
|
@ -17,6 +17,8 @@
|
||||
#
|
||||
############################################################
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from builtins import range
|
||||
import logging
|
||||
import requests
|
||||
import keys
|
||||
|
@ -1,6 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" This is the main session needed to access all Twitter Features."""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import range
|
||||
import os
|
||||
import time
|
||||
import logging
|
||||
@ -368,6 +370,7 @@ class Session(base.baseSession):
|
||||
else:
|
||||
return quoted_tweet
|
||||
original_tweet = self.check_long_tweet(original_tweet)
|
||||
|
||||
if "full_text" in original_tweet:
|
||||
value = "full_text"
|
||||
elif "message" in original_tweet:
|
||||
@ -430,7 +433,7 @@ class Session(base.baseSession):
|
||||
self.db["users"][user["id_str"]] = user
|
||||
return user["id_str"]
|
||||
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:
|
||||
return self.db["users"][i]["id_str"]
|
||||
user = utils.if_user_exists(self.twitter, screen_name)
|
||||
|
@ -1,5 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
import url_shortener, re
|
||||
import output
|
||||
from twython import TwythonError
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
|
||||
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):
|
||||
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):
|
||||
# try:
|
||||
@ -51,12 +51,12 @@ class soundSystem(object):
|
||||
def check_soundpack(self):
|
||||
""" Checks if the folder where live the current soundpack exists."""
|
||||
self.soundpack_OK = False
|
||||
if os.path.exists(paths.sound_path(self.config["current_soundpack"])):
|
||||
self.path = paths.sound_path(self.config["current_soundpack"])
|
||||
if os.path.exists(os.path.join(paths.sound_path(), self.config["current_soundpack"])):
|
||||
self.path = os.path.join(paths.sound_path(), self.config["current_soundpack"])
|
||||
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...")
|
||||
self.path = paths.sound_path("default")
|
||||
self.path = os.path.join(paths.sound_path(), "default")
|
||||
self.soundpack_OK = True
|
||||
else:
|
||||
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 os.path
|
||||
import platform
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
from logging import getLogger
|
||||
logger = getLogger('update')
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
import application
|
||||
from . import update
|
||||
import platform
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
def convert_bytes(n):
|
||||
K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
|
||||
if n >= P:
|
||||
|
@ -1,5 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
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 application
|
||||
from . import utils
|
||||
@ -25,7 +29,7 @@ def progress_callback(total_downloaded, total_size):
|
||||
if total_downloaded == total_size:
|
||||
progress_dialog.Destroy()
|
||||
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():
|
||||
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