mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-17 13:46:07 -04:00
Merge branch 'next-gen' into update_japanese_translation
This commit is contained in:
@@ -24,8 +24,8 @@ mention_all = boolean(default=False)
|
||||
no_streaming = boolean(default=False)
|
||||
|
||||
[proxy]
|
||||
type = string(default="Direct connection")
|
||||
type = integer(default=0)
|
||||
server = string(default="")
|
||||
port = string(default="")
|
||||
port = integer(default=8080)
|
||||
user = string(default="")
|
||||
password = string(default="")
|
@@ -9,7 +9,7 @@ log = logging.getLogger("config")
|
||||
|
||||
MAINFILE = "twblue.conf"
|
||||
MAINSPEC = "app-configuration.defaults"
|
||||
proxyTypes=[u"http", u"https", u"socks4", u"socks5"]
|
||||
proxyTypes = ["system", "http", "socks4", "socks4a", "socks5", "socks5h"]
|
||||
app = None
|
||||
keymap=None
|
||||
changed_keymap = False
|
||||
|
@@ -145,7 +145,7 @@ class baseBufferController(baseBuffers.buffer):
|
||||
while l != False:
|
||||
tweetsList.append(tweet)
|
||||
try:
|
||||
tweet = self.session.twitter.get_status(id=l, include_ext_alt_text=True)
|
||||
tweet = self.session.twitter.get_status(id=l, include_ext_alt_text=True, tweet_mode="extended")
|
||||
tweet.full_text = utils.expand_urls(tweet.full_text, tweet.entities)
|
||||
except TweepError as e:
|
||||
utils.twitter_error(e)
|
||||
|
@@ -225,7 +225,7 @@ class viewTweet(basicTweet):
|
||||
else:
|
||||
text = text + " @%s: %s\n" % (tweetList[i].user.screen_name, getattr(tweetList[i], value))
|
||||
# tweets with extended_entities could include image descriptions.
|
||||
if getattr(tweetList[i], "extended_entities") and "media" in tweetList[i].extended_entities:
|
||||
if hasattr(tweetList[i], "extended_entities") and "media" in tweetList[i].extended_entities:
|
||||
for z in tweetList[i].extended_entities["media"]:
|
||||
if "ext_alt_text" in z and z["ext_alt_text"] != None:
|
||||
image_description.append(z["ext_alt_text"])
|
||||
|
@@ -74,12 +74,12 @@ class globalSettingsController(object):
|
||||
self.dialog.set_value("general", "update_period", config.app["app-settings"]["update_period"])
|
||||
self.dialog.set_value("general", "check_for_updates", config.app["app-settings"]["check_for_updates"])
|
||||
self.dialog.set_value("general", "remember_mention_and_longtweet", config.app["app-settings"]["remember_mention_and_longtweet"])
|
||||
proxyTypes=config.proxyTypes
|
||||
self.dialog.create_proxy([_(u"Direct connection")]+proxyTypes)
|
||||
if config.app["proxy"]["type"] not in proxyTypes:
|
||||
proxyTypes = [_("System default"), _("HTTP"), _("SOCKS v4"), _("SOCKS v4 with DNS support"), _("SOCKS v5"), _("SOCKS v5 with DNS support")]
|
||||
self.dialog.create_proxy(proxyTypes)
|
||||
try:
|
||||
self.dialog.proxy.type.SetSelection(config.app["proxy"]["type"])
|
||||
except:
|
||||
self.dialog.proxy.type.SetSelection(0)
|
||||
else:
|
||||
self.dialog.proxy.type.SetSelection(proxyTypes.index(config.app["proxy"]["type"])+1)
|
||||
self.dialog.set_value("proxy", "server", config.app["proxy"]["server"])
|
||||
self.dialog.set_value("proxy", "port", config.app["proxy"]["port"])
|
||||
self.dialog.set_value("proxy", "user", config.app["proxy"]["user"])
|
||||
@@ -121,7 +121,7 @@ class globalSettingsController(object):
|
||||
if config.app["proxy"]["type"]!=self.dialog.get_value("proxy", "type") or config.app["proxy"]["server"] != self.dialog.get_value("proxy", "server") or config.app["proxy"]["port"] != self.dialog.get_value("proxy", "port") or config.app["proxy"]["user"] != self.dialog.get_value("proxy", "user") or config.app["proxy"]["password"] != self.dialog.get_value("proxy", "password"):
|
||||
if self.is_started == True:
|
||||
self.needs_restart = True
|
||||
config.app["proxy"]["type"]=self.dialog.get_value("proxy", "type")
|
||||
config.app["proxy"]["type"] = self.dialog.proxy.type.Selection
|
||||
config.app["proxy"]["server"] = self.dialog.get_value("proxy", "server")
|
||||
config.app["proxy"]["port"] = self.dialog.get_value("proxy", "port")
|
||||
config.app["proxy"]["user"] = self.dialog.get_value("proxy", "user")
|
||||
|
15
src/main.py
15
src/main.py
@@ -65,6 +65,7 @@ log = logging.getLogger("main")
|
||||
def setup():
|
||||
log.debug("Starting " + application.name + " %s" % (application.version,))
|
||||
config.setup()
|
||||
proxy_setup()
|
||||
log.debug("Using %s %s" % (platform.system(), platform.architecture()[0]))
|
||||
log.debug("Application path is %s" % (paths.app_path(),))
|
||||
log.debug("config path is %s" % (paths.config_path(),))
|
||||
@@ -77,6 +78,7 @@ def setup():
|
||||
from controller import mainController
|
||||
from sessionmanager import sessionManager
|
||||
app = widgetUtils.mainLoopObject()
|
||||
check_pid()
|
||||
if system == "Windows":
|
||||
if config.app["app-settings"]["donation_dialog_displayed"] == False:
|
||||
donation()
|
||||
@@ -90,7 +92,6 @@ def setup():
|
||||
if hasattr(sm.view, "destroy"):
|
||||
sm.view.destroy()
|
||||
del sm
|
||||
check_pid()
|
||||
r = mainController.Controller()
|
||||
r.view.show()
|
||||
r.do_work()
|
||||
@@ -101,6 +102,18 @@ def setup():
|
||||
GLib.idle_add(r.start)
|
||||
app.run()
|
||||
|
||||
def proxy_setup():
|
||||
if config.app["proxy"]["server"] != "" and config.app["proxy"]["type"] > 0:
|
||||
log.debug("Loading proxy settings")
|
||||
proxy_url = config.app["proxy"]["server"] + ":" + str(config.app["proxy"]["port"])
|
||||
if config.app["proxy"]["user"] != "" and config.app["proxy"]["password"] != "":
|
||||
proxy_url = config.app["proxy"]["user"] + ":" + config.app["proxy"]["password"] + "@" + proxy_url
|
||||
elif config.app["proxy"]["user"] != "" and config.proxyTypes[config.app["proxy"]["type"]] in ["socks4", "socks4a"]:
|
||||
proxy_url = config.app["proxy"]["user"] + "@" + proxy_url
|
||||
proxy_url = config.proxyTypes[config.app["proxy"]["type"]] + "://" + proxy_url
|
||||
os.environ["HTTP_PROXY"] = proxy_url
|
||||
os.environ["HTTPS_PROXY"] = proxy_url
|
||||
|
||||
def donation():
|
||||
dlg = commonMessageDialogs.donation()
|
||||
if dlg == widgetUtils.YES:
|
||||
|
@@ -1,13 +1,9 @@
|
||||
# -*- 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
|
||||
import wx
|
||||
from pubsub import pub
|
||||
from twython import TwythonRateLimitError
|
||||
|
||||
def call_threaded(func, *args, **kwargs):
|
||||
#Call the given function in a daemonized thread and return the thread.
|
||||
@@ -19,20 +15,6 @@ def call_threaded(func, *args, **kwargs):
|
||||
except:
|
||||
log.exception("Thread %d with function %r, args of %r, and kwargs of %r failed to run." % (threading.current_thread().ident, func, a, k))
|
||||
# pass
|
||||
thread = threading.Thread(target=new_func, args=args, kwargs=kwargs)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
return thread
|
||||
|
||||
def stream_threaded(func, *args, **kwargs):
|
||||
def new_func(*a, **k):
|
||||
try:
|
||||
func(**k)
|
||||
except Exception as msg:
|
||||
log.error("Error in stream with args: %r" % (a,))
|
||||
log.error(msg.message)
|
||||
pub.sendMessage("stream-error", session=a[0])
|
||||
|
||||
thread = threading.Thread(target=new_func, args=args, kwargs=kwargs)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
@@ -1,8 +1,4 @@
|
||||
# -*- 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
|
||||
@@ -21,7 +17,7 @@ from sessions.twitter import session
|
||||
from . import manager
|
||||
import config_utils
|
||||
import config
|
||||
from twython.exceptions import TwythonAuthError
|
||||
from tweepy.error import TweepError
|
||||
log = logging.getLogger("sessionmanager.sessionManager")
|
||||
|
||||
class sessionManagerController(object):
|
||||
@@ -87,7 +83,7 @@ class sessionManagerController(object):
|
||||
if i not in config.app["sessions"]["ignored_sessions"]:
|
||||
try:
|
||||
s.login()
|
||||
except TwythonAuthError:
|
||||
except TweepError:
|
||||
self.show_auth_error(s.settings["twitter"]["user_name"])
|
||||
continue
|
||||
sessions.sessions[i] = s
|
||||
|
@@ -79,7 +79,7 @@ class proxy(wx.Panel, baseDialog.BaseWXDialog):
|
||||
serverBox.Add(self.server, 0, wx.ALL, 5)
|
||||
sizer.Add(serverBox, 0, wx.ALL, 5)
|
||||
lbl = wx.StaticText(self, wx.ID_ANY, _(u"Port: "))
|
||||
self.port = wx.TextCtrl(self, wx.ID_ANY)
|
||||
self.port = wx.SpinCtrl(self, wx.ID_ANY, min=1, max=65535)
|
||||
portBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
portBox.Add(lbl, 0, wx.ALL, 5)
|
||||
portBox.Add(self.port, 0, wx.ALL, 5)
|
||||
|
Reference in New Issue
Block a user