1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 12:28:08 +01:00

Implement --status/-i in wicd-cli, to show current connection status.

This commit is contained in:
David Paleino
2012-09-26 17:32:12 +02:00
parent 1ece88dd29
commit 93a30244e3
3 changed files with 126 additions and 25 deletions

View File

@@ -20,6 +20,7 @@ import dbus
import dbus.service
import sys
from wicd import misc
from wicd.translations import _
misc.RenameProcess('wicd-cli')
@@ -61,19 +62,55 @@ parser.add_option('--network-details', '-d', default=False, action='store_true')
parser.add_option('--disconnect', '-x', default=False, action='store_true')
parser.add_option('--connect', '-c', default=False, action='store_true')
parser.add_option('--list-encryption-types', '-e', default=False, action='store_true')
# short options for these two aren't great.
# short options for these aren't great.
parser.add_option('--wireless', '-y', default=False, action='store_true')
parser.add_option('--wired', '-z', default=False, action='store_true')
parser.add_option('--load-profile', '-o', default=False, action='store_true')
parser.add_option('--status', '-i', default=False, action='store_true') # -i(nfo)
options, arguments = parser.parse_args()
op_performed = False
if not (options.wireless or options.wired):
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."
if options.status:
status, info = daemon.GetConnectionStatus()
if status in (misc.WIRED, misc.WIRELESS):
connected = True
status_msg = _('Connected')
if status == misc.WIRED:
conn_type = _('Wired')
else:
conn_type = _('Wireless')
else:
connected = False
status_msg = misc._const_status_dict[status]
print _('Connection status') + ': ' + status_msg
if connected:
print _('Connection type') + ': ' + conn_type
if status == misc.WIRELESS:
print _('Connected to $A at $B (IP: $C)') \
.replace('$A', info[1]) \
.replace('$B', info[2]) \
.replace('$C', info[0])
print _('Network ID: $A') \
.replace('$A', info[3])
else:
print _('Connected to wired network (IP: $A)') \
.replace('$A', info[0])
else:
if status == misc.CONNECTING:
if info[0] == 'wired':
print _('Connecting to wired network.')
elif info[0] == 'wireless':
print _('Connecting to wireless network "$A".') \
.replace('$A', info[1])
op_performed = True
# functions
def is_valid_wireless_network_id(network_id):
if not (network_id >= 0 \

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-06 21:25+0200\n"
"POT-Creation-Date: 2012-09-26 17:26+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -140,7 +140,7 @@ msgstr ""
msgid "Configuring preferences for wireless network \"$A\" ($B)"
msgstr ""
#: wicd/misc.py:82
#: wicd/misc.py:89
msgid "Configuring wireless interface..."
msgstr ""
@@ -152,10 +152,30 @@ msgstr ""
msgid "Connect to selected network"
msgstr ""
#: cli/wicd-cli.py:83
msgid "Connected"
msgstr ""
#: cli/wicd-cli.py:96
msgid "Connected to \"$A\" ($B)."
msgstr ""
#: curses/wicd-curses.py:158 gtk/gui.py:490 gtk/wicd-client.py:215
msgid "Connected to $A at $B (IP: $C)"
msgstr ""
#: cli/wicd-cli.py:102
msgid "Connected to $A."
msgstr ""
#: wicd/misc.py:53
msgid "Connected to a wired network"
msgstr ""
#: wicd/misc.py:52
msgid "Connected to a wireless network"
msgstr ""
#: curses/wicd-curses.py:133 gtk/gui.py:483 gtk/wicd-client.py:220
msgid "Connected to wired network (IP: $A)"
msgstr ""
@@ -164,23 +184,31 @@ msgstr ""
msgid "Connecting"
msgstr ""
#: wicd/misc.py:79
#: cli/wicd-cli.py:107
msgid "Connecting to wired network."
msgstr ""
#: cli/wicd-cli.py:109
msgid "Connecting to wireless network \"$A\"."
msgstr ""
#: wicd/misc.py:86
msgid "Connection Cancelled"
msgstr ""
#: wicd/misc.py:85
#: wicd/misc.py:92
msgid "Connection Failed."
msgstr ""
#: wicd/misc.py:81
#: wicd/misc.py:88
msgid "Connection Failed: Bad password"
msgstr ""
#: wicd/misc.py:91
#: wicd/misc.py:98
msgid "Connection Failed: No DHCP offers received."
msgstr ""
#: wicd/misc.py:83
#: wicd/misc.py:90
msgid "Connection Failed: Unable to Get IP Address"
msgstr ""
@@ -188,14 +216,30 @@ msgstr ""
msgid "Connection established"
msgstr ""
#: wicd/misc.py:80
#: wicd/misc.py:87
msgid "Connection failed: Could not contact the wireless access point."
msgstr ""
#: wicd/misc.py:97
#: wicd/misc.py:51
msgid "Connection in progress"
msgstr ""
#: cli/wicd-cli.py:92
msgid "Connection status"
msgstr ""
#: wicd/misc.py:104
msgid "Connection successful."
msgstr ""
#: wicd/misc.py:54
msgid "Connection suspended"
msgstr ""
#: cli/wicd-cli.py:94
msgid "Connection type"
msgstr ""
#: gtk/gui.py:65 gtk/wicd-client.py:955
msgid ""
"Could not connect to wicd's D-Bus interface. Check the wicd log for error "
@@ -274,7 +318,7 @@ msgstr ""
msgid "Domain"
msgstr ""
#: wicd/misc.py:84
#: wicd/misc.py:91
msgid "Done connecting..."
msgstr ""
@@ -300,7 +344,7 @@ msgstr ""
msgid "External Programs"
msgstr ""
#: wicd/misc.py:86
#: wicd/misc.py:93
msgid "Flushing the routing table..."
msgstr ""
@@ -316,11 +360,11 @@ msgstr ""
msgid "General Settings"
msgstr ""
#: wicd/misc.py:87
#: wicd/misc.py:94
msgid "Generating PSK..."
msgstr ""
#: wicd/misc.py:88
#: wicd/misc.py:95
msgid "Generating WPA configuration file..."
msgstr ""
@@ -385,6 +429,10 @@ msgstr ""
msgid "Netmask"
msgstr ""
#: cli/wicd-cli.py:99
msgid "Network ID: $A"
msgstr ""
#: curses/prefs_curses.py:66
msgid "Network Interfaces"
msgstr ""
@@ -399,6 +447,7 @@ msgstr ""
#: curses/wicd-curses.py:786 gtk/gui.py:500 gtk/wicd-client.py:213
#: gtk/wicd-client.py:223 gtk/wicd-client.py:335 gtk/wicd-client.py:338
#: wicd/misc.py:50
msgid "Not connected"
msgstr ""
@@ -409,7 +458,7 @@ msgstr ""
msgid "OK"
msgstr ""
#: wicd/misc.py:93
#: wicd/misc.py:100
msgid "Obtaining IP address..."
msgstr ""
@@ -503,11 +552,11 @@ msgstr ""
msgid "Properties"
msgstr ""
#: wicd/misc.py:89
#: wicd/misc.py:96
msgid "Putting interface down..."
msgstr ""
#: wicd/misc.py:90
#: wicd/misc.py:97
msgid "Putting interface up..."
msgstr ""
@@ -548,7 +597,7 @@ msgstr ""
msgid "Required encryption information is missing."
msgstr ""
#: wicd/misc.py:92
#: wicd/misc.py:99
msgid "Resetting IP address..."
msgstr ""
@@ -604,15 +653,15 @@ msgstr ""
msgid "Set up Ad-hoc network"
msgstr ""
#: wicd/misc.py:94
#: wicd/misc.py:101
msgid "Setting broadcast address..."
msgstr ""
#: wicd/misc.py:95
#: wicd/misc.py:102
msgid "Setting static DNS servers..."
msgstr ""
#: wicd/misc.py:96
#: wicd/misc.py:103
msgid "Setting static IP addresses..."
msgstr ""
@@ -733,11 +782,11 @@ msgstr ""
msgid "Username"
msgstr ""
#: wicd/misc.py:98
#: wicd/misc.py:105
msgid "Validating authentication..."
msgstr ""
#: wicd/misc.py:99
#: wicd/misc.py:106
msgid "Verifying access point association..."
msgstr ""
@@ -753,10 +802,14 @@ msgstr ""
msgid "Wicd daemon unreachable"
msgstr ""
#: wicd/misc.py:209
#: wicd/misc.py:216
msgid "Wicd needs to access your computer's network cards."
msgstr ""
#: cli/wicd-cli.py:85
msgid "Wired"
msgstr ""
#: gtk/wicd-client.py:628
msgid ""
"Wired\n"
@@ -790,6 +843,10 @@ msgstr ""
msgid "Wired connection detected"
msgstr ""
#: cli/wicd-cli.py:87
msgid "Wireless"
msgstr ""
#: gtk/wicd-client.py:633
msgid ""
"Wireless\n"

View File

@@ -46,6 +46,13 @@ CONNECTING = 1
WIRELESS = 2
WIRED = 3
SUSPENDED = 4
_const_status_dict = {
NOT_CONNECTED: _('Not connected'),
CONNECTING: _('Connection in progress'),
WIRELESS: _('Connected to a wireless network'),
WIRED: _('Connected to a wired network'),
SUSPENDED: _('Connection suspended'),
}
# Automatic app selection constant
AUTO = 0