Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(self):
self.loop = GLib.MainLoop()
if self.config.notifications:
try:
notify2.init("pantalaimon", mainloop=self.loop)
self.notifications = True
except dbus.DBusException:
logger.error(
"Notifications are enabled but no notification "
"server could be found, disabling notifications."
)
self.notifications = False
GLib.timeout_add(100, self.message_callback)
self.loop.run()
def __attrs_post_init__(self):
loop = asyncio.get_event_loop()
self.homeserver_url = self.homeserver.geturl()
self.hostname = self.homeserver.hostname
self.store = PanStore(self.data_dir)
accounts = self.store.load_users(self.name)
for user_id, device_id in accounts:
if self.conf.keyring:
try:
token = keyring.get_password(
"pantalaimon", f"{user_id}-{device_id}-token"
)
except RuntimeError as e:
logger.error(e)
else:
token = self.store.load_access_token(user_id, device_id)
if not token:
logger.warn(
f"Not restoring client for {user_id} {device_id}, "
f"missing access token."
)
continue
logger.info(f"Restoring client for {user_id} {device_id}")
pan_client = PanClient(
self.name,
self.store,
self.conf,
def __attrs_post_init__(self):
loop = asyncio.get_event_loop()
self.homeserver_url = self.homeserver.geturl()
self.hostname = self.homeserver.hostname
self.store = PanStore(self.data_dir)
accounts = self.store.load_users(self.name)
for user_id, device_id in accounts:
if self.conf.keyring:
try:
token = keyring.get_password(
"pantalaimon", f"{user_id}-{device_id}-token"
)
except RuntimeError as e:
logger.error(e)
else:
token = self.store.load_access_token(user_id, device_id)
if not token:
logger.warn(
f"Not restoring client for {user_id} {device_id}, "
f"missing access token."
)
continue
logger.info(f"Restoring client for {user_id} {device_id}")
pan_client = PanClient(
self.name,
self.store,
self.conf,
await self.send_ui_message(
UpdateUsersMessage(self.name, user_id, pan_client.device_id)
)
self.pan_clients[user_id] = pan_client
if self.conf.keyring:
try:
keyring.set_password(
"pantalaimon",
f"{user_id}-{pan_client.device_id}-token",
pan_client.access_token,
)
except RuntimeError as e:
logger.error(e)
else:
self.store.save_access_token(
user_id, pan_client.device_id, pan_client.access_token
)
pan_client.start_loop()
await self.send_ui_message(
UpdateUsersMessage(self.name, user_id, pan_client.device_id)
)
self.pan_clients[user_id] = pan_client
if self.conf.keyring:
try:
keyring.set_password(
"pantalaimon",
f"{user_id}-{pan_client.device_id}-token",
pan_client.access_token,
)
except RuntimeError as e:
logger.error(e)
else:
self.store.save_access_token(
user_id, pan_client.device_id, pan_client.access_token
)
pan_client.start_loop()