Add --version argument
This commit is contained in:
parent
c3601a046b
commit
cea8426fcd
|
@ -15,6 +15,8 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
__version__ = '0.2.1'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib2 import urlopen, Request
|
from urllib2 import urlopen, Request
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -346,6 +348,10 @@ def ctrl_c(signum, frame):
|
||||||
raise SystemExit('\nCancelling...')
|
raise SystemExit('\nCancelling...')
|
||||||
|
|
||||||
|
|
||||||
|
def version():
|
||||||
|
raise SystemExit(__version__)
|
||||||
|
|
||||||
|
|
||||||
def speedtest():
|
def speedtest():
|
||||||
"""Run the full speedtest.net test"""
|
"""Run the full speedtest.net test"""
|
||||||
|
|
||||||
|
@ -377,6 +383,8 @@ def speedtest():
|
||||||
'sorted by distance')
|
'sorted by distance')
|
||||||
parser.add_argument('--server', help='Specify a server ID to test against')
|
parser.add_argument('--server', help='Specify a server ID to test against')
|
||||||
parser.add_argument('--mini', help='URL of the Speedtest Mini server')
|
parser.add_argument('--mini', help='URL of the Speedtest Mini server')
|
||||||
|
parser.add_argument('--version', action='store_true',
|
||||||
|
help='Show the version number and exit')
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
if isinstance(options, tuple):
|
if isinstance(options, tuple):
|
||||||
|
@ -385,6 +393,9 @@ def speedtest():
|
||||||
args = options
|
args = options
|
||||||
del options
|
del options
|
||||||
|
|
||||||
|
if args.version:
|
||||||
|
version()
|
||||||
|
|
||||||
if not args.simple:
|
if not args.simple:
|
||||||
print_('Retrieving speedtest.net configuration...')
|
print_('Retrieving speedtest.net configuration...')
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
|
Loading…
Reference in New Issue