- Fix #220
This commit is contained in:
parent
9344f59e19
commit
8737ba2e43
11 changed files with 63 additions and 54 deletions
|
|
@ -18,6 +18,8 @@ import gi
|
|||
import sys
|
||||
from .settings import SettingsWindow
|
||||
|
||||
log = logging.getLogger("about_settings")
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
# pylint: disable=wrong-import-position,wrong-import-order
|
||||
from gi.repository import Gtk, Gdk, GLib # nopep8
|
||||
|
|
@ -68,7 +70,7 @@ class AboutSettingsWindow(Gtk.Grid):
|
|||
self.set_column_homogeneous(True)
|
||||
|
||||
def close_app(self, button):
|
||||
logging.info("Quit pressed")
|
||||
log.info("Quit pressed")
|
||||
sys.exit(0)
|
||||
|
||||
def present_settings(self):
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ except ModuleNotFoundError:
|
|||
from xdg import XDG_CONFIG_HOME as xdg_config_home
|
||||
from xdg import XDG_DATA_HOME as xdg_data_home
|
||||
|
||||
log = logging.getLogger("autostart")
|
||||
|
||||
class Autostart:
|
||||
"""A class to assist auto-start"""
|
||||
|
|
@ -33,7 +34,7 @@ class Autostart:
|
|||
xdg_data_home, 'applications/'), '/usr/share/applications/']
|
||||
self.auto = self.find_auto()
|
||||
self.desktop = self.find_desktop()
|
||||
logging.info("Autostart info : desktop %s auto %s",
|
||||
log.info("Autostart info : desktop %s auto %s",
|
||||
self.desktop, self.auto)
|
||||
|
||||
def find_auto(self):
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import calendar
|
|||
import websocket
|
||||
import requests
|
||||
|
||||
log = logging.getLogger("discord_connector")
|
||||
|
||||
class DiscordConnector:
|
||||
"""
|
||||
|
|
@ -115,10 +116,10 @@ class DiscordConnector:
|
|||
if channel != self.current_voice:
|
||||
if channel in self.channels:
|
||||
channel_name = self.channels[channel]['name']
|
||||
logging.info(
|
||||
log.info(
|
||||
"Joined room: %s", channel_name)
|
||||
else:
|
||||
logging.info("Joining private room")
|
||||
log.info("Joining private room")
|
||||
self.sub_voice_channel(channel)
|
||||
self.current_voice = channel
|
||||
if need_req:
|
||||
|
|
@ -133,7 +134,7 @@ class DiscordConnector:
|
|||
return
|
||||
if channel != self.current_text:
|
||||
self.current_text = channel
|
||||
logging.info(
|
||||
log.info(
|
||||
"Changing text room: %s", channel)
|
||||
if need_req:
|
||||
self.req_channel_details(channel)
|
||||
|
|
@ -328,7 +329,7 @@ class DiscordConnector:
|
|||
if self.current_text == j["data"]["channel_id"]:
|
||||
self.delete_text(j["data"]["message"])
|
||||
else:
|
||||
logging.info(j)
|
||||
log.info(j)
|
||||
return
|
||||
elif j["cmd"] == "AUTHENTICATE":
|
||||
if j["evt"] == "ERROR":
|
||||
|
|
@ -337,9 +338,9 @@ class DiscordConnector:
|
|||
else:
|
||||
self.req_guilds()
|
||||
self.user = j["data"]["user"]
|
||||
logging.info(
|
||||
log.info(
|
||||
"ID is %s", self.user["id"])
|
||||
logging.info(
|
||||
log.info(
|
||||
"Logged in as %s", self.user["username"])
|
||||
self.authed = True
|
||||
return
|
||||
|
|
@ -364,7 +365,7 @@ class DiscordConnector:
|
|||
elif j["cmd"] == "GET_CHANNEL":
|
||||
self.request_text_rooms_awaiting -= 1
|
||||
if j["evt"] == "ERROR":
|
||||
logging.info(
|
||||
log.info(
|
||||
"Could not get room")
|
||||
return
|
||||
if j["data"]["type"] == 2: # Voice channel
|
||||
|
|
@ -385,7 +386,7 @@ class DiscordConnector:
|
|||
if j['data']['position'] >= len(self.request_text_rooms_response):
|
||||
# Error. The list of channels has changed since we requested last
|
||||
self.needs_guild_rerequest = 60 * 30
|
||||
logging.error(
|
||||
log.error(
|
||||
"IndexError getting channel information. Starting again in 30 seconds")
|
||||
pass
|
||||
else:
|
||||
|
|
@ -404,7 +405,7 @@ class DiscordConnector:
|
|||
self.request_text_rooms = None
|
||||
|
||||
return
|
||||
logging.info(j)
|
||||
log.info(j)
|
||||
|
||||
def check_guilds(self):
|
||||
"""
|
||||
|
|
@ -433,13 +434,13 @@ class DiscordConnector:
|
|||
"""
|
||||
Called when an error has occured
|
||||
"""
|
||||
logging.error("ERROR : %s", error)
|
||||
log.error("ERROR : %s", error)
|
||||
|
||||
def on_close(self):
|
||||
"""
|
||||
Called when connection is closed
|
||||
"""
|
||||
logging.info("Connection closed")
|
||||
log.info("Connection closed")
|
||||
self.voice_overlay.hide()
|
||||
if self.text_overlay:
|
||||
self.text_overlay.hide()
|
||||
|
|
@ -480,7 +481,7 @@ class DiscordConnector:
|
|||
print("Requesting channels for guild:",
|
||||
self.guilds.get(guild))
|
||||
else:
|
||||
logging.info(f"Didn't find guild with id {guild}")
|
||||
log.info(f"Didn't find guild with id {guild}")
|
||||
# cmd = {
|
||||
# "cmd": "GET_CHANNELS",
|
||||
# "args": {
|
||||
|
|
@ -527,7 +528,7 @@ class DiscordConnector:
|
|||
if self.channels[channel]["type"] == 2:
|
||||
self.req_channel_details(channel)
|
||||
count += 1
|
||||
logging.warning("Getting %s rooms", count)
|
||||
log.warning("Getting %s rooms", count)
|
||||
|
||||
def sub_raw(self, event, args, nonce):
|
||||
"""
|
||||
|
|
@ -593,12 +594,12 @@ class DiscordConnector:
|
|||
if not self.websocket:
|
||||
self.connect()
|
||||
if self.warn_connection:
|
||||
logging.info(
|
||||
log.info(
|
||||
"Unable to connect to Discord client")
|
||||
self.warn_connection = False
|
||||
return True
|
||||
if self.needs_guild_rerequest == 0:
|
||||
logging.error("Re-requesting guild list")
|
||||
log.error("Re-requesting guild list")
|
||||
self.request_text_rooms_for_guild(self.last_requested_guild)
|
||||
if self.needs_guild_rerequest >= 0:
|
||||
self.needs_guild_rerequest -= 1
|
||||
|
|
@ -674,7 +675,7 @@ class DiscordConnector:
|
|||
None] * len(guild["channels"])
|
||||
self.req_all_channel_details(guild_id)
|
||||
else:
|
||||
logging.warning(
|
||||
log.warning(
|
||||
f"Trying to request channel details for guild without "
|
||||
f"cached channels. This is likely because the guild id is "
|
||||
f"not in guild ids. Please add {guild_id} to the guild "
|
||||
|
|
@ -696,5 +697,5 @@ class DiscordConnector:
|
|||
)
|
||||
except ConnectionError as error:
|
||||
if self.error_connection:
|
||||
logging.error(error)
|
||||
log.error(error)
|
||||
self.error_connection = False
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ try:
|
|||
except ModuleNotFoundError:
|
||||
from xdg import XDG_CONFIG_HOME as xdg_config_home
|
||||
|
||||
log = logging.getLogger("discover_overlay")
|
||||
|
||||
class Discover:
|
||||
"""Main application class"""
|
||||
|
|
@ -58,7 +59,7 @@ class Discover:
|
|||
|
||||
self.do_args(args, True)
|
||||
if "GAMESCOPE_WAYLAND_DISPLAY" in os.environ:
|
||||
logging.info(
|
||||
log.info(
|
||||
"GameScope session detected. Enabling steam and gamescope integration")
|
||||
self.steamos = True
|
||||
self.show_settings_delay = True
|
||||
|
|
@ -239,7 +240,7 @@ class Discover:
|
|||
self.ind.set_menu(menu)
|
||||
except (ImportError, ValueError) as exception:
|
||||
# Create System Tray
|
||||
logging.info("Falling back to Systray : %s", exception)
|
||||
log.info("Falling back to Systray : %s", exception)
|
||||
self.tray = Gtk.StatusIcon.new_from_icon_name(
|
||||
"discover-overlay-tray")
|
||||
self.tray.connect('popup-menu', self.show_menu)
|
||||
|
|
@ -341,10 +342,10 @@ def entrypoint():
|
|||
if "--rpc" in sys.argv:
|
||||
with open(rpc_file, "w") as tfile:
|
||||
tfile.write(line)
|
||||
logging.warning("Sent RPC command")
|
||||
log.warning("Sent RPC command")
|
||||
else:
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
logging.info("Flatpak compat mode started")
|
||||
log.info("Flatpak compat mode started")
|
||||
Discover(rpc_file, debug_file, line)
|
||||
return
|
||||
|
||||
|
|
@ -355,8 +356,8 @@ def entrypoint():
|
|||
logging.getLogger().setLevel(logging.INFO)
|
||||
Discover(rpc_file, debug_file, line)
|
||||
except pidfile.AlreadyRunningError:
|
||||
logging.warning("Discover overlay is currently running")
|
||||
log.warning("Discover overlay is currently running")
|
||||
|
||||
with open(rpc_file, "w") as tfile:
|
||||
tfile.write(line)
|
||||
logging.warning("Sent RPC command")
|
||||
log.warning("Sent RPC command")
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ gi.require_version('GdkPixbuf', '2.0')
|
|||
# pylint: disable=wrong-import-position
|
||||
from gi.repository import Gio, GdkPixbuf # nopep8
|
||||
|
||||
log = logging.getLogger("image_getter")
|
||||
|
||||
class ImageGetter():
|
||||
"""Older attempt. Not advised as it can't manage anything but PNG. Loads to GDK Pixmap"""
|
||||
|
|
@ -54,9 +55,9 @@ class ImageGetter():
|
|||
|
||||
self.func(self.identifier, pixbuf)
|
||||
except urllib.error.URLError as exception:
|
||||
logging.error(
|
||||
log.error(
|
||||
"Could not access : %s", self.url)
|
||||
logging.error(exception)
|
||||
log.error(exception)
|
||||
|
||||
|
||||
class SurfaceGetter():
|
||||
|
|
@ -83,19 +84,19 @@ class SurfaceGetter():
|
|||
|
||||
self.func(self.identifier, surface)
|
||||
except requests.HTTPError:
|
||||
logging.error("Unable to open %s", self.url)
|
||||
log.error("Unable to open %s", self.url)
|
||||
except requests.TooManyRedirects:
|
||||
logging.error("Unable to open %s - Too many redirects", self.url)
|
||||
log.error("Unable to open %s - Too many redirects", self.url)
|
||||
except requests.Timeout:
|
||||
logging.error("Unable to open %s - Timeout", self.url)
|
||||
log.error("Unable to open %s - Timeout", self.url)
|
||||
except requests.ConnectionError:
|
||||
logging.error("Unable to open %s - Connection error", self.url)
|
||||
log.error("Unable to open %s - Connection error", self.url)
|
||||
except ValueError:
|
||||
logging.error("Unable to read %s", self.url)
|
||||
log.error("Unable to read %s", self.url)
|
||||
except TypeError:
|
||||
logging.error("Unable to read %s", self.url)
|
||||
log.error("Unable to read %s", self.url)
|
||||
except PIL.UnidentifiedImageError:
|
||||
logging.error("Unknown image type")
|
||||
log.error("Unknown image type")
|
||||
|
||||
def get_file(self):
|
||||
locations = [os.path.expanduser('~/.local/'), '/usr/', '/']
|
||||
|
|
@ -105,13 +106,13 @@ class SurfaceGetter():
|
|||
try:
|
||||
image = Image.open(mixpath)
|
||||
except ValueError:
|
||||
logging.error("Value Erorr - Unable to read %s", mixpath)
|
||||
log.error("Value Erorr - Unable to read %s", mixpath)
|
||||
except TypeError:
|
||||
logging.error("Type Error - Unable to read %s", mixpath)
|
||||
log.error("Type Error - Unable to read %s", mixpath)
|
||||
except PIL.UnidentifiedImageError:
|
||||
logging.error("Unknown image type: %s", mixpath)
|
||||
log.error("Unknown image type: %s", mixpath)
|
||||
except FileNotFoundError:
|
||||
logging.error("File not found: %s", mixpath)
|
||||
log.error("File not found: %s", mixpath)
|
||||
surface = from_pil(image)
|
||||
if surface:
|
||||
self.func(self.identifier, surface)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""Notification setting tab on settings window"""
|
||||
import json
|
||||
import logging
|
||||
from configparser import ConfigParser
|
||||
import gi
|
||||
from .settings import SettingsWindow
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ try:
|
|||
except (ImportError, ValueError):
|
||||
pass
|
||||
|
||||
log = logging.getLogger("overlay")
|
||||
|
||||
class OverlayWindow(Gtk.Window):
|
||||
"""
|
||||
|
|
@ -71,7 +72,7 @@ class OverlayWindow(Gtk.Window):
|
|||
screen = self.get_screen()
|
||||
visual = screen.get_rgba_visual()
|
||||
if not self.get_display().supports_input_shapes():
|
||||
logging.info(
|
||||
log.info(
|
||||
"Input shapes not available. Quitting")
|
||||
sys.exit(1)
|
||||
if visual:
|
||||
|
|
@ -106,7 +107,7 @@ class OverlayWindow(Gtk.Window):
|
|||
# Xatom.CARDINAL,16,
|
||||
# [0xffff], X.PropModeReplace)
|
||||
|
||||
logging.info("Setting STEAM_EXTERNAL_OVERLAY")
|
||||
log.info("Setting STEAM_EXTERNAL_OVERLAY")
|
||||
display.sync()
|
||||
self.monitor = 0
|
||||
self.align_right = True
|
||||
|
|
@ -127,9 +128,9 @@ class OverlayWindow(Gtk.Window):
|
|||
"""
|
||||
if self.is_wayland:
|
||||
if not GtkLayerShell.is_supported():
|
||||
logging.info(
|
||||
log.info(
|
||||
"GTK Layer Shell is not supported on this wayland compositor")
|
||||
logging.info("Currently not possible: Gnome, Plasma, Weston")
|
||||
log.info("Currently not possible: Gnome, Plasma, Weston")
|
||||
sys.exit(0)
|
||||
GtkLayerShell.init_for_window(self)
|
||||
GtkLayerShell.set_layer(self, GtkLayerShell.Layer.OVERLAY)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ try:
|
|||
except ModuleNotFoundError:
|
||||
from xdg import XDG_CONFIG_HOME as xdg_config_home
|
||||
|
||||
log = logging.getLogger("settings")
|
||||
|
||||
class SettingsWindow(Gtk.VBox):
|
||||
"""
|
||||
|
|
@ -95,7 +96,7 @@ class SettingsWindow(Gtk.VBox):
|
|||
for i in range(0, display.get_n_monitors()):
|
||||
if display.get_monitor(i).get_model() == name:
|
||||
return i
|
||||
logging.info(
|
||||
log.info(
|
||||
"Could not find monitor : %s", name)
|
||||
return 0
|
||||
|
||||
|
|
@ -108,7 +109,7 @@ class SettingsWindow(Gtk.VBox):
|
|||
for i in range(0, display.get_n_monitors()):
|
||||
if display.get_monitor(i).get_model() == name:
|
||||
return display.get_monitor(i)
|
||||
logging.info(
|
||||
log.info(
|
||||
"Could not find monitor : %s", name)
|
||||
return None
|
||||
|
||||
|
|
@ -139,7 +140,7 @@ class SettingsWindow(Gtk.VBox):
|
|||
self.floating_w = width
|
||||
self.floating_h = height
|
||||
|
||||
logging.info("Positioned overlay : %s , %s %s x %s", self.floating_x,
|
||||
log.info("Positioned overlay : %s , %s %s x %s", self.floating_x,
|
||||
self.floating_y, self.floating_w, self.floating_h)
|
||||
self.overlay.set_floating(True, pos_x, pos_y, width, height)
|
||||
self.save_config()
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ gi.require_version('PangoCairo', '1.0')
|
|||
# pylint: disable=wrong-import-position,wrong-import-order
|
||||
from gi.repository import Pango, PangoCairo # nopep8
|
||||
|
||||
log = logging.getLogger("text_overlay")
|
||||
|
||||
class TextOverlayWindow(OverlayWindow):
|
||||
"""Overlay window for voice"""
|
||||
|
|
@ -151,7 +152,7 @@ class TextOverlayWindow(OverlayWindow):
|
|||
ret = '\n'
|
||||
else:
|
||||
if message["type"] not in self.warned_filetypes:
|
||||
logging.error("Unknown text type : %s", message["type"])
|
||||
log.error("Unknown text type : %s", message["type"])
|
||||
self.warned_filetypes.append(message['type'])
|
||||
return ret
|
||||
|
||||
|
|
@ -217,7 +218,7 @@ class TextOverlayWindow(OverlayWindow):
|
|||
url, None)
|
||||
self.attachment[url] = None # Avoid asking repeatedly
|
||||
else:
|
||||
logging.warning("Unknown file extension '%s'", extension)
|
||||
log.warning("Unknown file extension '%s'", extension)
|
||||
# cy = self.draw_text(cy, "%s" % (line['attach']))
|
||||
message = "<span foreground='%s'>%s</span>: %s" % (self.sanitize_string(col),
|
||||
self.sanitize_string(
|
||||
|
|
@ -303,7 +304,7 @@ class TextOverlayWindow(OverlayWindow):
|
|||
"""
|
||||
# print(shape.data, self.image_list, self.attachment)
|
||||
if shape.data >= len(self.image_list):
|
||||
logging.warning(f"{shape.data} >= {len(self.image_list)}")
|
||||
log.warning(f"{shape.data} >= {len(self.image_list)}")
|
||||
return
|
||||
# key is the url to the image
|
||||
key = self.image_list[shape.data]
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from gi.repository import Gtk, Gdk # nopep8
|
|||
|
||||
|
||||
GUILD_DEFAULT_VALUE = "0"
|
||||
|
||||
log = logging.getLogger("text_settings")
|
||||
|
||||
class TextSettingsWindow(SettingsWindow):
|
||||
"""Text setting tab on settings window"""
|
||||
|
|
@ -196,8 +196,8 @@ class TextSettingsWindow(SettingsWindow):
|
|||
return
|
||||
self.list_guilds = in_list
|
||||
self.list_guilds_keys = []
|
||||
logging.warn("Guild list")
|
||||
logging.warn(in_list)
|
||||
log.warn("Guild list")
|
||||
log.warn(in_list)
|
||||
for key in in_list.keys():
|
||||
self.list_guilds_keys.append(key)
|
||||
self.list_guilds_keys.sort()
|
||||
|
|
@ -234,7 +234,7 @@ class TextSettingsWindow(SettingsWindow):
|
|||
"text", "show_attach", fallback=True)
|
||||
self.autohide = config.getboolean("text", "autohide", fallback=False)
|
||||
|
||||
logging.info(
|
||||
log.info(
|
||||
"Loading saved channel %s", self.channel)
|
||||
|
||||
# Pass all of our config over to the overlay
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ gi.require_version('PangoCairo', '1.0')
|
|||
# pylint: disable=wrong-import-position,wrong-import-order
|
||||
from gi.repository import Pango, PangoCairo # nopep8
|
||||
|
||||
log = logging.getLogger("voice_overlay")
|
||||
|
||||
class VoiceOverlayWindow(OverlayWindow):
|
||||
"""Overlay window for voice"""
|
||||
|
|
@ -192,7 +193,7 @@ class VoiceOverlayWindow(OverlayWindow):
|
|||
if _id not in self.guild_ids:
|
||||
self.discover.connection.req_channels(_id)
|
||||
except AttributeError as _e:
|
||||
logging.error(_e)
|
||||
log.error(_e)
|
||||
pass
|
||||
self.guild_ids = guild_ids
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue