Skip to content

Code Quality Fixes(5) #1523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/plugins/indicator_libmessaging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
"""
src/plugins/indicator_libmessaging.py
=====================================
"""

import gi
gi.require_version('MessagingMenu', '1.0') # noqa:E402
Expand All @@ -9,6 +13,7 @@


class IndicatorLibmessaging(object):
"""Plugin for libmessage indicator"""
def __init__(self, form):
try:
self.app = MessagingMenu.App(desktop_id='pybitmessage.desktop')
Expand All @@ -32,15 +37,18 @@ def __del__(self):
if self.app:
self.app.unregister()

def activate(self, app, source):
def activate(self, app, source): # pylint: disable=unused-argument
"""Activate the libmessaging indicator plugin"""
self.form.appIndicatorInbox(
self.new_message_item if source == 'messages'
else self.new_broadcast_item
)

# show the number of unread messages and subscriptions
# on the messaging menu
def show_unread(self, draw_attention=False):
"""
show the number of unread messages and subscriptions
on the messaging menu
"""
for source, count in zip(
('messages', 'subscriptions'),
self.form.getUnread()
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/menu_qrcode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
"""
src/plugins/menu_qrcode.py
==========================

A menu plugin showing QR-Code for bitmessage address in modal dialog.
"""

Expand All @@ -12,9 +15,10 @@


# http://stackoverflow.com/questions/20452486
class Image(qrcode.image.base.BaseImage):
class Image(qrcode.image.base.BaseImage): # pylint: disable=abstract-method
"""Image output class for qrcode using QPainter"""
def __init__(self, border, width, box_size):

def __init__(self, border, width, box_size): # pylint: disable=super-init-not-called
self.border = border
self.width = width
self.box_size = box_size
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/notification_notify2.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# -*- coding: utf-8 -*-
"""
src/plugins/notification_notify2.py
===================================
"""

import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify

Notify.init('pybitmessage')


def connect_plugin(title, subtitle, category, label, icon):
"""Plugin for notify2"""
if not icon:
icon = 'mail-message-new' if category == 2 else 'pybitmessage'
connect_plugin.notification.update(title, subtitle, icon)
connect_plugin.notification.show()


connect_plugin.notification = Notify.Notification.new("Init", "Init")
5 changes: 4 additions & 1 deletion src/plugins/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-

"""
src/plugins/plugin.py
===================================
"""
import pkg_resources


Expand Down
9 changes: 6 additions & 3 deletions src/plugins/proxyconfig_stem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-

"""
src/plugins/proxyconfig_stem.py
===================================
"""
import os
import logging
import random # noseq
Expand Down Expand Up @@ -29,14 +32,14 @@ def __call__(self, line):
# Plugin's debug or unexpected log line from tor
self._logger.debug(line)
else:
self._logger.log(self._levels.get(level, 10), '(tor)' + line)
self._logger.log(self._levels.get(level, 10), '(tor) %s', line)


def connect_plugin(config): # pylint: disable=too-many-branches
"""Run stem proxy configurator"""
logwrite = DebugLogger()
if config.safeGet('bitmessagesettings', 'sockshostname') not in (
'localhost', '127.0.0.1', ''
'localhost', '127.0.0.1', ''
):
# remote proxy is choosen for outbound connections,
# nothing to do here, but need to set socksproxytype to SOCKS5!
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/sound_canberra.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
"""
src/plugins/proxyconfig_stem.py
===================================
"""

from pybitmessage.bitmessageqt import sound

Expand All @@ -14,7 +18,8 @@
}


def connect_plugin(category, label=None):
def connect_plugin(category, label=None): # pylint: disable=unused-argument
"""This function implements the entry point."""
try:
_canberra.play(0, pycanberra.CA_PROP_EVENT_ID, _theme[category], None)
except (KeyError, pycanberra.CanberraException):
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/sound_gstreamer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-

"""
src/plugins/sound_gstreamer.py
===================================
"""
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst # noqa: E402
Expand All @@ -9,6 +12,7 @@


def connect_plugin(sound_file):
"""Entry point for sound file"""
_player.set_state(Gst.State.NULL)
_player.set_property("uri", "file://" + sound_file)
_player.set_state(Gst.State.PLAYING)
9 changes: 7 additions & 2 deletions src/plugins/sound_playfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# -*- coding: utf-8 -*-

"""
src/plugins/sound_playfile.py
===================================
"""

try:
import winsound

def connect_plugin(sound_file):
"""Plugin's entry point"""
winsound.PlaySound(sound_file, winsound.SND_FILENAME)
except ImportError:
import os
Expand All @@ -18,7 +22,8 @@ def _subprocess(*args):
args, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True)

def connect_plugin(sound_file):
global play_cmd
"""This function implements the entry point."""
global play_cmd # pylint: disable=global-statement

ext = os.path.splitext(sound_file)[-1]
try:
Expand Down