From 46b46c4d6d018544b232d6c3ed68a50e8f7c1fdf Mon Sep 17 00:00:00 2001 From: Jose Manuel Delicado Date: Sat, 30 Jan 2016 17:14:41 +0100 Subject: [PATCH] Some important code fixes --- src/controller/buffersController.py | 2 +- src/controller/settings.py | 34 +++++++-------- src/extra/translator/translator.py | 10 ++--- src/libloader/libloader.py | 2 +- src/platform_utils/libloader.py | 2 +- src/sessionmanager/sessionManager.py | 1 + src/setup.py | 64 ++++++++++++++-------------- src/sound.py | 2 + src/sound_lib/music.py | 14 +++--- 9 files changed, 67 insertions(+), 64 deletions(-) diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index 149f6459..1d500a87 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -1088,7 +1088,7 @@ class conversationBufferController(searchBufferController): if dlg == widgetUtils.YES: self.timer.cancel() return True - elif dlg == WidgetUtils.NO: + elif dlg == widgetUtils.NO: return False class pocketBufferController(baseBufferController): diff --git a/src/controller/settings.py b/src/controller/settings.py index 3a040d61..19d8e456 100644 --- a/src/controller/settings.py +++ b/src/controller/settings.py @@ -261,24 +261,24 @@ class accountSettingsController(globalSettingsController): if change == True: self.dialog.buffers.change_selected_item() - def manage_pocket(self, *args, **kwargs): - if self.dialog.services.get_pocket_status() == _(u"Connect your Pocket account"): - self.connect_pocket() - else: - self.disconnect_pocket() +# def manage_pocket(self, *args, **kwargs): +# if self.dialog.services.get_pocket_status() == _(u"Connect your Pocket account"): +# self.connect_pocket() +# else: +# self.disconnect_pocket() - def connect_pocket(self): - dlg = self.dialog.services.show_pocket_dialog() - if dlg == widgetUtils.YES: - request_token = pocket.Pocket.get_request_token(consumer_key=keys.keyring.get("pocket_consumer_key"), redirect_uri="http://127.0.0.1:8080") - auth_url = pocket.Pocket.get_auth_url(code=request_token, redirect_uri="http://127.0.0.1:8080") - webbrowser.open_new_tab(auth_url) - httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', 8080), authorisationHandler.handler) - while authorisationHandler.logged == False: - httpd.handle_request() - user_credentials = pocket.Pocket.get_credentials(consumer_key=keys.keyring.get("pocket_consumer_key"), code=request_token) - self.dialog.services.set_pocket(True) - self.config["services"]["pocket_access_token"] = user_credentials["access_token"] +# def connect_pocket(self): +# dlg = self.dialog.services.show_pocket_dialog() +# if dlg == widgetUtils.YES: +# request_token = pocket.Pocket.get_request_token(consumer_key=keys.keyring.get("pocket_consumer_key"), redirect_uri="http://127.0.0.1:8080") +# auth_url = pocket.Pocket.get_auth_url(code=request_token, redirect_uri="http://127.0.0.1:8080") +# webbrowser.open_new_tab(auth_url) +# httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', 8080), authorisationHandler.handler) +# while authorisationHandler.logged == False: +# httpd.handle_request() +# user_credentials = pocket.Pocket.get_credentials(consumer_key=keys.keyring.get("pocket_consumer_key"), code=request_token) +# self.dialog.services.set_pocket(True) +# self.config["services"]["pocket_access_token"] = user_credentials["access_token"] def disconnect_dropbox(self): self.config["services"]["pocket_access_token"] = "" diff --git a/src/extra/translator/translator.py b/src/extra/translator/translator.py index f2c65407..0ec6e4c1 100644 --- a/src/extra/translator/translator.py +++ b/src/extra/translator/translator.py @@ -101,8 +101,8 @@ languages = { } def available_languages(): - l = languages.keys() - d = languages.values() - l.insert(0, '') - d.insert(0, _(u"autodetect")) - return sorted(zip(l, d)) + l = languages.keys() + d = languages.values() + l.insert(0, '') + d.insert(0, _(u"autodetect")) + return sorted(zip(l, d)) diff --git a/src/libloader/libloader.py b/src/libloader/libloader.py index 6ab2c0e2..6aa7c32f 100644 --- a/src/libloader/libloader.py +++ b/src/libloader/libloader.py @@ -32,7 +32,7 @@ def load_library(library, x86_path='.', x64_path='.', *args, **kwargs): loaded = _do_load(lib, *args, **kwargs) if loaded is not None: return loaded - raise LibraryLoadError('unable to load %r. Provided library path: %r' % (library, path)) + raise LibraryLoadError('unable to load %r. Provided library path: %r' % (library, lib)) def _do_load(file, *args, **kwargs): loader = TYPES[platform.system()]['loader'] diff --git a/src/platform_utils/libloader.py b/src/platform_utils/libloader.py index 548207d3..bb540e18 100644 --- a/src/platform_utils/libloader.py +++ b/src/platform_utils/libloader.py @@ -32,7 +32,7 @@ def load_library(library, x86_path='.', x64_path='.', *args, **kwargs): loaded = _do_load(lib, *args, **kwargs) if loaded is not None: return loaded - raise LibraryLoadError('unable to load %r. Provided library path: %r' % (library, path)) + raise LibraryLoadError('unable to load %r. Provided library path: %r' % (library, lib)) def _do_load(file, *args, **kwargs): loader = TYPES[platform.system()]['loader'] diff --git a/src/sessionmanager/sessionManager.py b/src/sessionmanager/sessionManager.py index 733ccdc1..5bc11b35 100644 --- a/src/sessionmanager/sessionManager.py +++ b/src/sessionmanager/sessionManager.py @@ -2,6 +2,7 @@ import shutil import widgetUtils import platform +import output if platform.system() == "Windows": import wxUI as view from controller import settings diff --git a/src/setup.py b/src/setup.py index 3cb97eec..b0dd5514 100644 --- a/src/setup.py +++ b/src/setup.py @@ -28,22 +28,22 @@ from glob import glob import wx def get_architecture_files(): - if platform.architecture()[0][:2] == "32": - return [ + if platform.architecture()[0][:2] == "32": + return [ ("", ["../windows-dependencies/x86/oggenc2.exe", "../windows-dependencies/x86/bootstrap.exe"]), ("Microsoft.VC90.CRT", glob("../windows-dependencies/x86/Microsoft.VC90.CRT/*")), ("Microsoft.VC90.MFC", glob("../windows-dependencies/x86/Microsoft.VC90.MFC/*")),] - elif platform.architecture()[0][:2] == "64": - return [ + elif platform.architecture()[0][:2] == "64": + return [ ("", ["../windows-dependencies/x64/oggenc2.exe", "../windows-dependencies/x86/bootstrap.exe"]), ("Microsoft.VC90.CRT", glob("../windows-dependencies/x64/Microsoft.VC90.CRT/*")), ("Microsoft.VC90.MFC", glob("../windows-dependencies/x64/Microsoft.VC90.MFC/*")),] def get_data(): - import accessible_output2 - import sound_lib - import enchant - return [ + import accessible_output2 + import sound_lib + import enchant + return [ ("", ["conf.defaults", "app-configuration.defaults", "icon.ico"]), ("requests", ["cacert.pem"]), ("accessible_output2/lib", glob("accessible_output2/lib/*.dll")), @@ -52,33 +52,33 @@ def get_data(): ]+get_sounds()+get_locales()+get_documentation()+sound_lib.find_datafiles()+accessible_output2.find_datafiles()+enchant.utils.win32_data_files()+get_architecture_files()+wx_files() def get_documentation (): - answer = [] - depth = 6 - for root, dirs, files in os.walk('documentation'): - if depth == 0: - break - new = (root, glob(os.path.join(root, "*.html"))) - answer.append(new) - depth -= 1 - return answer + answer = [] + depth = 6 + for root, dirs, files in os.walk('documentation'): + if depth == 0: + break + new = (root, glob(os.path.join(root, "*.html"))) + answer.append(new) + depth -= 1 + return answer def get_sounds(): - answer = [] - depth = 6 - for root, dirs, files in os.walk('sounds'): - if depth == 0: - break - new = (root, glob(os.path.join(root, "*.ogg"))) - answer.append(new) - depth -= 1 - return answer + answer = [] + depth = 6 + for root, dirs, files in os.walk('sounds'): + if depth == 0: + break + new = (root, glob(os.path.join(root, "*.ogg"))) + answer.append(new) + depth -= 1 + return answer def get_locales(): - answer = [] - for root, dirs, files in os.walk('locales'): - new = (root, glob(os.path.join(root, '*.mo'))) - answer.append(new) - return answer + answer = [] + for root, dirs, files in os.walk('locales'): + new = (root, glob(os.path.join(root, '*.mo'))) + answer.append(new) + return answer def wx_files(): wxDir=wx.__path__[0] @@ -99,7 +99,7 @@ def wx_files(): return list(localeMoFiles) if __name__ == '__main__': - setup( + setup( name = application.name, author = application.author, author_email = application.authorEmail, diff --git a/src/sound.py b/src/sound.py index 4e46cf0c..34ef40e9 100644 --- a/src/sound.py +++ b/src/sound.py @@ -14,6 +14,8 @@ system = platform.system() from mysc.repeating_timer import RepeatingTimer from mysc.thread_utils import call_threaded import application +import tempfile +import glob URLPlayer = None def setup(): diff --git a/src/sound_lib/music.py b/src/sound_lib/music.py index 96d09f4a..9ccbee85 100644 --- a/src/sound_lib/music.py +++ b/src/sound_lib/music.py @@ -5,14 +5,14 @@ from .channel import Channel class Music(Channel): def __init__(self, mem=False, file=None, offset=0, length=0, flags=0, freq=0): - handle = BASS_MusicLoad(mem, file, offset, length, flags, freq) + handle = pybass.BASS_MusicLoad(mem, file, offset, length, flags, freq) super(Music, self).__init__(handle) self.add_attributes_to_mapping( music_amplify=pybass.BASS_ATTRIB_MUSIC_AMPLIFY, - music_bpm = BASS_ATTRIB_MUSIC_BPM, - music_pansep=BASS_ATTRIB_MUSIC_PANSEP, - music_speed=BASS_ATTRIB_MUSIC_SPEED, - music_vol_chan=BASS_ATTRIB_MUSIC_VOL_CHAN, - music_vol_global=BASS_ATTRIB_MUSIC_VOL_GLOBAL, - music_vol_inst=BASS_ATTRIB_MUSIC_VOL_INST, + music_bpm = pybass.BASS_ATTRIB_MUSIC_BPM, + music_pansep=pybass.BASS_ATTRIB_MUSIC_PANSEP, + music_speed=pybass.BASS_ATTRIB_MUSIC_SPEED, + music_vol_chan=pybass.BASS_ATTRIB_MUSIC_VOL_CHAN, + music_vol_global=pybass.BASS_ATTRIB_MUSIC_VOL_GLOBAL, + music_vol_inst=pybass.BASS_ATTRIB_MUSIC_VOL_INST, )