Update pull request according to feedback

This commit is contained in:
Charles Milette 2018-07-23 18:36:30 -04:00 committed by Samuel Henrique
parent 5cdcb4391f
commit 5469bbb53b
13 changed files with 27 additions and 30 deletions

View file

@ -5,14 +5,6 @@ class NamedEvent(ABC):
Interface representing an operating system event object with a name.
"""
@abstractmethod
def __init__(self, name: str):
"""
create NamedEvent object
:param name Name of the event
"""
pass
@abstractmethod
def is_set(self) -> bool:
"""

View file

@ -32,7 +32,10 @@ class PosixNamedEvent(NamedEvent):
return
def wait(self, timeout=None):
self.__semaphore.acquire(timeout)
try:
self.__semaphore.acquire(timeout)
except posix_ipc.BusyError:
return
def is_duplicate(self) -> bool:
return self.__duplicate

View file

@ -58,4 +58,4 @@ def start(filtered, delay, changer_func, event_name):
if pid > 0:
__print_fork(pid, len(filtered), delay)
sys.exit(0)
__slideshow_worker(filtered, delay, changer_func)
__slideshow_worker(filtered, delay, changer_func, event_name)

View file

@ -8,6 +8,7 @@ class TerminalProvider(ABC):
"""
@abstractmethod
@staticmethod
def change_terminal(path: str):
"""
This sets the wallpaper of the corresponding TE of this adapter.
@ -16,6 +17,7 @@ class TerminalProvider(ABC):
pass
@abstractmethod
@staticmethod
def is_compatible() -> bool:
"""
checks for compatibility
@ -25,6 +27,7 @@ class TerminalProvider(ABC):
pass
@abstractmethod
@staticmethod
def clear():
"""
Clear the terminal's background image.

View file

@ -11,7 +11,7 @@ class ConEmuProvider(_TProv):
return "CONEMUPID" in os.environ
def __run_command(command: str):
output = subprocess.check_output(f'ConEmuC -GuiMacro {command}').decode(sys.stdout.encoding)
output = subprocess.check_output(["ConEmuC", "-GuiMacro", command]).decode(sys.stdout.encoding)
if output != 'OK':
print(output)

View file

@ -13,10 +13,10 @@ class ItermProvider(_TProv):
end tell"""
def is_compatible() -> bool:
return os.environ.get("ITERM_PROFILE")
return "ITERM_PROFILE" in os.environ
def __run_osascript(stream):
p = subprocess.Popen(['osascript'], stdout=subprocess.PIPE,
p = subprocess.Popen(["osascript"], stdout=subprocess.PIPE,
stdin=subprocess.PIPE)
p.stdin.write(stream)
p.communicate()

View file

@ -9,7 +9,7 @@ class TerminologyProvider(_TProv):
return environ.get("TERMINOLOGY") == '1'
def change_terminal(path: str):
run(f'tybg "{path}"', check=True)
run(["tybg", path], check=True)
def clear():
run("tybg", check=True)

View file

@ -12,12 +12,10 @@ class TilixProvider(_TProv):
return "TILIX_ID" in environ
def change_terminal(path: str):
command = f'gsettings set {TilixProvider.setting_key} {TilixProvider.__setting_field} "{path}"'
run(command, check=True)
run(["gsettings", "set", TilixProvider.__setting_key, TilixProvider.__setting_field, path], check=True)
def clear():
command = f'gsettings reset {TilixProvider.setting_key} {TilixProvider.__setting_field}'
run(command, check=True)
run(["gsettings", "reset", TilixProvider.__setting_key, TilixProvider.__setting_field], check=True)
def __str__():
return "Tilix"

View file

@ -8,18 +8,20 @@ class WallpaperProvider(ABC):
"""
@abstractmethod
@staticmethod
def change_wallpaper(path: str):
"""
This sets the wallpaper of the corresponding D.E of this adapter.
:param path The full path of the required pokemon image
"""
raise NotImplementedError()
pass
@abstractmethod
@staticmethod
def is_compatible() -> bool:
"""
checks for compatibility
:return a boolean saying whether or not the current adaptor is
compatible with the running D.E
"""
raise NotImplementedError()
pass

View file

@ -12,7 +12,7 @@ class DarwinProvider(_WProv):
end tell"""
def __run_osascript(stream):
p = _sp.Popen(['osascript'], stdout=_sp.PIPE,
p = _sp.Popen(["osascript"], stdout=_sp.PIPE,
stdin=_sp.PIPE)
p.stdin.write(stream)
p.communicate()

View file

@ -7,17 +7,16 @@ from . import WallpaperProvider as _WProv
class FehProvider(_WProv):
__compatible_wm = ['I3_PID', '_OPENBOX_PID']
__compatible_wm = ["I3_PID", "_OPENBOX_PID"]
def change_wallpaper(path: str):
if (Path.home() / '.fehbg').is_file():
command = f'feh --bg-fill "{path}"'
else:
command = f'feh --no-fehbg --bg-fill "{path}"'
command = ["feh", "--bg-fill", path]
if not (Path.home() / ".fehbg").is_file():
command.insert(1, "--no-fehbg")
subprocess.run(command, check=True)
def __get_root_props() -> str:
return subprocess.check_output('xprop -root -notype').decode(sys.stdout.encoding)
return subprocess.check_output("xprop -root -notype").decode(sys.stdout.encoding)
def is_compatible() -> bool:
return (which("feh") is not None

View file

@ -5,8 +5,8 @@ from . import WallpaperProvider as _WProv
class GnomeProvider(_WProv):
def change_wallpaper(path: str) -> None:
run(f'gsettings set org.gnome.desktop.background picture-uri "file://{path}"', check=True)
def change_wallpaper(path: str):
run(["gsettings", "set", "org.gnome.desktop.background", "picture-uri", f"file://{path}"], check=True)
def is_compatible() -> bool:
return "gnome" in environ.get("DESKTOP_SESSION", default='').lower()

View file

@ -10,7 +10,7 @@ class Win32Provider(_WProv):
windll.user32.SystemParametersInfoW(WindowsProvider.__SPI_SETDESKWALLPAPER, 0, path, 0)
def is_compatible() -> bool:
return sys.platform == 'win32'
return sys.platform == "win32"
def __str__():
return "Windows Desktop"