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

wicd-cli: write diagnostics to stderr #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions cli/wicd-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
'org.wicd.daemon.config'
)
except dbus.DBusException:
print 'Error: Could not connect to the daemon. ' + \
'Please make sure it is running.'
sys.stderr.write('Error: Could not connect to the daemon. ' + \
'Please make sure it is running.\n')
sys.exit(3)

if not daemon:
print 'Error connecting to wicd via D-Bus. ' + \
'Please make sure the wicd service is running.'
sys.stderr.write('Error connecting to wicd via D-Bus. ' + \
'Please make sure the wicd service is running.\n')
sys.exit(3)

parser = optparse.OptionParser()
Expand Down Expand Up @@ -86,8 +86,8 @@
op_performed = False

if not (options.wireless or options.wired) and not options.status:
print "Please use --wireless or --wired to specify " + \
"the type of connection to operate on."
sys.stderr.write("Please use --wireless or --wired to specify " + \
"the type of connection to operate on.\n")

if options.status:
status, info = daemon.GetConnectionStatus()
Expand Down Expand Up @@ -130,21 +130,21 @@ def is_valid_wireless_network_id(network_id):
""" Check if it's a valid wireless network. '"""
if not (network_id >= 0 \
and network_id < wireless.GetNumberOfNetworks()):
print 'Invalid wireless network identifier.'
sys.stderr.write('Invalid wireless network identifier.\n')
sys.exit(1)

def is_valid_wired_network_id(network_id):
""" Check if it's a valid wired network. '"""
num = len(wired.GetWiredProfileList())
if not (network_id < num and \
network_id >= 0):
print 'Invalid wired network identifier.'
sys.stderr.write('Invalid wired network identifier.\n')
sys.exit(4)

def is_valid_wired_network_profile(profile_name):
""" Check if it's a valid wired network profile. '"""
if not profile_name in wired.GetWiredProfileList():
print 'Profile of that name does not exist.'
sys.stderr.write('Profile of that name does not exist.\n')
sys.exit(5)

if options.scan and options.wireless:
Expand Down