Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103102
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Adam Funk <a24061@ducksburg.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Testing whether the VPN is running? |
| Date | Thu, 18 Feb 2016 10:03:20 +0000 |
| Organization | $CABAL |
| Lines | 34 |
| Message-ID | <8ghgpcxrd3.ln2@news.ducksburg.com> (permalink) |
| References | <2cfgpcxdg2.ln2@news.ducksburg.com> <mailman.240.1455788735.22075.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net Wh//vmvVDsfwzBuMNKAPxQLptYnUIZVftkxbUk3UlpX9/33vBr |
| X-Orig-Path | news.ducksburg.com!not-for-mail |
| Cancel-Lock | sha1:FGQYu3LosvvAsHtD4kkEoI0nugc= |
| User-Agent | slrn/pre1.0.3-10 (Linux) |
| Xref | csiph.com comp.lang.python:103102 |
Show key headers only | View raw
On 2016-02-18, Ervin Hegedüs wrote: > Hi Adam, > > On Thu, Feb 18, 2016 at 09:26:58AM +0000, Adam Funk wrote: >> I'd like to test (inside a python 3 program) whether the VPN is >> running or not. The only thing I can think of so far is to use >> subprocess to run the 'ifconfig' command, then check its output for >> 'tun0'. Is there a better way? > > you didn't wrote, which system (OS) you want to use - based on > the "ifconfig" and "tun0" keywords, possible that's a Linux. Oops, sorry! But your educated guess is right. :-) > I think that the psutil modul could be better for you for this > task: > > https://pypi.python.org/pypi/psutil/ > > and see the "Network" section. if 'tun0' in psutil.net_if_addrs(): # vpn is running Brilliant! I've used psutil for something else, but I didn't know it did that too. My excuse is that the version on my system was 2.2.1, which does not do that, so I installed the newer version with pip3. Thanks for pointing me to that. -- XML is like violence: if it doesn't solve the problem, use more.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Testing whether the VPN is running? Adam Funk <a24061@ducksburg.com> - 2016-02-18 09:26 +0000
Re: Testing whether the VPN is running? Ervin Hegedüs <airween@gmail.com> - 2016-02-18 10:45 +0100
Re: Testing whether the VPN is running? Adam Funk <a24061@ducksburg.com> - 2016-02-18 10:03 +0000
Re: Testing whether the VPN is running? Cameron Simpson <cs@zip.com.au> - 2016-02-23 19:24 +1100
Re: Testing whether the VPN is running? Adam Funk <a24061@ducksburg.com> - 2016-02-25 13:25 +0000
Re: Testing whether the VPN is running? Gisle Vanem <gvanem@yahoo.no> - 2016-02-23 10:40 +0100
Re: Testing whether the VPN is running? Dan Stromberg <drsalists@gmail.com> - 2016-02-25 15:01 -0800
csiph-web