Skip to content
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

Use whereis_exe to check for binaries #79

Merged
merged 4 commits into from
Jul 15, 2014
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
7 changes: 6 additions & 1 deletion plyer/platforms/linux/battery.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from subprocess import Popen, PIPE
from plyer.facades import Battery
from plyer.utils import whereis_exe


class LinuxBattery(Battery):
Expand Down Expand Up @@ -31,4 +32,8 @@ def _get_status(self):


def instance():
return LinuxBattery()
import sys
if whereis_exe('upower'):
return LinuxBattery()
sys.stderr.write("upower not found.")
return Battery()
7 changes: 6 additions & 1 deletion plyer/platforms/linux/email.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
from urllib import quote
from plyer.facades import Email
from plyer.utils import whereis_exe


class LinuxEmail(Email):
Expand All @@ -26,4 +27,8 @@ def _send(self, **kwargs):


def instance():
return LinuxEmail()
import sys
if whereis_exe('xdg-open'):
return LinuxEmail()
sys.stderr.write("xdg-open not found.")
return Email()
7 changes: 6 additions & 1 deletion plyer/platforms/linux/uniqueid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from subprocess import Popen, PIPE
from plyer.facades import UniqueID
from plyer.utils import whereis_exe


class LinuxUniqueID(UniqueID):
Expand All @@ -17,4 +18,8 @@ def _get_uid(self):


def instance():
return LinuxUniqueID()
import sys
if whereis_exe('lshw'):
return LinuxUniqueID()
sys.stderr.write("lshw not found.")
return UniqueID()
7 changes: 6 additions & 1 deletion plyer/platforms/macosx/battery.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from subprocess import Popen, PIPE
from plyer.facades import Battery
from plyer.utils import whereis_exe


class OSXBattery(Battery):
Expand Down Expand Up @@ -32,4 +33,8 @@ def _get_status(self):


def instance():
return OSXBattery()
import sys
if whereis_exe('ioreg'):
return OSXBattery()
sys.stderr.write("ioreg not found.")
return Battery()
7 changes: 6 additions & 1 deletion plyer/platforms/macosx/email.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
from urllib import quote
from plyer.facades import Email
from plyer.utils import whereis_exe


class MacOSXEmail(Email):
Expand All @@ -26,4 +27,8 @@ def _send(self, **kwargs):


def instance():
return MacOSXEmail()
import sys
if whereis_exe('open'):
return MacOSXEmail()
sys.stderr.write("open not found.")
return Email()
7 changes: 6 additions & 1 deletion plyer/platforms/macosx/uniqueid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from subprocess import Popen, PIPE
from plyer.facades import UniqueID
from plyer.utils import whereis_exe


class OSXUniqueID(UniqueID):
Expand All @@ -17,4 +18,8 @@ def _get_uid(self):


def instance():
return OSXUniqueID()
import sys
if whereis_exe('ioreg'):
return OSXUniqueID()
sys.stderr.write("ioreg not found.")
return UniqueID()